Small BlobResourceHandle cleanup
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 22:05:57 +0000 (22:05 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 22:05:57 +0000 (22:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111352

Reviewed by Sam Weinig.

1. Don't use PassRefPtr<BlobStorageData> when ownership is not being passed.
2. Added OVERRIDE to some functions.
3. Added const to ResourceHandle::firstRequest().

* platform/network/BlobRegistryImpl.cpp:
(WebCore::loadResourceSynchronously):
(WebCore::BlobRegistryImpl::createResourceHandle):
(WebCore::BlobRegistryImpl::getBlobDataFromURL):
* platform/network/BlobRegistryImpl.h:
(BlobRegistryImpl):
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::createAsync):
(WebCore::BlobResourceHandle::loadResourceSynchronously):
* platform/network/BlobResourceHandle.h:
(BlobResourceHandle):
* platform/network/FormData.cpp:
(WebCore::appendBlobResolved):
* platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::firstRequest):
* platform/network/ResourceHandle.h:
(ResourceHandle):

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

Source/WebCore/ChangeLog
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/FormData.cpp
Source/WebCore/platform/network/ResourceHandle.cpp
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/platform/network/chromium/ResourceHandle.cpp

index 20dcd30..86bca39 100644 (file)
@@ -1,3 +1,32 @@
+2013-03-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Small BlobResourceHandle cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=111352
+
+        Reviewed by Sam Weinig.
+
+        1. Don't use PassRefPtr<BlobStorageData> when ownership is not being passed.
+        2. Added OVERRIDE to some functions.
+        3. Added const to ResourceHandle::firstRequest().
+
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::loadResourceSynchronously):
+        (WebCore::BlobRegistryImpl::createResourceHandle):
+        (WebCore::BlobRegistryImpl::getBlobDataFromURL):
+        * platform/network/BlobRegistryImpl.h:
+        (BlobRegistryImpl):
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::createAsync):
+        (WebCore::BlobResourceHandle::loadResourceSynchronously):
+        * platform/network/BlobResourceHandle.h:
+        (BlobResourceHandle):
+        * platform/network/FormData.cpp:
+        (WebCore::appendBlobResolved):
+        * platform/network/ResourceHandle.cpp:
+        (WebCore::ResourceHandle::firstRequest):
+        * platform/network/ResourceHandle.h:
+        (ResourceHandle):
+
 2013-03-04  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Introduce WebInspector.EventTarget interface for interfaces that dispatch events.
index 67f9b04..bc12849 100644 (file)
@@ -57,7 +57,7 @@ static PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest& re
 
 static void loadResourceSynchronously(NetworkingContext*, const ResourceRequest& request, StoredCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
 {
-    RefPtr<BlobStorageData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(request.url());
+    BlobStorageData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(request.url());
     BlobResourceHandle::loadResourceSynchronously(blobData, request, error, response, data);
 }
 
@@ -80,7 +80,7 @@ static void registerBlobResourceHandleConstructor()
 
 PassRefPtr<ResourceHandle> BlobRegistryImpl::createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
 {
-    RefPtr<BlobResourceHandle> handle = BlobResourceHandle::createAsync(m_blobs.get(request.url().string()), request, client);
+    RefPtr<BlobResourceHandle> handle = BlobResourceHandle::createAsync(getBlobDataFromURL(request.url()), request, client);
     if (!handle)
         return 0;
 
@@ -191,10 +191,10 @@ void BlobRegistryImpl::unregisterBlobURL(const KURL& url)
     m_blobs.remove(url.string());
 }
 
-PassRefPtr<BlobStorageData> BlobRegistryImpl::getBlobDataFromURL(const KURL& url) const
+BlobStorageData* BlobRegistryImpl::getBlobDataFromURL(const KURL& url) const
 {
     ASSERT(isMainThread());
-    return m_blobs.get(url.string());
+    return m_blobs.get(url.string()).get();
 }
 
 } // namespace WebCore
index 255e21b..b34dc76 100644 (file)
@@ -50,7 +50,7 @@ class BlobRegistryImpl : public BlobRegistry {
 public:
     virtual ~BlobRegistryImpl();
 
-    PassRefPtr<BlobStorageData> getBlobDataFromURL(const KURL&) const;
+    BlobStorageData* getBlobDataFromURL(const KURL&) const;
 
     PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*);
 
