Eliminate BlobStorageData
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 May 2014 22:11:07 +0000 (22:11 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 May 2014 22:11:07 +0000 (22:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132617

Reviewed by Anders Carlsson.

* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* platform/network/BlobData.h:
(WebCore::BlobData::create):
(WebCore::BlobData::BlobData):
* platform/network/BlobRegistryImpl.cpp:
(WebCore::loadResourceSynchronously):
(WebCore::BlobRegistryImpl::appendStorageItems):
(WebCore::BlobRegistryImpl::registerFileBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURLForSlice):
(WebCore::BlobRegistryImpl::getBlobDataFromURL):
(WebCore::BlobRegistryImpl::blobSize):
* platform/network/BlobRegistryImpl.h:
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::createAsync):
(WebCore::BlobResourceHandle::loadResourceSynchronously):
(WebCore::BlobResourceHandle::BlobResourceHandle):
(WebCore::BlobResourceHandle::doStart):
(WebCore::BlobResourceHandle::getSizeForNext):
(WebCore::BlobResourceHandle::didGetSize):
(WebCore::BlobResourceHandle::seek):
(WebCore::BlobResourceHandle::readSync):
(WebCore::BlobResourceHandle::readDataSync):
(WebCore::BlobResourceHandle::readFileSync):
(WebCore::BlobResourceHandle::readAsync):
(WebCore::BlobResourceHandle::readDataAsync):
(WebCore::BlobResourceHandle::readFileAsync):
(WebCore::BlobResourceHandle::notifyResponseOnSuccess):
* platform/network/BlobResourceHandle.h:
* platform/network/BlobStorageData.h: Removed.
* platform/network/FormData.cpp:
(WebCore::appendBlobResolved):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::addEncodedBlobToSoupMessageBody):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168382 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/network/BlobData.h
Source/WebCore/platform/network/BlobRegistryImpl.cpp
Source/WebCore/platform/network/BlobRegistryImpl.h
Source/WebCore/platform/network/BlobResourceHandle.cpp
Source/WebCore/platform/network/BlobResourceHandle.h
Source/WebCore/platform/network/BlobStorageData.h [deleted file]
Source/WebCore/platform/network/FormData.cpp
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

index 992c568..5830e35 100644 (file)
@@ -1,3 +1,47 @@
+2014-05-06  Alexey Proskuryakov  <ap@apple.com>
+
+        Eliminate BlobStorageData
+        https://bugs.webkit.org/show_bug.cgi?id=132617
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/network/BlobData.h:
+        (WebCore::BlobData::create):
+        (WebCore::BlobData::BlobData):
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::loadResourceSynchronously):
+        (WebCore::BlobRegistryImpl::appendStorageItems):
+        (WebCore::BlobRegistryImpl::registerFileBlobURL):
+        (WebCore::BlobRegistryImpl::registerBlobURL):
+        (WebCore::BlobRegistryImpl::registerBlobURLForSlice):
+        (WebCore::BlobRegistryImpl::getBlobDataFromURL):
+        (WebCore::BlobRegistryImpl::blobSize):
+        * platform/network/BlobRegistryImpl.h:
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::createAsync):
+        (WebCore::BlobResourceHandle::loadResourceSynchronously):
+        (WebCore::BlobResourceHandle::BlobResourceHandle):
+        (WebCore::BlobResourceHandle::doStart):
+        (WebCore::BlobResourceHandle::getSizeForNext):
+        (WebCore::BlobResourceHandle::didGetSize):
+        (WebCore::BlobResourceHandle::seek):
+        (WebCore::BlobResourceHandle::readSync):
+        (WebCore::BlobResourceHandle::readDataSync):
+        (WebCore::BlobResourceHandle::readFileSync):
+        (WebCore::BlobResourceHandle::readAsync):
+        (WebCore::BlobResourceHandle::readDataAsync):
+        (WebCore::BlobResourceHandle::readFileAsync):
+        (WebCore::BlobResourceHandle::notifyResponseOnSuccess):
+        * platform/network/BlobResourceHandle.h:
+        * platform/network/BlobStorageData.h: Removed.
+        * platform/network/FormData.cpp:
+        (WebCore::appendBlobResolved):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::addEncodedBlobToSoupMessageBody):
+
 2014-05-06  Simon Fraser  <simon.fraser@apple.com>
 
         Fix the iOS build.
