Clean up Blob code
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Feb 2016 16:57:08 +0000 (16:57 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Feb 2016 16:57:08 +0000 (16:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153910

Reviewed by Alexey Proskuryakov.

Source/WebCore:

No new tests, no change in behavior.

* css/StyleSheet.h:
* fileapi/Blob.cpp:
(WebCore::Blob::Blob):
(WebCore::Blob::normalizedContentType):
(WebCore::Blob::isNormalizedContentType):
(WebCore::Blob::registry):
* fileapi/Blob.h:
* fileapi/BlobURL.cpp:
(WebCore::BlobURL::createPublicURL):
* fileapi/BlobURL.h:
(WebCore::BlobURL::BlobURL):
(WebCore::BlobURL::blobProtocol): Deleted.
* platform/PlatformStrategies.cpp:
(WebCore::setPlatformStrategies):
(WebCore::hasPlatformStrategies): Deleted.
* platform/PlatformStrategies.h:
* platform/network/BlobRegistry.cpp:
(WebCore::blobRegistry):
* platform/network/BlobRegistry.h:
* platform/network/BlobRegistryImpl.cpp:
(WebCore::BlobRegistryImpl::~BlobRegistryImpl):
(WebCore::createResourceHandle):
(WebCore::registerBlobResourceHandleConstructor):
(WebCore::BlobRegistryImpl::createResourceHandle):
(WebCore::BlobRegistryImpl::appendStorageItems):
(WebCore::BlobRegistryImpl::registerFileBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURL):
* platform/network/BlobRegistryImpl.h:
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::loadResourceSynchronously):
(WebCore::BlobResourceHandle::BlobResourceHandle):
* platform/network/ResourceHandle.h:

Source/WebKit2:

* NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
(WebKit::NetworkBlobRegistry::NetworkBlobRegistry):
(WebKit::NetworkBlobRegistry::registerFileBlobURL):
* NetworkProcess/FileAPI/NetworkBlobRegistry.h:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::registerFileBlobURL):
(WebKit::NetworkConnectionToWebProcess::registerBlobURL):
* WebProcess/FileAPI/BlobRegistryProxy.cpp:
(WebKit::BlobRegistryProxy::registerFileBlobURL):
* WebProcess/FileAPI/BlobRegistryProxy.h:

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

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/StyleSheet.h
Source/WebCore/fileapi/Blob.cpp
Source/WebCore/fileapi/Blob.h
Source/WebCore/fileapi/BlobURL.cpp
Source/WebCore/fileapi/BlobURL.h
Source/WebCore/platform/PlatformStrategies.cpp
Source/WebCore/platform/PlatformStrategies.h
Source/WebCore/platform/network/BlobRegistry.cpp
Source/WebCore/platform/network/BlobRegistry.h
Source/WebCore/platform/network/BlobRegistryImpl.cpp
Source/WebCore/platform/network/BlobRegistryImpl.h
Source/WebCore/platform/network/BlobResourceHandle.cpp
Source/WebCore/platform/network/ResourceHandle.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp
Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp
Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h

index 7c79c5e..d7fb223 100644 (file)
@@ -1,3 +1,45 @@
+2016-02-05  Alex Christensen  <achristensen@webkit.org>
+
+        Clean up Blob code
+        https://bugs.webkit.org/show_bug.cgi?id=153910
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests, no change in behavior.
+
+        * css/StyleSheet.h:
+        * fileapi/Blob.cpp:
+        (WebCore::Blob::Blob):
+        (WebCore::Blob::normalizedContentType):
+        (WebCore::Blob::isNormalizedContentType):
+        (WebCore::Blob::registry):
+        * fileapi/Blob.h:
+        * fileapi/BlobURL.cpp:
+        (WebCore::BlobURL::createPublicURL):
+        * fileapi/BlobURL.h:
+        (WebCore::BlobURL::BlobURL):
+        (WebCore::BlobURL::blobProtocol): Deleted.
+        * platform/PlatformStrategies.cpp:
+        (WebCore::setPlatformStrategies):
+        (WebCore::hasPlatformStrategies): Deleted.
+        * platform/PlatformStrategies.h:
+        * platform/network/BlobRegistry.cpp:
+        (WebCore::blobRegistry):
+        * platform/network/BlobRegistry.h:
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::BlobRegistryImpl::~BlobRegistryImpl):
+        (WebCore::createResourceHandle):
+        (WebCore::registerBlobResourceHandleConstructor):
+        (WebCore::BlobRegistryImpl::createResourceHandle):
+        (WebCore::BlobRegistryImpl::appendStorageItems):
+        (WebCore::BlobRegistryImpl::registerFileBlobURL):
+        (WebCore::BlobRegistryImpl::registerBlobURL):
+        * platform/network/BlobRegistryImpl.h:
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::loadResourceSynchronously):
+        (WebCore::BlobResourceHandle::BlobResourceHandle):
+        * platform/network/ResourceHandle.h:
+
 2016-02-05  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Scrollbars incorrectly rendered with older versions of GTK+