index 22be809..c41ee55 100644 (file)
@@ -82,10 +82,10 @@ class BlobResourceSynchronousLoader : public ResourceHandleClient {
 public:
     BlobResourceSynchronousLoader(ResourceError&, ResourceResponse&, Vector<char>&);
 
-    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/);
-    virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
-    virtual void didFail(ResourceHandle*, const ResourceError&);
+    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE;
+    virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/) OVERRIDE;
+    virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) OVERRIDE;
+    virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
 
 private:
     ResourceError& m_error;
@@ -133,7 +133,7 @@ void BlobResourceSynchronousLoader::didFail(ResourceHandle*, const ResourceError
 ///////////////////////////////////////////////////////////////////////////////
 // BlobResourceHandle
 
-PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(PassRefPtr<BlobStorageData> blobData, const ResourceRequest& request, ResourceHandleClient* client)
+PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(BlobStorageData* blobData, const ResourceRequest& request, ResourceHandleClient* client)
 {
     // FIXME: Should probably call didFail() instead of blocking the load without explanation.
     if (!equalIgnoringCase(request.httpMethod(), "GET"))
@@ -142,7 +142,7 @@ PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(PassRefPtr<BlobSt
     return adoptRef(new BlobResourceHandle(blobData, request, client, true));
 }
 
-void BlobResourceHandle::loadResourceSynchronously(PassRefPtr<BlobStorageData> blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data)
+void BlobResourceHandle::loadResourceSynchronously(BlobStorageData* 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");
index 95e1fcc..922e42a 100644 (file)
@@ -50,17 +50,17 @@ struct BlobDataItem;
 
 class BlobResourceHandle : public FileStreamClient, public ResourceHandle  {
 public:
-    static PassRefPtr<BlobResourceHandle> createAsync(PassRefPtr<BlobStorageData>, const ResourceRequest&, ResourceHandleClient*);
+    static PassRefPtr<BlobResourceHandle> createAsync(BlobStorageData*, const ResourceRequest&, ResourceHandleClient*);
 
-    static void loadResourceSynchronously(PassRefPtr<BlobStorageData> blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data);
+    static void loadResourceSynchronously(BlobStorageData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data);
 
     // FileStreamClient methods.
-    virtual void didGetSize(long long);
-    virtual void didOpen(bool);
-    virtual void didRead(int);
+    virtual void didGetSize(long long) OVERRIDE;
+    virtual void didOpen(bool) OVERRIDE;
+    virtual void didRead(int) OVERRIDE;
 
     // ResourceHandle methods.
-    virtual void cancel();
+    virtual void cancel() OVERRIDE;
 
     void start();
     int readSync(char*, int);
index 065b90a..54b573e 100644 (file)
@@ -326,7 +326,7 @@ static void appendBlobResolved(FormData* formData, const KURL& url)
         LOG_ERROR("Tried to resolve a blob without a usable registry");
         return;
     }
-    RefPtr<BlobStorageData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(KURL(ParsedURLString, url));
+    BlobStorageData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(KURL(ParsedURLString, url));
     if (!blobData) {
         LOG_ERROR("Could not get blob data from a registry");
         return;
index d610f7d..c2d656a 100644 (file)
@@ -147,7 +147,7 @@ void ResourceHandle::setClient(ResourceHandleClient* client)
     d->m_client = client;
 }
 
-ResourceRequest& ResourceHandle::firstRequest()
+ResourceRequest& ResourceHandle::firstRequest() const
 {
     return d->m_firstRequest;
 }
index de60c22..d4752a7 100644 (file)
@@ -194,7 +194,7 @@ public:
 
     void didChangePriority(ResourceLoadPriority);
 
-    ResourceRequest& firstRequest();
+    ResourceRequest& firstRequest() const;
     const String& lastHTTPMethod() const;
 
     void fireFailure(Timer<ResourceHandle>*);
index b56dc63..9394a14 100644 (file)
@@ -202,7 +202,7 @@ PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context,
     return 0;
 }
 
-ResourceRequest& ResourceHandle::firstRequest()
+ResourceRequest& ResourceHandle::firstRequest() const
 {
     return d->request();
 }