index 752cb49..f15f79c 100644 (file)
     <ClInclude Include="..\platform\network\BlobRegistry.h" />
     <ClInclude Include="..\platform\network\BlobRegistryImpl.h" />
     <ClInclude Include="..\platform\network\BlobResourceHandle.h" />
-    <ClInclude Include="..\platform\network\BlobStorageData.h" />
     <ClInclude Include="..\platform\network\CookieStorage.h" />
     <ClInclude Include="..\platform\network\Credential.h" />
     <ClInclude Include="..\platform\network\CredentialStorage.h" />
index f7f78bf..9a708d3 100644 (file)
     <ClInclude Include="..\platform\network\BlobResourceHandle.h">
       <Filter>platform\network</Filter>
     </ClInclude>
-    <ClInclude Include="..\platform\network\BlobStorageData.h">
-      <Filter>platform\network</Filter>
-    </ClInclude>
     <ClInclude Include="..\platform\network\CookieStorage.h">
       <Filter>platform\network</Filter>
     </ClInclude>
index dbeb74a..c7dd37f 100644 (file)
                2EDEF1F5121B0EFC00726DB2 /* BlobRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDEF1EF121B0EFC00726DB2 /* BlobRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2EDEF1F6121B0EFC00726DB2 /* BlobRegistryImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EDEF1F0121B0EFC00726DB2 /* BlobRegistryImpl.cpp */; };
                2EDEF1F7121B0EFC00726DB2 /* BlobRegistryImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDEF1F1121B0EFC00726DB2 /* BlobRegistryImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               2EDEF1F8121B0EFC00726DB2 /* BlobStorageData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDEF1F2121B0EFC00726DB2 /* BlobStorageData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2EDF369C122C94B4002F7D4E /* FileReaderSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EDF369A122C94B4002F7D4E /* FileReaderSync.cpp */; };
                2EDF369D122C94B4002F7D4E /* FileReaderSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDF369B122C94B4002F7D4E /* FileReaderSync.h */; };
                2EDF369F122C94C8002F7D4E /* FileException.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDF369E122C94C8002F7D4E /* FileException.h */; };
                2EDEF1EF121B0EFC00726DB2 /* BlobRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobRegistry.h; sourceTree = "<group>"; };
                2EDEF1F0121B0EFC00726DB2 /* BlobRegistryImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobRegistryImpl.cpp; sourceTree = "<group>"; };
                2EDEF1F1121B0EFC00726DB2 /* BlobRegistryImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobRegistryImpl.h; sourceTree = "<group>"; };
-               2EDEF1F2121B0EFC00726DB2 /* BlobStorageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobStorageData.h; sourceTree = "<group>"; };
                2EDF369A122C94B4002F7D4E /* FileReaderSync.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileReaderSync.cpp; path = fileapi/FileReaderSync.cpp; sourceTree = "<group>"; };
                2EDF369B122C94B4002F7D4E /* FileReaderSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileReaderSync.h; path = fileapi/FileReaderSync.h; sourceTree = "<group>"; };
                2EDF369E122C94C8002F7D4E /* FileException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileException.h; path = fileapi/FileException.h; sourceTree = "<group>"; };
                                2EDEF1F1121B0EFC00726DB2 /* BlobRegistryImpl.h */,
                                2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */,
                                2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */,
-                               2EDEF1F2121B0EFC00726DB2 /* BlobStorageData.h */,
                                E13F01EA1270E10D00DFBA71 /* CookieStorage.h */,
                                514C76580CE923A1007EF3CD /* Credential.cpp */,
                                514C76590CE923A1007EF3CD /* Credential.h */,
                                2EDEF1F5121B0EFC00726DB2 /* BlobRegistry.h in Headers */,
                                2EDEF1F7121B0EFC00726DB2 /* BlobRegistryImpl.h in Headers */,
                                2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */,