index ae5aa73..25b4c20 100644 (file)
@@ -22,7 +22,6 @@
 #define StyleSheet_h
 
 #include "CSSParserMode.h"
-#include "URLHash.h"
 #include <wtf/Forward.h>
 #include <wtf/ListHashSet.h>
 #include <wtf/RefCounted.h>
index 99488eb..6d07021 100644 (file)
@@ -100,7 +100,7 @@ Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, lon
     , m_size(size)
 {
     m_internalURL = BlobURL::createInternalURL();
-    ThreadableBlobRegistry::registerBlobURL(0, m_internalURL, srcURL);
+    ThreadableBlobRegistry::registerBlobURL(nullptr, m_internalURL, srcURL);
 }
 
 Blob::Blob(const URL& srcURL, long long start, long long end, const String& type)
@@ -146,6 +146,7 @@ String Blob::normalizedContentType(const String& contentType)
     return contentType.convertToASCIILowercase();
 }
 
+#if !ASSERT_DISABLED
 bool Blob::isNormalizedContentType(const String& contentType)
 {
     // FIXME: Do we really want to treat the empty string and null string as valid content types?
@@ -172,6 +173,7 @@ bool Blob::isNormalizedContentType(const CString& contentType)
     }
     return true;
 }
+#endif
 
 URLRegistry& Blob::registry() const
 {
index 5ea61e4..c891e90 100644 (file)
@@ -76,9 +76,10 @@ public:
     static bool isValidContentType(const String&);
     // The normalization procedure described in the File API spec.
     static String normalizedContentType(const String&);
-    // Intended for use in ASSERT statements.
+#if !ASSERT_DISABLED
     static bool isNormalizedContentType(const String&);
     static bool isNormalizedContentType(const CString&);
+#endif
 
     // URLRegistrable
     virtual URLRegistry& registry() const override;
index 3debf38..847ea49 100644 (file)
@@ -39,7 +39,7 @@
 
 namespace WebCore {
 
-const char BlobURL::kBlobProtocol[] = "blob";
+const char* kBlobProtocol = "blob";
 
 URL BlobURL::createPublicURL(SecurityOrigin* securityOrigin)
 {
index c7fa4fe..f837c91 100644 (file)
@@ -52,11 +52,9 @@ public:
     static URL createInternalURL();
     static String getOrigin(const URL&);
     static String getIdentifier(const URL&);
-    static const char* blobProtocol() { return kBlobProtocol; }
 
 private:
     static URL createBlobURL(const String& originString);
-    static const char kBlobProtocol[];
     BlobURL() { }
 };
 
index cf7bf82..56a5a63 100644 (file)
@@ -49,10 +49,5 @@ void setPlatformStrategies(PlatformStrategies* platformStrategies)
     ASSERT(platformStrategies == s_platformStrategies);
 }
 
-bool hasPlatformStrategies()
-{
-    return s_platformStrategies;
-}
-
 } // namespace WebCore
 
index e810e2b..a11379f 100644 (file)
@@ -96,7 +96,6 @@ private:
 
 WEBCORE_EXPORT PlatformStrategies* platformStrategies();
 WEBCORE_EXPORT void setPlatformStrategies(PlatformStrategies*);
-bool hasPlatformStrategies();
     
 } // namespace WebCore
 
index 7ee1c0f..b1fafc6 100644 (file)
 #include "config.h"
 #include "BlobRegistry.h"
 
-#include "BlobRegistryImpl.h"
-#include "LoaderStrategy.h"
 #include "PlatformStrategies.h"
 #include <wtf/MainThread.h>
 