-                               2EDEF1F8121B0EFC00726DB2 /* BlobStorageData.h in Headers */,
                                A5F36D3B18F758720054C024 /* PageScriptDebugServer.h in Headers */,
                                976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */,
                                93F199BE08245E59001E9ABC /* BlockExceptions.h in Headers */,
index b1a8595..6278595 100644 (file)
@@ -35,6 +35,7 @@
 #include "URL.h"
 #include <wtf/Forward.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/RefCounted.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/text/WTFString.h>
 
@@ -154,10 +155,12 @@ private:
 
 typedef Vector<BlobDataItem> BlobDataItemList;
 
-class BlobData {
-    WTF_MAKE_FAST_ALLOCATED;
+class BlobData : public RefCounted<BlobData> {
 public:
-    BlobData() { }
+    static PassRefPtr<BlobData> create()
+    {
+        return adoptRef(new BlobData);
+    }
 
     const String& contentType() const { return m_contentType; }
     void setContentType(const String&);
@@ -172,10 +175,8 @@ public:
 
 private:
     friend class BlobRegistryImpl;
-    friend class BlobStorageData;
 
-    // This is only exposed to BlobStorageData.
-    void appendData(const RawData&, long long offset, long long length);
+    BlobData() { }
 
     String m_contentType;
     String m_contentDisposition;
index 42832d1..f37f3b4 100644 (file)
@@ -34,9 +34,9 @@
 
 #if ENABLE(BLOB)
 
+#include "BlobData.h"
 #include "BlobPart.h"
 #include "BlobResourceHandle.h"
-#include "BlobStorageData.h"
 #include "FileMetadata.h"
 #include "FileSystem.h"
 #include "ResourceError.h"
@@ -63,7 +63,7 @@ static PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest& re
 
 static void loadResourceSynchronously(NetworkingContext*, const ResourceRequest& request, StoredCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
 {
-    BlobStorageData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(request.url());
+    BlobData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(request.url());
     BlobResourceHandle::loadResourceSynchronously(blobData, request, error, response, data);
 }
 
@@ -87,7 +87,7 @@ PassRefPtr<ResourceHandle> BlobRegistryImpl::createResourceHandle(const Resource
     return handle.release();
 }
 
-void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, const BlobDataItemList& items, long long offset, long long length)
+void BlobRegistryImpl::appendStorageItems(BlobData* blobData, const BlobDataItemList& items, long long offset, long long length)
 {
     ASSERT(length != BlobDataItem::toEndOfFile);
 
@@ -106,10 +106,10 @@ void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, cons
         long long currentLength = iter->length - offset;
         long long newLength = currentLength > length ? length : currentLength;
         if (iter->type == BlobDataItem::Data)
-            blobStorageData->m_data.appendData(iter->data, iter->offset + offset, newLength);
+            blobData->appendData(iter->data, iter->offset + offset, newLength);
         else {
             ASSERT(iter->type == BlobDataItem::File);
-            blobStorageData->m_data.appendFile(iter->path, iter->offset + offset, newLength, iter->expectedModificationTime);
+            blobData->appendFile(iter->path, iter->offset + offset, newLength, iter->expectedModificationTime);
         }
         length -= newLength;
         offset = 0;
@@ -122,15 +122,16 @@ void BlobRegistryImpl::registerFileBlobURL(const URL& url, const String& path, c
     ASSERT(isMainThread());
     registerBlobResourceHandleConstructor();
 
-    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(contentType);
+    RefPtr<BlobData> blobData = BlobData::create();
+    blobData->setContentType(contentType);
 
     // FIXME: Factor out size and modification tracking for a cleaner implementation.
     FileMetadata metadata;
     if (!getFileMetadata(path, metadata))
         return;
 
-    blobStorageData->m_data.appendFile(path, 0, metadata.length, metadata.modificationTime);
-    m_blobs.set(url.string(), blobStorageData);
+    blobData->appendFile(path, 0, metadata.length, metadata.modificationTime);
+    m_blobs.set(url.string(), blobData.release());
 }
 
 unsigned long long BlobRegistryImpl::registerBlobURL(const URL& url, Vector<BlobPart> blobParts, const String& contentType)
@@ -138,7 +139,8 @@ unsigned long long BlobRegistryImpl::registerBlobURL(const URL& url, Vector<Blob
     ASSERT(isMainThread());
     registerBlobResourceHandleConstructor();
 
-    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(contentType);
+    RefPtr<BlobData> blobData = BlobData::create();
+    blobData->setContentType(contentType);
 
     // The blob data is stored in the "canonical" way. That is, it only contains a list of Data and File items.
     // 1) The Data item is denoted by the raw data and the range.
@@ -153,7 +155,7 @@ unsigned long long BlobRegistryImpl::registerBlobURL(const URL& url, Vector<Blob
             unsigned long long partSize = part.data().size();
             RefPtr<RawData> rawData = RawData::create(part.moveData());
             size += partSize;
-            blobStorageData->m_data.appendData(rawData.release(), 0, partSize);
+            blobData->appendData(rawData.release(), 0, partSize);
             break;
         }
         case BlobPart::Blob: {
@@ -161,22 +163,21 @@ unsigned long long BlobRegistryImpl::registerBlobURL(const URL& url, Vector<Blob
                 return 0;
             unsigned long long partSize = blobSize(part.url()); // As a side effect, this calculates sizes of all files in the blob.
             size += partSize;
-            appendStorageItems(blobStorageData.get(), m_blobs.get(part.url().string())->items(), 0, partSize);
+            appendStorageItems(blobData.get(), m_blobs.get(part.url().string())->items(), 0, partSize);
             break;
         }
         }
     }
 
-    m_blobs.set(url.string(), blobStorageData);
+    m_blobs.set(url.string(), blobData.release());
     return size;
 }
 
 void BlobRegistryImpl::registerBlobURL(const URL& url, const URL& srcURL)
 {
     ASSERT(isMainThread());
-    registerBlobResourceHandleConstructor();
 
-    RefPtr<BlobStorageData> src = m_blobs.get(srcURL.string());
+    BlobData* src = getBlobDataFromURL(srcURL);
     if (!src)
         return;
 
@@ -186,8 +187,8 @@ void BlobRegistryImpl::registerBlobURL(const URL& url, const URL& srcURL)
 unsigned long long BlobRegistryImpl::registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end)
 {
     ASSERT(isMainThread());
-    BlobStorageData* originalStorageData = m_blobs.get(srcURL.string());
-    if (!originalStorageData)
+    BlobData* originalData = getBlobDataFromURL(srcURL);
+    if (!originalData)
         return 0;
 
     unsigned long long originalSize = blobSize(srcURL);
@@ -212,11 +213,12 @@ unsigned long long BlobRegistryImpl::registerBlobURLForSlice(const URL& url, con
         end = originalSize;
 
     unsigned long long newLength = end - start;
-    RefPtr<BlobStorageData> newStorageData = BlobStorageData::create(originalStorageData->contentType());
+    RefPtr<BlobData> newData = BlobData::create();
+    newData->setContentType(originalData->contentType());
 
-    appendStorageItems(newStorageData.get(), originalStorageData->items(), start, newLength);
+    appendStorageItems(newData.get(), originalData->items(), start, newLength);
 
-    m_blobs.set(url.string(), newStorageData.release());
+    m_blobs.set(url.string(), newData.release());
     return newLength;
 }
 
@@ -226,7 +228,7 @@ void BlobRegistryImpl::unregisterBlobURL(const URL& url)
     m_blobs.remove(url.string());
 }
 
-BlobStorageData* BlobRegistryImpl::getBlobDataFromURL(const URL& url) const
+BlobData* BlobRegistryImpl::getBlobDataFromURL(const URL& url) const
 {
     ASSERT(isMainThread());
     return m_blobs.get(url.string());
@@ -235,12 +237,12 @@ BlobStorageData* BlobRegistryImpl::getBlobDataFromURL(const URL& url) const
 unsigned long long BlobRegistryImpl::blobSize(const URL& url)
 {
     ASSERT(isMainThread());
-    BlobStorageData* storageData = m_blobs.get(url.string());
-    if (!storageData)
+    BlobData* data = getBlobDataFromURL(url);
+    if (!data)
         return 0;
 
     unsigned long long result = 0;
-    for (const BlobDataItem& item : storageData->items()) {
+    for (const BlobDataItem& item : data->items()) {
         if (item.length == BlobDataItem::toEndOfFile) {
             FileMetadata metadata;
             if (!getFileMetadata(item.path, metadata))
index 12f32e2..2ad8cbe 100644 (file)
@@ -31,8 +31,8 @@
 #ifndef BlobRegistryImpl_h
 #define BlobRegistryImpl_h
 
+#include "BlobData.h"
 #include "BlobRegistry.h"
-#include "BlobStorageData.h"
 #include <wtf/HashMap.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
@@ -50,12 +50,12 @@ class BlobRegistryImpl final : public BlobRegistry {
 public:
     virtual ~BlobRegistryImpl();
 
-    BlobStorageData* getBlobDataFromURL(const URL&) const;
+    BlobData* getBlobDataFromURL(const URL&) const;
 
     PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*);
 
 private:
-    void appendStorageItems(BlobStorageData*, const BlobDataItemList&, long long offset, long long length);
+    void appendStorageItems(BlobData*, const BlobDataItemList&, long long offset, long long length);
 
     virtual void registerFileBlobURL(const WebCore::URL&, const String& path, const String& contentType) override;
     virtual unsigned long long registerBlobURL(const URL&, Vector<BlobPart>, const String& contentType) override;
@@ -66,7 +66,7 @@ private:
 
     unsigned long long blobSize(const URL&);
 
-    HashMap<String, RefPtr<BlobStorageData>> m_blobs;
+    HashMap<String, RefPtr<BlobData>> m_blobs;
 };
 
 } // namespace WebCore
index 8f605bd..a73993d 100644 (file)
@@ -35,7 +35,7 @@
 #include "BlobResourceHandle.h"
 
 #include "AsyncFileStream.h"
-#include "BlobStorageData.h"
+#include "BlobData.h"
 #include "FileStream.h"
 #include "FileSystem.h"
 #include "HTTPParsers.h"
@@ -135,7 +135,7 @@ void BlobResourceSynchronousLoader::didFail(ResourceHandle*, const ResourceError
 ///////////////////////////////////////////////////////////////////////////////
 // BlobResourceHandle
 
-PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(BlobStorageData* blobData, const ResourceRequest& request, ResourceHandleClient* client)
+PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(BlobData* blobData, const ResourceRequest& request, ResourceHandleClient* client)
 {
     // FIXME: Should probably call didFail() instead of blocking the load without explanation.
     if (!equalIgnoringCase(request.httpMethod(), "GET"))
@@ -144,7 +144,7 @@ PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(BlobStorageData*
     return adoptRef(new BlobResourceHandle(blobData, request, client, true));
 }
 
-void BlobResourceHandle::loadResourceSynchronously(BlobStorageData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data)
+void BlobResourceHandle::loadResourceSynchronously(BlobData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data)
 {
     if (!equalIgnoringCase(request.httpMethod(), "GET")) {
         error = ResourceError(webKitBlobResourceDomain, methodNotAllowed, response.url(), "Request method must be GET");
@@ -156,7 +156,7 @@ void BlobResourceHandle::loadResourceSynchronously(BlobStorageData* blobData, co
     handle->start();
 }
 
-BlobResourceHandle::BlobResourceHandle(PassRefPtr<BlobStorageData> blobData, const ResourceRequest& request, ResourceHandleClient* client, bool async)
+BlobResourceHandle::BlobResourceHandle(BlobData* blobData, const ResourceRequest& request, ResourceHandleClient* client, bool async)
     : ResourceHandle(0, request, client, false, false)
     , m_blobData(blobData)
     , m_async(async)
@@ -224,6 +224,8 @@ void BlobResourceHandle::start()
 
 void BlobResourceHandle::doStart()
 {
+    ASSERT(isMainThread());
+
     // Do not continue if the request is aborted or an error occurs.
     if (m_aborted || m_errorCode)
         return;
@@ -255,6 +257,8 @@ void BlobResourceHandle::doStart()
 
 void BlobResourceHandle::getSizeForNext()
 {
+    ASSERT(isMainThread());
+
     // Do we finish validating and counting size for all items?
     if (m_sizeItemCount >= m_blobData->items().size()) {
         seek();
@@ -287,6 +291,8 @@ void BlobResourceHandle::getSizeForNext()
 
 void BlobResourceHandle::didGetSize(long long size)
 {
+    ASSERT(isMainThread());
+
     // Do not continue if the request is aborted or an error occurs.
     if (m_aborted || m_errorCode)
         return;
@@ -316,6 +322,8 @@ void BlobResourceHandle::didGetSize(long long size)
 
 void BlobResourceHandle::seek()
 {
+    ASSERT(isMainThread());
+
     // Convert from the suffix length to the range.
     if (m_rangeSuffixLength != positionNotSpecified) {
         m_rangeOffset = m_totalRemainingSize - m_rangeSuffixLength;
@@ -345,6 +353,8 @@ void BlobResourceHandle::seek()
 
 int BlobResourceHandle::readSync(char* buf, int length)
 {
+    ASSERT(isMainThread());
+
     ASSERT(!m_async);
     Ref<BlobResourceHandle> protect(*this);
 
@@ -391,6 +401,8 @@ int BlobResourceHandle::readSync(char* buf, int length)
 
 int BlobResourceHandle::readDataSync(const BlobDataItem& item, char* buf, int length)
 {
+    ASSERT(isMainThread());
+
     ASSERT(!m_async);
 
     long long remaining = item.length - m_currentItemReadSize;
@@ -411,6 +423,8 @@ int BlobResourceHandle::readDataSync(const BlobDataItem& item, char* buf, int le
 
 int BlobResourceHandle::readFileSync(const BlobDataItem& item, char* buf, int length)
 {
+    ASSERT(isMainThread());
+
     ASSERT(!m_async);
 
     if (!m_fileOpened) {
@@ -444,6 +458,7 @@ int BlobResourceHandle::readFileSync(const BlobDataItem& item, char* buf, int le
 
 void BlobResourceHandle::readAsync()
 {
+    ASSERT(isMainThread());
     ASSERT(m_async);
 
     // Do not continue if the request is aborted or an error occurs.
@@ -467,6 +482,7 @@ void BlobResourceHandle::readAsync()
 
 void BlobResourceHandle::readDataAsync(const BlobDataItem& item)
 {
+    ASSERT(isMainThread());
     ASSERT(m_async);
     Ref<BlobResourceHandle> protect(*this);
 
@@ -479,6 +495,7 @@ void BlobResourceHandle::readDataAsync(const BlobDataItem& item)
 
 void BlobResourceHandle::readFileAsync(const BlobDataItem& item)
 {
+    ASSERT(isMainThread());
     ASSERT(m_async);
 
     if (m_fileOpened) {
@@ -577,6 +594,8 @@ void BlobResourceHandle::notifyResponse()
 
 void BlobResourceHandle::notifyResponseOnSuccess()
 {
+    ASSERT(isMainThread());
+
     bool isRangeRequest = m_rangeOffset != positionNotSpecified;
     ResourceResponse response(firstRequest().url(), m_blobData->contentType(), m_totalRemainingSize, String(), String());
     response.setExpectedContentLength(m_totalRemainingSize);
index 0ec849b..f2f48d7 100644 (file)
@@ -42,7 +42,7 @@
 namespace WebCore {
 
 class AsyncFileStream;
-class BlobStorageData;
+class BlobData;
 class FileStream;
 class ResourceHandleClient;
 class ResourceRequest;
@@ -50,9 +50,9 @@ struct BlobDataItem;
 
 class BlobResourceHandle : public FileStreamClient, public ResourceHandle  {
 public:
-    static PassRefPtr<BlobResourceHandle> createAsync(BlobStorageData*, const ResourceRequest&, ResourceHandleClient*);
+    static PassRefPtr<BlobResourceHandle> createAsync(BlobData*, const ResourceRequest&, ResourceHandleClient*);
 
-    static void loadResourceSynchronously(BlobStorageData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data);
+    static void loadResourceSynchronously(BlobData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data);
 
     // FileStreamClient methods.
     virtual void didGetSize(long long) override;
@@ -70,7 +70,7 @@ public:
 private:
     friend void delayedStartBlobResourceHandle(void*);
 
-    BlobResourceHandle(PassRefPtr<BlobStorageData>, const ResourceRequest&, ResourceHandleClient*, bool async);
+    BlobResourceHandle(BlobData*, const ResourceRequest&, ResourceHandleClient*, bool async);
     virtual ~BlobResourceHandle();
 
     void doStart();
@@ -93,7 +93,7 @@ private:
     void notifyFail(int errorCode);
     void notifyFinish();
 
-    RefPtr<BlobStorageData> m_blobData;
+    RefPtr<BlobData> m_blobData;
     bool m_async;
     RefPtr<AsyncFileStream> m_asyncStream; // For asynchronous loading.
     RefPtr<FileStream> m_stream; // For synchronous loading.
diff --git a/Source/WebCore/platform/network/BlobStorageData.h b/Source/WebCore/platform/network/BlobStorageData.h
deleted file mode 100644 (file)
index ff3d4f7..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BlobStorageData_h
-#define BlobStorageData_h
-
-#include "BlobData.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class BlobStorageData : public RefCounted<BlobStorageData> {
-public:
-    static PassRefPtr<BlobStorageData> create(const String& contentType)
-    {
-        return adoptRef(new BlobStorageData(contentType));
-    }
-
-    const String& contentType() const { return m_data.contentType(); }
-    const BlobDataItemList& items() const { return m_data.items(); }
-
-private:
-    friend class BlobRegistryImpl;
-
-    BlobStorageData(const String& contentType)
-    {
-        m_data.setContentType(contentType);
-    }
-
-    BlobData m_data;
-};
-
-} // namespace WebCore
-
-#endif // BlobStorageData_h
index 538237e..a7d45a0 100644 (file)
@@ -24,7 +24,6 @@
 #include "FormData.h"
 
 #include "BlobRegistryImpl.h"
-#include "BlobStorageData.h"
 #include "BlobURL.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
@@ -302,7 +301,7 @@ static void appendBlobResolved(FormData* formData, const URL& url)
         LOG_ERROR("Tried to resolve a blob without a usable registry");
         return;
     }
-    BlobStorageData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(URL(ParsedURLString, url));
+    BlobData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(URL(ParsedURLString, url));
     if (!blobData) {
         LOG_ERROR("Could not get blob data from a registry");
         return;
index 7ef0963..683afef 100644 (file)
@@ -66,7 +66,6 @@
 #if ENABLE(BLOB)
 #include "BlobData.h"
 #include "BlobRegistryImpl.h"
-#include "BlobStorageData.h"
 #endif
 
 #if PLATFORM(GTK)
@@ -798,7 +797,7 @@ static void addEncodedBlobItemToSoupMessageBody(SoupMessage* message, const Blob
 
 static void addEncodedBlobToSoupMessageBody(SoupMessage* message, const FormDataElement& element, unsigned long& totalBodySize)
 {
-    RefPtr<BlobStorageData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(URL(ParsedURLString, element.m_url));
+    RefPtr<BlobData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(URL(ParsedURLString, element.m_url));
     if (!blobData)
         return;