-#if PLATFORM(IOS)
-#include "WebCoreThread.h"
-#endif
-
 namespace WebCore {
 
 BlobRegistry& blobRegistry()
index 9bafade..3ab3856 100644 (file)
@@ -48,7 +48,7 @@ class WEBCORE_EXPORT BlobRegistry {
 public:
 
     // Registers a blob URL referring to the specified file.
-    virtual void registerFileBlobURL(const URL&, PassRefPtr<BlobDataFileReference>, const String& contentType) = 0;
+    virtual void registerFileBlobURL(const URL&, RefPtr<BlobDataFileReference>&&, const String& contentType) = 0;
 
     // Registers a blob URL referring to the specified blob data.
     virtual void registerBlobURL(const URL&, Vector<BlobPart>, const String& contentType) = 0;
index f09b9ed..cc04bb9 100644 (file)
 #include <wtf/MainThread.h>
 #include <wtf/StdLibExtras.h>
 
-#if PLATFORM(IOS)
-#include "WebCoreThread.h"
-#endif
-
 namespace WebCore {
 
 BlobRegistryImpl::~BlobRegistryImpl()
 {
 }
 
-static PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
+static RefPtr<ResourceHandle> createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
 {
     return static_cast<BlobRegistryImpl&>(blobRegistry()).createResourceHandle(request, client);
 }
@@ -75,14 +71,14 @@ static void registerBlobResourceHandleConstructor()
     }
 }
 
-PassRefPtr<ResourceHandle> BlobRegistryImpl::createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
+RefPtr<ResourceHandle> BlobRegistryImpl::createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
 {
-    RefPtr<BlobResourceHandle> handle = BlobResourceHandle::createAsync(getBlobDataFromURL(request.url()), request, client);
+    auto handle = BlobResourceHandle::createAsync(getBlobDataFromURL(request.url()), request, client);
     if (!handle)
-        return 0;
+        return nullptr;
 
     handle->start();
-    return handle.release();
+    return handle;
 }
 
 void BlobRegistryImpl::appendStorageItems(BlobData* blobData, const BlobDataItemList& items, long long offset, long long length)
@@ -114,7 +110,7 @@ void BlobRegistryImpl::appendStorageItems(BlobData* blobData, const BlobDataItem
     ASSERT(!length);
 }
 
-void BlobRegistryImpl::registerFileBlobURL(const URL& url, PassRefPtr<BlobDataFileReference> file, const String& contentType)
+void BlobRegistryImpl::registerFileBlobURL(const URL& url, RefPtr<BlobDataFileReference>&& file, const String& contentType)
 {
     ASSERT(isMainThread());
     registerBlobResourceHandleConstructor();
@@ -148,10 +144,10 @@ void BlobRegistryImpl::registerBlobURL(const URL& url, Vector<BlobPart> blobPart
             break;
         }
         case BlobPart::Blob: {
-            if (!m_blobs.contains(part.url().string()))
-                return;
-            for (const BlobDataItem& item : m_blobs.get(part.url().string())->items())
-                blobData->m_items.append(item);
+            if (auto blob = m_blobs.get(part.url().string())) {
+                for (const BlobDataItem& item : blob->items())
+                    blobData->m_items.append(item);
+            }
             break;
         }
         }
index bab56ea..1798209 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "BlobData.h"
 #include "BlobRegistry.h"
+#include "URLHash.h"
 #include <wtf/HashMap.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
@@ -52,12 +53,12 @@ public:
 
     BlobData* getBlobDataFromURL(const URL&) const;
 
-    PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*);
+    RefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*);
 
 private:
     void appendStorageItems(BlobData*, const BlobDataItemList&, long long offset, long long length);
 
-    virtual void registerFileBlobURL(const WebCore::URL&, PassRefPtr<BlobDataFileReference>, const String& contentType) override;
+    virtual void registerFileBlobURL(const URL&, RefPtr<BlobDataFileReference>&&, const String& contentType) override;
     virtual void registerBlobURL(const URL&, Vector<BlobPart>, const String& contentType) override;
     virtual void registerBlobURL(const URL&, const URL& srcURL) override;
     virtual void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) override;
index 80d5465..1ebb647 100644 (file)
@@ -156,7 +156,7 @@ void BlobResourceHandle::loadResourceSynchronously(BlobData* blobData, const Res
 }
 
 BlobResourceHandle::BlobResourceHandle(BlobData* blobData, const ResourceRequest& request, ResourceHandleClient* client, bool async)
-    : ResourceHandle(0, request, client, false, false)
+    : ResourceHandle(nullptr, request, client, false, false)
     , m_blobData(blobData)
     , m_async(async)
 {
index 1ca021b..1ac32b4 100644 (file)
@@ -240,7 +240,7 @@ public:
     static CFMutableDictionaryRef createSSLPropertiesFromNSURLRequest(const ResourceRequest&);
 #endif
 
-    typedef PassRefPtr<ResourceHandle> (*BuiltinConstructor)(const ResourceRequest& request, ResourceHandleClient* client);
+    typedef RefPtr<ResourceHandle> (*BuiltinConstructor)(const ResourceRequest& request, ResourceHandleClient* client);
     static void registerBuiltinConstructor(const AtomicString& protocol, BuiltinConstructor);
 
     typedef void (*BuiltinSynchronousLoader)(NetworkingContext*, const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
index 4bb0a64..0a1e530 100644 (file)
@@ -1,3 +1,21 @@
+2016-02-05  Alex Christensen  <achristensen@webkit.org>
+
+        Clean up Blob code
+        https://bugs.webkit.org/show_bug.cgi?id=153910
+
+        Reviewed by Alexey Proskuryakov.
+
+        * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
+        (WebKit::NetworkBlobRegistry::NetworkBlobRegistry):
+        (WebKit::NetworkBlobRegistry::registerFileBlobURL):
+        * NetworkProcess/FileAPI/NetworkBlobRegistry.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::registerFileBlobURL):
+        (WebKit::NetworkConnectionToWebProcess::registerBlobURL):
+        * WebProcess/FileAPI/BlobRegistryProxy.cpp:
+        (WebKit::BlobRegistryProxy::registerFileBlobURL):
+        * WebProcess/FileAPI/BlobRegistryProxy.h:
+
 2016-02-05  Dan Bernstein  <mitz@apple.com>
 
         [Cocoa] Get rid of unused SPI declarations
index a1c154e..e99d7cf 100644 (file)
@@ -48,7 +48,7 @@ NetworkBlobRegistry::NetworkBlobRegistry()
 {
 }
 
-void NetworkBlobRegistry::registerFileBlobURL(NetworkConnectionToWebProcess* connection, const URL& url, const String& path, PassRefPtr<SandboxExtension> sandboxExtension, const String& contentType)
+void NetworkBlobRegistry::registerFileBlobURL(NetworkConnectionToWebProcess* connection, const URL& url, const String& path, RefPtr<SandboxExtension>&& sandboxExtension, const String& contentType)
 {
     blobRegistry().registerFileBlobURL(url, BlobDataFileReferenceWithSandboxExtension::create(path, sandboxExtension), contentType);
 
index a729578..4adde41 100644 (file)
@@ -46,7 +46,7 @@ public:
     NetworkBlobRegistry();
     static NetworkBlobRegistry& singleton();
 
-    void registerFileBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const String& path, PassRefPtr<SandboxExtension>, const String& contentType);
+    void registerFileBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const String& path, RefPtr<SandboxExtension>&&, const String& contentType);
     void registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType);
     void registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL);
     void registerBlobURLForSlice(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL, int64_t start, int64_t end);
index 2ec55cb..8129198 100644 (file)
@@ -242,7 +242,7 @@ void NetworkConnectionToWebProcess::registerFileBlobURL(const URL& url, const St
 {
     RefPtr<SandboxExtension> extension = SandboxExtension::create(extensionHandle);
 
-    NetworkBlobRegistry::singleton().registerFileBlobURL(this, url, path, extension.release(), contentType);
+    NetworkBlobRegistry::singleton().registerFileBlobURL(this, url, path, WTFMove(extension), contentType);
 }
 
 void NetworkConnectionToWebProcess::registerBlobURL(const URL& url, Vector<BlobPart> blobParts, const String& contentType)
index 7f44bea..f78c990 100644 (file)
@@ -36,7 +36,7 @@ using namespace WebCore;
 
 namespace WebKit {
 
-void BlobRegistryProxy::registerFileBlobURL(const WebCore::URL& url, PassRefPtr<BlobDataFileReference> file, const String& contentType)
+void BlobRegistryProxy::registerFileBlobURL(const WebCore::URL& url, RefPtr<BlobDataFileReference>&& file, const String& contentType)
 {
     SandboxExtension::Handle extensionHandle;
 
index ad1a7c5..1f77360 100644 (file)
@@ -32,7 +32,7 @@ namespace WebKit {
 
 class BlobRegistryProxy final : public WebCore::BlobRegistry {
 public:
-    virtual void registerFileBlobURL(const WebCore::URL&, PassRefPtr<WebCore::BlobDataFileReference>, const String& contentType) override;
+    virtual void registerFileBlobURL(const WebCore::URL&, RefPtr<WebCore::BlobDataFileReference>&&, const String& contentType) override;
     virtual void registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType) override;
     virtual void registerBlobURL(const WebCore::URL&, const WebCore::URL& srcURL) override;
     virtual void unregisterBlobURL(const WebCore::URL&) override;