Modernize loading code
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Jun 2016 18:52:06 +0000 (18:52 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Jun 2016 18:52:06 +0000 (18:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158332

Reviewed by Darin Adler.

Source/WebCore:

No new tests, no change in behavior.

* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResourceContent):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
* loader/FrameLoader.h:
* loader/NetscapePlugInStreamLoader.cpp:
(WebCore::NetscapePlugInStreamLoader::didReceiveData):
(WebCore::NetscapePlugInStreamLoader::didReceiveBuffer):
(WebCore::NetscapePlugInStreamLoader::didReceiveDataOrBuffer):
(WebCore::NetscapePlugInStreamLoader::didFinishLoading):
* loader/NetscapePlugInStreamLoader.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::deliverResponseAndData):
(WebCore::ResourceLoader::loadDataURL):
(WebCore::ResourceLoader::addDataOrBuffer):
(WebCore::ResourceLoader::clearResourceData):
(WebCore::ResourceLoader::didReceiveData):
(WebCore::ResourceLoader::didReceiveBuffer):
(WebCore::ResourceLoader::didReceiveDataOrBuffer):
(WebCore::ResourceLoader::didFinishLoading):
* loader/ResourceLoader.h:
(WebCore::ResourceLoader::wasCancelled):
(WebCore::ResourceLoader::options):
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didReceiveData):
(WebCore::SubresourceLoader::didReceiveBuffer):
(WebCore::SubresourceLoader::didReceiveDataOrBuffer):
* loader/SubresourceLoader.h:
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::abort):
(WebCore::ApplicationCacheGroup::createResourceHandle):
* loader/appcache/ApplicationCacheGroup.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::addData):
* loader/cache/CachedRawResourceClient.h:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::SharedBuffer):
(WebCore::SharedBuffer::createWithContentsOfFile):
(WebCore::SharedBuffer::adoptVector):
(WebCore::SharedBuffer::duplicateDataBufferIfNecessary):
(WebCore::SharedBuffer::appendToDataBuffer):
(WebCore::SharedBuffer::clearDataBuffer):
* platform/SharedBuffer.h:
(WebCore::SharedBuffer::create):
* platform/cf/SharedBufferCF.cpp:
(WebCore::SharedBuffer::SharedBuffer):
(WebCore::SharedBuffer::maybeAppendPlatformData):
(WebCore::SharedBuffer::wrapCFDataArray):
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(ResourceHandleStreamingClient::didReceiveData):
(ResourceHandleStreamingClient::didReceiveBuffer):
* platform/mac/SharedBufferMac.mm:
(WebCore::SharedBuffer::createCFData):
(WebCore::SharedBuffer::createFromReadingFile):
* platform/network/BlobRegistryImpl.cpp:
(WebCore::BlobRegistryImpl::~BlobRegistryImpl):
(WebCore::createBlobResourceHandle):
(WebCore::loadBlobResourceSynchronously):
(WebCore::registerBlobResourceHandleConstructor):
(WebCore::BlobRegistryImpl::createResourceHandle):
(WebCore::BlobRegistryImpl::appendStorageItems):
(WebCore::createResourceHandle): Deleted.
(WebCore::loadResourceSynchronously): Deleted.
* platform/network/BlobRegistryImpl.h:
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::createAsync):
(WebCore::BlobResourceHandle::loadResourceSynchronously):
Removed the overridden didReceiveData and didFinishLoading,
which did nothing and were identical to the function they overwrote.
* platform/network/BlobResourceHandle.h:
* platform/network/PingHandle.h:
* platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::ResourceHandle):
(WebCore::ResourceHandle::create):
(WebCore::ResourceHandle::scheduleFailure):
* platform/network/ResourceHandle.h:
* platform/network/ResourceHandleClient.cpp:
(WebCore::ResourceHandleClient::willCacheResponseAsync):
(WebCore::ResourceHandleClient::didReceiveBuffer):
* platform/network/ResourceHandleClient.h:
(WebCore::ResourceHandleClient::didReceiveResponse):
(WebCore::ResourceHandleClient::didReceiveData):
(WebCore::ResourceHandleClient::didFinishLoading):
(WebCore::ResourceHandleClient::didFail):
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionDataTask resource:receivedData:length:]):
This data must be copied in order to put it in a refcounted NSData because it comes
from IPC from the Network Process and is an IPC::DataReference which will be deallocated
when the message handling is done.
* platform/soup/SharedBufferSoup.cpp:
(WebCore::SharedBuffer::SharedBuffer):
* testing/MockContentFilter.cpp:
(WebCore::MockContentFilter::replacementData):
(WebCore::MockContentFilter::unblockHandler):

Source/WebKit2:

* NetworkProcess/Downloads/PendingDownload.h:
* NetworkProcess/NetworkDataTask.h:
(WebKit::NetworkDataTask::client):
* NetworkProcess/NetworkLoad.cpp:
(WebKit::NetworkLoad::didReceiveResponseNetworkSession):
(WebKit::NetworkLoad::didReceiveData):
(WebKit::NetworkLoad::didReceiveBuffer):
* NetworkProcess/NetworkLoad.h:
* NetworkProcess/NetworkLoadClient.h:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveBuffer):
(WebKit::NetworkResourceLoader::didFinishLoading):
* NetworkProcess/NetworkResourceLoader.h:
* NetworkProcess/PingLoad.h:
* NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
(WebKit::NetworkCache::SpeculativeLoad::didReceiveBuffer):
* NetworkProcess/cache/NetworkCacheSpeculativeLoad.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTask::didReceiveResponse):
(WebKit::NetworkDataTask::didReceiveData):
* Shared/WebHitTestResultData.cpp:
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResource):

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

46 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/loader/NetscapePlugInStreamLoader.cpp
Source/WebCore/loader/NetscapePlugInStreamLoader.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ResourceLoader.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/SubresourceLoader.h
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebCore/loader/appcache/ApplicationCacheGroup.h
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedRawResourceClient.h
Source/WebCore/platform/SharedBuffer.cpp
Source/WebCore/platform/SharedBuffer.h
Source/WebCore/platform/cf/SharedBufferCF.cpp
Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
Source/WebCore/platform/mac/SharedBufferMac.mm
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/PingHandle.h
Source/WebCore/platform/network/ResourceHandle.cpp
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/platform/network/ResourceHandleClient.cpp
Source/WebCore/platform/network/ResourceHandleClient.h
Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebCore/platform/soup/SharedBufferSoup.cpp
Source/WebCore/testing/MockContentFilter.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/Downloads/PendingDownload.h
Source/WebKit2/NetworkProcess/NetworkDataTask.h
Source/WebKit2/NetworkProcess/NetworkLoad.cpp
Source/WebKit2/NetworkProcess/NetworkLoad.h
Source/WebKit2/NetworkProcess/NetworkLoadClient.h
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
Source/WebKit2/NetworkProcess/PingLoad.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h
Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
Source/WebKit2/Shared/WebHitTestResultData.cpp
Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp

index 87c8fc5..e7c40a8 100644 (file)
@@ -1,3 +1,107 @@
+2016-06-06  Alex Christensen  <achristensen@webkit.org>
+
+        Modernize loading code
+        https://bugs.webkit.org/show_bug.cgi?id=158332
+
+        Reviewed by Darin Adler.
+
+        No new tests, no change in behavior.
+
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::cachedResourceContent):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::continueAfterContentPolicy):
+        * loader/FrameLoader.h:
+        * loader/NetscapePlugInStreamLoader.cpp:
+        (WebCore::NetscapePlugInStreamLoader::didReceiveData):
+        (WebCore::NetscapePlugInStreamLoader::didReceiveBuffer):
+        (WebCore::NetscapePlugInStreamLoader::didReceiveDataOrBuffer):
+        (WebCore::NetscapePlugInStreamLoader::didFinishLoading):
+        * loader/NetscapePlugInStreamLoader.h:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::deliverResponseAndData):
+        (WebCore::ResourceLoader::loadDataURL):
+        (WebCore::ResourceLoader::addDataOrBuffer):
+        (WebCore::ResourceLoader::clearResourceData):
+        (WebCore::ResourceLoader::didReceiveData):
+        (WebCore::ResourceLoader::didReceiveBuffer):
+        (WebCore::ResourceLoader::didReceiveDataOrBuffer):
+        (WebCore::ResourceLoader::didFinishLoading):
+        * loader/ResourceLoader.h:
+        (WebCore::ResourceLoader::wasCancelled):
+        (WebCore::ResourceLoader::options):
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::didReceiveData):
+        (WebCore::SubresourceLoader::didReceiveBuffer):
+        (WebCore::SubresourceLoader::didReceiveDataOrBuffer):
+        * loader/SubresourceLoader.h:
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::abort):
+        (WebCore::ApplicationCacheGroup::createResourceHandle):
+        * loader/appcache/ApplicationCacheGroup.h:
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::addData):
+        * loader/cache/CachedRawResourceClient.h:
+        * platform/SharedBuffer.cpp:
+        (WebCore::SharedBuffer::SharedBuffer):
+        (WebCore::SharedBuffer::createWithContentsOfFile):
+        (WebCore::SharedBuffer::adoptVector):
+        (WebCore::SharedBuffer::duplicateDataBufferIfNecessary):
+        (WebCore::SharedBuffer::appendToDataBuffer):
+        (WebCore::SharedBuffer::clearDataBuffer):
+        * platform/SharedBuffer.h:
+        (WebCore::SharedBuffer::create):
+        * platform/cf/SharedBufferCF.cpp:
+        (WebCore::SharedBuffer::SharedBuffer):
+        (WebCore::SharedBuffer::maybeAppendPlatformData):
+        (WebCore::SharedBuffer::wrapCFDataArray):
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (ResourceHandleStreamingClient::didReceiveData):
+        (ResourceHandleStreamingClient::didReceiveBuffer):
+        * platform/mac/SharedBufferMac.mm:
+        (WebCore::SharedBuffer::createCFData):
+        (WebCore::SharedBuffer::createFromReadingFile):
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::BlobRegistryImpl::~BlobRegistryImpl):
+        (WebCore::createBlobResourceHandle):
+        (WebCore::loadBlobResourceSynchronously):
+        (WebCore::registerBlobResourceHandleConstructor):
+        (WebCore::BlobRegistryImpl::createResourceHandle):
+        (WebCore::BlobRegistryImpl::appendStorageItems):
+        (WebCore::createResourceHandle): Deleted.
+        (WebCore::loadResourceSynchronously): Deleted.
+        * platform/network/BlobRegistryImpl.h:
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::createAsync):
+        (WebCore::BlobResourceHandle::loadResourceSynchronously):
+        Removed the overridden didReceiveData and didFinishLoading, 
+        which did nothing and were identical to the function they overwrote.
+        * platform/network/BlobResourceHandle.h:
+        * platform/network/PingHandle.h:
+        * platform/network/ResourceHandle.cpp:
+        (WebCore::ResourceHandle::ResourceHandle):
+        (WebCore::ResourceHandle::create):
+        (WebCore::ResourceHandle::scheduleFailure):
+        * platform/network/ResourceHandle.h:
+        * platform/network/ResourceHandleClient.cpp:
+        (WebCore::ResourceHandleClient::willCacheResponseAsync):
+        (WebCore::ResourceHandleClient::didReceiveBuffer):
+        * platform/network/ResourceHandleClient.h:
+        (WebCore::ResourceHandleClient::didReceiveResponse):
+        (WebCore::ResourceHandleClient::didReceiveData):
+        (WebCore::ResourceHandleClient::didFinishLoading):
+        (WebCore::ResourceHandleClient::didFail):
+        * platform/network/cocoa/WebCoreNSURLSession.mm:
+        (-[WebCoreNSURLSessionDataTask resource:receivedData:length:]):
+        This data must be copied in order to put it in a refcounted NSData because it comes
+        from IPC from the Network Process and is an IPC::DataReference which will be deallocated
+        when the message handling is done.
+        * platform/soup/SharedBufferSoup.cpp:
+        (WebCore::SharedBuffer::SharedBuffer):
+        * testing/MockContentFilter.cpp:
+        (WebCore::MockContentFilter::replacementData):
+        (WebCore::MockContentFilter::unblockHandler):
+
 2016-06-06  Sam Weinig  <sam@webkit.org>
 
         Add experimental support for spring based CSS animations
index eff6468..f78344d 100644 (file)
@@ -139,6 +139,7 @@ static RefPtr<TextResourceDecoder> createXHRTextDecoder(const String& mimeType,
 
 bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, String* result, bool* base64Encoded)
 {
+    // FIXME: result should be a String& and base64Encoded should be a bool&.
     bool hasZeroSize;
     bool prepared = prepareCachedResourceBuffer(cachedResource, &hasZeroSize);
     if (!prepared)
@@ -146,11 +147,15 @@ bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, S
 
     *base64Encoded = !hasTextContent(cachedResource);
     if (*base64Encoded) {
-        RefPtr<SharedBuffer> buffer = hasZeroSize ? SharedBuffer::create() : cachedResource->resourceBuffer();
-        if (!buffer)
-            return false;
-        *result = base64Encode(buffer->data(), buffer->size());
-        return true;
+        if (hasZeroSize) {
+            *result = { };
+            return true;
+        }
+        if (auto* buffer = cachedResource->resourceBuffer()) {
+            *result = base64Encode(buffer->data(), buffer->size());
+            return true;
+        }
+        return false;
     }
 
     if (hasZeroSize) {
index b3ed18b..62a3482 100644 (file)
@@ -805,8 +805,9 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
     }
 
     if (!isStopping() && m_substituteData.isValid() && isLoadingMainResource()) {
-        if (m_substituteData.content()->size())
-            dataReceived(0, m_substituteData.content()->data(), m_substituteData.content()->size());
+        auto content = m_substituteData.content();
+        if (content && content->size())
+            dataReceived(nullptr, content->data(), content->size());
         if (isLoadingMainResource())
             finishedLoading(0);
     }
index 9bed700..e4f2851 100644 (file)
@@ -43,7 +43,6 @@
 #include "ResourceLoadNotifier.h"
 #include "ResourceRequestBase.h"
 #include "SecurityContext.h"
-#include "SharedBuffer.h"
 #include "Timer.h"
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
@@ -76,6 +75,7 @@ class ResourceRequest;
 class ResourceResponse;
 class SecurityOrigin;
 class SerializedScriptValue;
+class SharedBuffer;
 class StringWithDirection;
 class SubframeLoader;
 class SubstituteData;
index 13b975d..3a5dc6b 100644 (file)
@@ -129,21 +129,21 @@ void NetscapePlugInStreamLoader::didReceiveResponse(const ResourceResponse& resp
 
 void NetscapePlugInStreamLoader::didReceiveData(const char* data, unsigned length, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
-    didReceiveDataOrBuffer(data, length, 0, encodedDataLength, dataPayloadType);
+    didReceiveDataOrBuffer(data, length, nullptr, encodedDataLength, dataPayloadType);
 }
 
-void NetscapePlugInStreamLoader::didReceiveBuffer(PassRefPtr<SharedBuffer> buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
+void NetscapePlugInStreamLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
-    didReceiveDataOrBuffer(0, 0, buffer, encodedDataLength, dataPayloadType);
+    didReceiveDataOrBuffer(nullptr, 0, WTFMove(buffer), encodedDataLength, dataPayloadType);
 }
 
-void NetscapePlugInStreamLoader::didReceiveDataOrBuffer(const char* data, int length, PassRefPtr<SharedBuffer> buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
+void NetscapePlugInStreamLoader::didReceiveDataOrBuffer(const char* data, int length, RefPtr<SharedBuffer>&& buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
     Ref<NetscapePlugInStreamLoader> protectedThis(*this);
     
     m_client->didReceiveData(this, buffer ? buffer->data() : data, buffer ? buffer->size() : length);
 
-    ResourceLoader::didReceiveDataOrBuffer(data, length, buffer, encodedDataLength, dataPayloadType);
+    ResourceLoader::didReceiveDataOrBuffer(data, length, WTFMove(buffer), encodedDataLength, dataPayloadType);
 }
 
 void NetscapePlugInStreamLoader::didFinishLoading(double finishTime)
index 191f8c6..1fe772b 100644 (file)
@@ -26,8 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef NetscapePlugInStreamLoader_h
-#define NetscapePlugInStreamLoader_h
+#pragma once
 
 #include "ResourceLoader.h"
 #include <wtf/Forward.h>
@@ -62,7 +61,7 @@ private:
     void willSendRequest(ResourceRequest&&, const ResourceResponse& redirectResponse, std::function<void(ResourceRequest&&)>&& callback) override;
     void didReceiveResponse(const ResourceResponse&) override;
     void didReceiveData(const char*, unsigned, long long encodedDataLength, DataPayloadType) override;
-    void didReceiveBuffer(PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType) override;
+    void didReceiveBuffer(Ref<SharedBuffer>&&, long long encodedDataLength, DataPayloadType) override;
     void didFinishLoading(double finishTime) override;
     void didFail(const ResourceError&) override;
 
@@ -73,7 +72,7 @@ private:
     void willCancel(const ResourceError&) override;
     void didCancel(const ResourceError&) override;
 
-    void didReceiveDataOrBuffer(const char*, int, PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
+    void didReceiveDataOrBuffer(const char*, int, RefPtr<SharedBuffer>&&, long long encodedDataLength, DataPayloadType);
 
     void notifyDone();
 
@@ -82,5 +81,3 @@ private:
 };
 
 }
-
-#endif // NetscapePlugInStreamLoader_h
index ee01a10..8a281ec 100644 (file)
@@ -170,7 +170,7 @@ void ResourceLoader::deliverResponseAndData(const ResourceResponse& response, Re
 
     if (buffer) {
         unsigned size = buffer->size();
-        didReceiveBuffer(buffer.release(), size, DataPayloadWholeResource);
+        didReceiveBuffer(buffer.releaseNonNull(), size, DataPayloadWholeResource);
         if (reachedTerminalState())
             return;
     }
@@ -254,13 +254,13 @@ void ResourceLoader::loadDataURL()
         if (protectedThis->wasCancelled())
             return;
         auto& result = decodeResult.value();
-        auto dataSize = result.data->size();
+        auto dataSize = result.data ? result.data->size() : 0;
 
         ResourceResponse dataResponse { url, result.mimeType, dataSize, result.charset };
         protectedThis->didReceiveResponse(dataResponse);
 
         if (!protectedThis->reachedTerminalState() && dataSize)
-            protectedThis->didReceiveBuffer(result.data.get(), dataSize, DataPayloadWholeResource);
+            protectedThis->didReceiveBuffer(result.data.releaseNonNull(), dataSize, DataPayloadWholeResource);
 
         if (!protectedThis->reachedTerminalState())
             protectedThis->didFinishLoading(currentTime());
@@ -289,19 +289,18 @@ void ResourceLoader::addDataOrBuffer(const char* data, unsigned length, SharedBu
     if (m_options.dataBufferingPolicy() == DoNotBufferData)
         return;
 
-    if (dataPayloadType == DataPayloadWholeResource) {
-        m_resourceData = buffer ? buffer : SharedBuffer::create(data, length);
-        return;
-    }
-        
-    if (!m_resourceData)
-        m_resourceData = buffer ? buffer : SharedBuffer::create(data, length);
-    else {
+    if (!m_resourceData || dataPayloadType == DataPayloadWholeResource) {
         if (buffer)
-            m_resourceData->append(buffer);
+            m_resourceData = buffer;
         else
-            m_resourceData->append(data, length);
+            m_resourceData = SharedBuffer::create(data, length);
+        return;
     }
+    
+    if (buffer)
+        m_resourceData->append(*buffer);
+    else
+        m_resourceData->append(data, length);
 }
 
 void ResourceLoader::clearResourceData()
@@ -453,23 +452,22 @@ void ResourceLoader::didReceiveData(const char* data, unsigned length, long long
     // ASSERT(con == connection);
     // ASSERT(!m_reachedTerminalState);
 
-    didReceiveDataOrBuffer(data, length, 0, encodedDataLength, dataPayloadType);
+    didReceiveDataOrBuffer(data, length, nullptr, encodedDataLength, dataPayloadType);
 }
 
-void ResourceLoader::didReceiveBuffer(PassRefPtr<SharedBuffer> buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
+void ResourceLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
-    didReceiveDataOrBuffer(0, 0, buffer, encodedDataLength, dataPayloadType);
+    didReceiveDataOrBuffer(nullptr, 0, WTFMove(buffer), encodedDataLength, dataPayloadType);
 }
 
-void ResourceLoader::didReceiveDataOrBuffer(const char* data, unsigned length, PassRefPtr<SharedBuffer> prpBuffer, long long encodedDataLength, DataPayloadType dataPayloadType)
+void ResourceLoader::didReceiveDataOrBuffer(const char* data, unsigned length, RefPtr<SharedBuffer>&& buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
     // This method should only get data+length *OR* a SharedBuffer.
-    ASSERT(!prpBuffer || (!data && !length));
+    ASSERT(!buffer || (!data && !length));
 
     // Protect this in this delegate method since the additional processing can do
     // anything including possibly derefing this; one example of this is Radar 3266216.
     Ref<ResourceLoader> protectedThis(*this);
-    RefPtr<SharedBuffer> buffer = prpBuffer;
 
     addDataOrBuffer(data, length, buffer.get(), dataPayloadType);
     
@@ -632,9 +630,9 @@ void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, unsigned
     didReceiveData(data, length, encodedDataLength, DataPayloadBytes);
 }
 
-void ResourceLoader::didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int encodedDataLength)
+void ResourceLoader::didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&& buffer, int encodedDataLength)
 {
-    didReceiveBuffer(buffer, encodedDataLength, DataPayloadBytes);
+    didReceiveBuffer(WTFMove(buffer), encodedDataLength, DataPayloadBytes);
 }
 
 void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime)
index 74aa1c6..d207934 100644 (file)
@@ -104,7 +104,7 @@ public:
     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
     virtual void didReceiveResponse(const ResourceResponse&);
     virtual void didReceiveData(const char*, unsigned, long long encodedDataLength, DataPayloadType);
-    virtual void didReceiveBuffer(PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
+    virtual void didReceiveBuffer(Ref<SharedBuffer>&&, long long encodedDataLength, DataPayloadType);
     virtual void didFinishLoading(double finishTime);
     virtual void didFail(const ResourceError&);
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
@@ -156,7 +156,7 @@ protected:
 
     bool wasCancelled() const { return m_cancellationStatus >= Cancelled; }
 
-    void didReceiveDataOrBuffer(const char*, unsigned, PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
+    void didReceiveDataOrBuffer(const char*, unsigned, RefPtr<SharedBuffer>&&, long long encodedDataLength, DataPayloadType);
 
     const ResourceLoaderOptions& options() { return m_options; }
 
@@ -187,7 +187,7 @@ private:
     void didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
     void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override;
     void didReceiveData(ResourceHandle*, const char*, unsigned, int encodedDataLength) override;
-    void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedDataLength) override;
+    void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int encodedDataLength) override;
     void didFinishLoading(ResourceHandle*, double finishTime) override;
     void didFail(ResourceHandle*, const ResourceError&) override;
     void wasBlocked(ResourceHandle*) override;
index 57c16f8..386ec07 100644 (file)
@@ -306,15 +306,15 @@ void SubresourceLoader::didReceiveResponse(const ResourceResponse& response)
 
 void SubresourceLoader::didReceiveData(const char* data, unsigned length, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
-    didReceiveDataOrBuffer(data, length, 0, encodedDataLength, dataPayloadType);
+    didReceiveDataOrBuffer(data, length, nullptr, encodedDataLength, dataPayloadType);
 }
 
-void SubresourceLoader::didReceiveBuffer(PassRefPtr<SharedBuffer> buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
+void SubresourceLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
-    didReceiveDataOrBuffer(0, 0, buffer, encodedDataLength, dataPayloadType);
+    didReceiveDataOrBuffer(nullptr, 0, WTFMove(buffer), encodedDataLength, dataPayloadType);
 }
 
-void SubresourceLoader::didReceiveDataOrBuffer(const char* data, int length, PassRefPtr<SharedBuffer> prpBuffer, long long encodedDataLength, DataPayloadType dataPayloadType)
+void SubresourceLoader::didReceiveDataOrBuffer(const char* data, int length, RefPtr<SharedBuffer>&& prpBuffer, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
     if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors())
         return;
@@ -326,7 +326,7 @@ void SubresourceLoader::didReceiveDataOrBuffer(const char* data, int length, Pas
     Ref<SubresourceLoader> protectedThis(*this);
     RefPtr<SharedBuffer> buffer = prpBuffer;
     
-    ResourceLoader::didReceiveDataOrBuffer(data, length, buffer, encodedDataLength, dataPayloadType);
+    ResourceLoader::didReceiveDataOrBuffer(data, length, WTFMove(buffer), encodedDataLength, dataPayloadType);
 
     if (!m_loadingMultipartContent) {
         if (auto* resourceData = this->resourceData())
index bbf4dfc..5ec7311 100644 (file)
@@ -26,8 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef SubresourceLoader_h
-#define SubresourceLoader_h
+#pragma once
 
 #include "FrameLoaderTypes.h"
 #include "ResourceLoader.h"
@@ -68,7 +67,7 @@ private:
     void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
     void didReceiveResponse(const ResourceResponse&) override;
     void didReceiveData(const char*, unsigned, long long encodedDataLength, DataPayloadType) override;
-    void didReceiveBuffer(PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType) override;
+    void didReceiveBuffer(Ref<SharedBuffer>&&, long long encodedDataLength, DataPayloadType) override;
     void didFinishLoading(double finishTime) override;
     void didFail(const ResourceError&) override;
     void willCancel(const ResourceError&) override;
@@ -94,7 +93,7 @@ private:
     bool checkForHTTPStatusCodeError();
     bool checkCrossOriginAccessControl(const ResourceRequest&, const ResourceResponse&, ResourceRequest& newRequest);
 
-    void didReceiveDataOrBuffer(const char*, int, PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
+    void didReceiveDataOrBuffer(const char*, int, RefPtr<SharedBuffer>&&, long long encodedDataLength, DataPayloadType);
 
     void notifyDone();
 
@@ -130,5 +129,3 @@ private:
 };
 
 }
-
-#endif // SubresourceLoader_h
index cd38a01..156c3b5 100644 (file)
@@ -462,7 +462,7 @@ void ApplicationCacheGroup::abort(Frame* frame)
     cacheUpdateFailed();
 }
 
-PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const URL& url, ApplicationCacheResource* newestCachedResource)
+RefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const URL& url, ApplicationCacheResource* newestCachedResource)
 {
     ResourceRequest request(url);
     m_frame->loader().applyUserAgent(request);
index 470e0bb..9b917cb 100644 (file)
@@ -102,7 +102,7 @@ private:
 
     void scheduleReachedMaxAppCacheSizeCallback();
 
-    PassRefPtr<ResourceHandle> createResourceHandle(const URL&, ApplicationCacheResource* newestCachedResource);
+    RefPtr<ResourceHandle> createResourceHandle(const URL&, ApplicationCacheResource* newestCachedResource);
 
     // For normal resource loading, WebKit client is asked about each resource individually. Since application cache does not belong to any particular document,
     // the existing client callback cannot be used, so assume that any client that enables application cache also wants it to use credential storage.
index 08c5f69..4f54525 100644 (file)
@@ -401,7 +401,7 @@ void CachedImage::addDataBuffer(SharedBuffer& data)
 void CachedImage::addData(const char* data, unsigned length)
 {
     ASSERT(dataBufferingPolicy() == DoNotBufferData);
-    addIncrementalDataBuffer(*SharedBuffer::create(data, length));
+    addIncrementalDataBuffer(SharedBuffer::create(data, length));
     CachedResource::addData(data, length);
 }
 
index 9a16bc6..1e0c9fd 100644 (file)
@@ -20,8 +20,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef CachedRawResourceClient_h
-#define CachedRawResourceClient_h
+#pragma once
 
 #include "CachedResourceClient.h"
 
@@ -48,5 +47,3 @@ public:
 };
 
 }
-
-#endif // CachedRawResourceClient_h
index 0f340de..b16a154 100644 (file)
@@ -62,30 +62,30 @@ static inline void freeSegment(char* p)
 #endif
 
 SharedBuffer::SharedBuffer()
-    : m_buffer(adoptRef(new DataBuffer))
+    : m_buffer(adoptRef(*new DataBuffer))
 {
 }
 
 SharedBuffer::SharedBuffer(unsigned size)
     : m_size(size)
-    , m_buffer(adoptRef(new DataBuffer))
+    , m_buffer(adoptRef(*new DataBuffer))
 {
 }
 
 SharedBuffer::SharedBuffer(const char* data, unsigned size)
-    : m_buffer(adoptRef(new DataBuffer))
+    : m_buffer(adoptRef(*new DataBuffer))
 {
     append(data, size);
 }
 
 SharedBuffer::SharedBuffer(const unsigned char* data, unsigned size)
-    : m_buffer(adoptRef(new DataBuffer))
+    : m_buffer(adoptRef(*new DataBuffer))
 {
     append(reinterpret_cast<const char*>(data), size);
 }
 
 SharedBuffer::SharedBuffer(MappedFileData&& fileData)
-    : m_buffer(adoptRef(new DataBuffer))
+    : m_buffer(adoptRef(*new DataBuffer))
     , m_fileData(WTFMove(fileData))
 {
 }
@@ -106,12 +106,12 @@ RefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePa
     return adoptRef(new SharedBuffer(WTFMove(mappedFileData)));
 }
 
-PassRefPtr<SharedBuffer> SharedBuffer::adoptVector(Vector<char>& vector)
+Ref<SharedBuffer> SharedBuffer::adoptVector(Vector<char>& vector)
 {
-    RefPtr<SharedBuffer> buffer = create();
+    auto buffer = create();
     buffer->m_buffer->data.swap(vector);
     buffer->m_size = buffer->m_buffer->data.size();
-    return buffer.release();
+    return buffer;
 }
 
 unsigned SharedBuffer::size() const
@@ -161,7 +161,7 @@ RefPtr<ArrayBuffer> SharedBuffer::createArrayBuffer() const
     return arrayBuffer;
 }
 
-void SharedBuffer::append(SharedBuffer* data)
+void SharedBuffer::append(SharedBuffer& data)
 {
     if (maybeAppendPlatformData(data))
         return;
@@ -172,7 +172,7 @@ void SharedBuffer::append(SharedBuffer* data)
 
     const char* segment;
     size_t position = 0;
-    while (size_t length = data->getSomeData(segment, position)) {
+    while (size_t length = data.getSomeData(segment, position)) {
         append(segment, length);
         position += length;
     }
@@ -288,10 +288,10 @@ void SharedBuffer::duplicateDataBufferIfNecessary() const
         return;
 
     size_t newCapacity = std::max(static_cast<size_t>(m_size), currentCapacity * 2);
-    RefPtr<DataBuffer> newBuffer = adoptRef(new DataBuffer);
+    auto newBuffer = adoptRef(*new DataBuffer);
     newBuffer->data.reserveInitialCapacity(newCapacity);
     newBuffer->data = m_buffer->data;
-    m_buffer = newBuffer.release();
+    m_buffer = WTFMove(newBuffer);
 }
 
 void SharedBuffer::appendToDataBuffer(const char *data, unsigned length) const
@@ -303,7 +303,7 @@ void SharedBuffer::appendToDataBuffer(const char *data, unsigned length) const
 void SharedBuffer::clearDataBuffer()
 {
     if (!m_buffer->hasOneRef())
-        m_buffer = adoptRef(new DataBuffer);
+        m_buffer = adoptRef(*new DataBuffer);
     else
         m_buffer->data.clear();
 }
@@ -409,7 +409,7 @@ inline const char* SharedBuffer::platformData() const
 {
     ASSERT_NOT_REACHED();
 
-    return 0;
+    return nullptr;
 }
 
 inline unsigned SharedBuffer::platformDataSize() const
@@ -419,7 +419,7 @@ inline unsigned SharedBuffer::platformDataSize() const
     return 0;
 }
 
-inline bool SharedBuffer::maybeAppendPlatformData(SharedBuffer*)
+inline bool SharedBuffer::maybeAppendPlatformData(SharedBuffer&)
 {
     return false;
 }
index a41f5a1..489989a 100644 (file)
@@ -24,8 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef SharedBuffer_h
-#define SharedBuffer_h
+#pragma once
 
 #include "FileSystem.h"
 #include <runtime/ArrayBuffer.h>
@@ -52,14 +51,14 @@ namespace WebCore {
     
 class SharedBuffer : public RefCounted<SharedBuffer> {
 public:
-    static PassRefPtr<SharedBuffer> create() { return adoptRef(new SharedBuffer); }
-    static PassRefPtr<SharedBuffer> create(unsigned size) { return adoptRef(new SharedBuffer(size)); }
-    static PassRefPtr<SharedBuffer> create(const char* c, unsigned i) { return adoptRef(new SharedBuffer(c, i)); }
+    static Ref<SharedBuffer> create() { return adoptRef(*new SharedBuffer); }
+    static Ref<SharedBuffer> create(unsigned size) { return adoptRef(*new SharedBuffer(size)); }
+    static Ref<SharedBuffer> create(const char* c, unsigned i) { return adoptRef(*new SharedBuffer(c, i)); }
     static Ref<SharedBuffer> create(const unsigned char* data, unsigned size) { return adoptRef(*new SharedBuffer(data, size)); }
 
     WEBCORE_EXPORT static RefPtr<SharedBuffer> createWithContentsOfFile(const String& filePath);
 
-    WEBCORE_EXPORT static PassRefPtr<SharedBuffer> adoptVector(Vector<char>& vector);
+    WEBCORE_EXPORT static Ref<SharedBuffer> adoptVector(Vector<char>&);
     
     WEBCORE_EXPORT ~SharedBuffer();
     
@@ -90,7 +89,7 @@ public:
 
     bool isEmpty() const { return !size(); }
 
-    WEBCORE_EXPORT void append(SharedBuffer*);
+    WEBCORE_EXPORT void append(SharedBuffer&);
     WEBCORE_EXPORT void append(const char*, unsigned);
     WEBCORE_EXPORT void append(const Vector<char>&);
 
@@ -99,7 +98,7 @@ public:
     unsigned platformDataSize() const;
 
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
-    static PassRefPtr<SharedBuffer> wrapCFDataArray(CFArrayRef);
+    static Ref<SharedBuffer> wrapCFDataArray(CFArrayRef);
     void append(CFDataRef);
 #endif
 
@@ -144,7 +143,7 @@ private:
 
     void clearPlatformData();
     void maybeTransferPlatformData();
-    bool maybeAppendPlatformData(SharedBuffer*);
+    bool maybeAppendPlatformData(SharedBuffer&);
 
     void maybeTransferMappedFileData();
 
@@ -155,14 +154,14 @@ private:
     void clearDataBuffer();
 
     unsigned m_size { 0 };
-    mutable RefPtr<DataBuffer> m_buffer;
+    mutable Ref<DataBuffer> m_buffer;
 
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
     explicit SharedBuffer(CFArrayRef);
     mutable Vector<RetainPtr<CFDataRef>> m_dataArray;
     unsigned copySomeDataFromDataArray(const char*& someData, unsigned position) const;
     const char *singleDataArrayBuffer() const;
-    bool maybeAppendDataArray(SharedBuffer*);
+    bool maybeAppendDataArray(SharedBuffer&);
 #else
     mutable Vector<char*> m_segments;
 #endif
@@ -184,5 +183,3 @@ private:
 RefPtr<SharedBuffer> utf8Buffer(const String&);
 
 } // namespace WebCore
-
-#endif // SharedBuffer_h
index e6c5cc3..2c89fc5 100644 (file)
@@ -34,7 +34,7 @@
 namespace WebCore {
 
 SharedBuffer::SharedBuffer(CFDataRef cfData)
-    : m_buffer(adoptRef(new DataBuffer))
+    : m_buffer(adoptRef(*new DataBuffer))
     , m_cfData(cfData)
     , m_vnodeToken(VNodeTracker::singleton().token())
 {
@@ -110,22 +110,22 @@ bool SharedBuffer::tryReplaceContentsWithPlatformBuffer(SharedBuffer& newContent
     return true;
 }
 
-bool SharedBuffer::maybeAppendPlatformData(SharedBuffer* newContents)
+bool SharedBuffer::maybeAppendPlatformData(SharedBuffer& newContents)
 {
-    if (size() || !newContents->m_cfData)
+    if (size() || !newContents.m_cfData)
         return false;
-    m_cfData = newContents->m_cfData;
+    m_cfData = newContents.m_cfData;
     return true;
 }
 
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
-PassRefPtr<SharedBuffer> SharedBuffer::wrapCFDataArray(CFArrayRef cfDataArray)
+Ref<SharedBuffer> SharedBuffer::wrapCFDataArray(CFArrayRef cfDataArray)
 {
-    return adoptRef(new SharedBuffer(cfDataArray));
+    return adoptRef(*new SharedBuffer(cfDataArray));
 }
 
 SharedBuffer::SharedBuffer(CFArrayRef cfDataArray)
-    : m_buffer(adoptRef(new DataBuffer))
+    : m_buffer(adoptRef(*new DataBuffer))
     , m_cfData(nullptr)
 {
     CFIndex dataArrayCount = CFArrayGetCount(cfDataArray);
@@ -185,16 +185,16 @@ const char *SharedBuffer::singleDataArrayBuffer() const
     return reinterpret_cast<const char*>(CFDataGetBytePtr(m_dataArray.at(0).get()));
 }
 
-bool SharedBuffer::maybeAppendDataArray(SharedBuffer* data)
+bool SharedBuffer::maybeAppendDataArray(SharedBuffer& data)
 {
-    if (m_buffer->data.size() || m_cfData || !data->m_dataArray.size())
+    if (m_buffer->data.size() || m_cfData || !data.m_dataArray.size())
         return false;
 #if !ASSERT_DISABLED
     unsigned originalSize = size();
 #endif
-    for (auto& cfData : data->m_dataArray)
+    for (auto& cfData : data.m_dataArray)
         append(cfData.get());
-    ASSERT(size() == originalSize + data->size());
+    ASSERT(size() == originalSize + data.size());
     return true;
 }
 #endif
index d0e1c72..7526b01 100644 (file)
@@ -98,7 +98,7 @@ class ResourceHandleStreamingClient : public ResourceHandleClient, public Stream
         ResourceRequest willSendRequest(ResourceHandle*, ResourceRequest&&, ResourceResponse&&) override;
         void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override;
         void didReceiveData(ResourceHandle*, const char*, unsigned, int) override;
-        void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedLength) override;
+        void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int encodedLength) override;
         void didFinishLoading(ResourceHandle*, double /*finishTime*/) override;
         void didFail(ResourceHandle*, const ResourceError&) override;
         void wasBlocked(ResourceHandle*) override;
@@ -1100,7 +1100,7 @@ void ResourceHandleStreamingClient::didReceiveData(ResourceHandle*, const char*
     ASSERT_NOT_REACHED();
 }
 
-void ResourceHandleStreamingClient::didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int /* encodedLength */)
+void ResourceHandleStreamingClient::didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&& buffer, int /* encodedLength */)
 {
     // This pattern is suggested by SharedBuffer.h.
     const char* segment;
index 6a7f45b..0cc81ba 100644 (file)
@@ -112,7 +112,7 @@ RetainPtr<CFDataRef> SharedBuffer::createCFData()
         return cfData;
 
     data(); // Force data into m_buffer from segments or data array.
-    return adoptCF((CFDataRef)adoptNS([[WebCoreSharedBufferData alloc] initWithSharedBufferDataBuffer:m_buffer.get()]).leakRef());
+    return adoptCF((CFDataRef)adoptNS([[WebCoreSharedBufferData alloc] initWithSharedBufferDataBuffer:m_buffer.ptr()]).leakRef());
 }
 
 RefPtr<SharedBuffer> SharedBuffer::createFromReadingFile(const String& filePath)
index 5d4aac8..27f8032 100644 (file)
@@ -53,12 +53,12 @@ BlobRegistryImpl::~BlobRegistryImpl()
 {
 }
 
-static RefPtr<ResourceHandle> createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
+static Ref<ResourceHandle> createBlobResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
 {
     return static_cast<BlobRegistryImpl&>(blobRegistry()).createResourceHandle(request, client);
 }
 
-static void loadResourceSynchronously(NetworkingContext*, const ResourceRequest& request, StoredCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
+static void loadBlobResourceSynchronously(NetworkingContext*, const ResourceRequest& request, StoredCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
 {
     BlobData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(request.url());
     BlobResourceHandle::loadResourceSynchronously(blobData, request, error, response, data);
@@ -68,20 +68,17 @@ static void registerBlobResourceHandleConstructor()
 {
     static bool didRegister = false;
     if (!didRegister) {
-        ResourceHandle::registerBuiltinConstructor("blob", createResourceHandle);
-        ResourceHandle::registerBuiltinSynchronousLoader("blob", loadResourceSynchronously);
+        ResourceHandle::registerBuiltinConstructor("blob", createBlobResourceHandle);
+        ResourceHandle::registerBuiltinSynchronousLoader("blob", loadBlobResourceSynchronously);
         didRegister = true;
     }
 }
 
-RefPtr<ResourceHandle> BlobRegistryImpl::createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
+Ref<ResourceHandle> BlobRegistryImpl::createResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
 {
     auto handle = BlobResourceHandle::createAsync(getBlobDataFromURL(request.url()), request, client);
-    if (!handle)
-        return nullptr;
-
     handle->start();
-    return handle;
+    return WTFMove(handle);
 }
 
 void BlobRegistryImpl::appendStorageItems(BlobData* blobData, const BlobDataItemList& items, long long offset, long long length)
index 3cfda98..fb194b6 100644 (file)
@@ -28,8 +28,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef BlobRegistryImpl_h
-#define BlobRegistryImpl_h
+#pragma once
 
 #include "BlobData.h"
 #include "BlobRegistry.h"
@@ -53,7 +52,7 @@ public:
 
     BlobData* getBlobDataFromURL(const URL&) const;
 
-    RefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*);
+    Ref<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*);
 
 private:
     void appendStorageItems(BlobData*, const BlobDataItemList&, long long offset, long long length);
@@ -74,5 +73,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // BlobRegistryImpl_h
index 8b28139..2da0ce2 100644 (file)
@@ -84,8 +84,6 @@ public:
     BlobResourceSynchronousLoader(ResourceError&, ResourceResponse&, Vector<char>&);
 
     void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override;
-    void didReceiveData(ResourceHandle*, const char*, unsigned, int /*encodedDataLength*/) override;
-    void didFinishLoading(ResourceHandle*, double /*finishTime*/) override;
     void didFail(ResourceHandle*, const ResourceError&) override;
 
 private:
@@ -116,14 +114,6 @@ void BlobResourceSynchronousLoader::didReceiveResponse(ResourceHandle* handle, c
     static_cast<BlobResourceHandle*>(handle)->readSync(m_data.data(), static_cast<int>(m_data.size()));
 }
 
-void BlobResourceSynchronousLoader::didReceiveData(ResourceHandle*, const char*, unsigned, int)
-{
-}
-
-void BlobResourceSynchronousLoader::didFinishLoading(ResourceHandle*, double)
-{
-}
-
 void BlobResourceSynchronousLoader::didFail(ResourceHandle*, const ResourceError& error)
 {
     m_error = error;
@@ -134,9 +124,9 @@ void BlobResourceSynchronousLoader::didFail(ResourceHandle*, const ResourceError
 ///////////////////////////////////////////////////////////////////////////////
 // BlobResourceHandle
 
-PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(BlobData* blobData, const ResourceRequest& request, ResourceHandleClient* client)
+Ref<BlobResourceHandle> BlobResourceHandle::createAsync(BlobData* blobData, const ResourceRequest& request, ResourceHandleClient* client)
 {
-    return adoptRef(new BlobResourceHandle(blobData, request, client, true));
+    return adoptRef(*new BlobResourceHandle(blobData, request, client, true));
 }
 
 void BlobResourceHandle::loadResourceSynchronously(BlobData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data)
index ce86968..c98ae2c 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef BlobResourceHandle_h
-#define BlobResourceHandle_h
+#pragma once
 
 #include "FileStreamClient.h"
 #include "ResourceHandle.h"
-#include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -48,7 +46,7 @@ class BlobDataItem;
 
 class BlobResourceHandle final : public FileStreamClient, public ResourceHandle  {
 public:
-    static PassRefPtr<BlobResourceHandle> createAsync(BlobData*, const ResourceRequest&, ResourceHandleClient*);
+    static Ref<BlobResourceHandle> createAsync(BlobData*, const ResourceRequest&, ResourceHandleClient*);
 
     static void loadResourceSynchronously(BlobData*, const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data);
 
@@ -112,5 +110,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // BlobResourceHandle_h
index 191778b..9045f11 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef PingHandle_h
-#define PingHandle_h
+#pragma once
 
 #include "ResourceHandle.h"
 #include "ResourceHandleClient.h"
@@ -58,7 +57,7 @@ public:
 
 private:
     void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override { delete this; }
-    void didReceiveData(ResourceHandle*, const char*, unsigned, int) override { delete this; }
+    void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int) override { delete this; };
     void didFinishLoading(ResourceHandle*, double) override { delete this; }
     void didFail(ResourceHandle*, const ResourceError&) override { delete this; }
     bool shouldUseCredentialStorage(ResourceHandle*)  override { return m_shouldUseCredentialStorage; }
@@ -81,5 +80,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // PingHandle_h
index 0a0a34e..be700ba 100644 (file)
@@ -85,7 +85,7 @@ ResourceHandle::ResourceHandle(NetworkingContext* context, const ResourceRequest
     }
 }
 
-PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
+RefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
 {
     BuiltinResourceHandleConstructorMap::iterator protocolMapItem = builtinResourceHandleConstructorMap().find(request.url().protocol());
 
@@ -100,7 +100,7 @@ PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, co
     if (newHandle->start())
         return newHandle.release();
 
-    return 0;
+    return nullptr;
 }
 
 void ResourceHandle::scheduleFailure(FailureType type)
index 7bb8802..c051a74 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef ResourceHandle_h
-#define ResourceHandle_h
+#pragma once
 
 #include "AuthenticationClient.h"
 #include "HTTPHeaderMap.h"
@@ -99,7 +98,7 @@ class ResourceHandle : public RefCounted<ResourceHandle>
 #endif
     {
 public:
-    WEBCORE_EXPORT static PassRefPtr<ResourceHandle> create(NetworkingContext*, const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff);
+    WEBCORE_EXPORT static RefPtr<ResourceHandle> create(NetworkingContext*, const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff);
     WEBCORE_EXPORT static void loadResourceSynchronously(NetworkingContext*, const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
 
     WEBCORE_EXPORT virtual ~ResourceHandle();
@@ -240,7 +239,7 @@ public:
     static CFMutableDictionaryRef createSSLPropertiesFromNSURLRequest(const ResourceRequest&);
 #endif
 
-    typedef RefPtr<ResourceHandle> (*BuiltinConstructor)(const ResourceRequest& request, ResourceHandleClient* client);
+    typedef Ref<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);
@@ -297,5 +296,3 @@ private:
 };
 
 }
-
-#endif // ResourceHandle_h
index ec617fb..0ec2981 100644 (file)
@@ -74,7 +74,7 @@ void ResourceHandleClient::willCacheResponseAsync(ResourceHandle* handle, NSCach
 }
 #endif
 
-void ResourceHandleClient::didReceiveBuffer(ResourceHandle* handle, PassRefPtr<SharedBuffer> buffer, int encodedDataLength)
+void ResourceHandleClient::didReceiveBuffer(ResourceHandle* handle, Ref<SharedBuffer>&& buffer, int encodedDataLength)
 {
     didReceiveData(handle, buffer->data(), buffer->size(), encodedDataLength);
 }
index b3382c5..c4d56aa 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef ResourceHandleClient_h
-#define ResourceHandleClient_h
+#pragma once
 
 #include "PlatformExportMacros.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/Ref.h>
 
 #if USE(CFNETWORK)
 #include <CFNetwork/CFURLCachePriv.h>
@@ -75,7 +74,7 @@ namespace WebCore {
         virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { }
         
         virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int /*encodedDataLength*/) { }
-        WEBCORE_EXPORT virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedDataLength);
+        WEBCORE_EXPORT virtual void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int encodedDataLength);
         
         virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) { }
         virtual void didFail(ResourceHandle*, const ResourceError&) { }
@@ -140,5 +139,3 @@ namespace WebCore {
     };
 
 }
-
-#endif
index 61fdfe1..89c3c56 100644 (file)
@@ -569,9 +569,6 @@ void WebCoreNSURLSessionDataTaskClient::loadFinished(PlatformMediaResource& reso
     ASSERT_UNUSED(resource, &resource == _resource);
     UNUSED_PARAM(data);
     UNUSED_PARAM(length);
-    // FIXME: try to avoid a copy, if possible.
-    // e.g., RetainPtr<CFDataRef> cfData = resource->resourceBuffer()->createCFData();
-
     RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:data length:length]);
     RetainPtr<WebCoreNSURLSessionDataTask> strongSelf { self };
     [self.session addDelegateOperation:[strongSelf, length, nsData] {
index a0e43a8..a4894a6 100644 (file)
@@ -146,7 +146,7 @@ public:
         ASSERT_NOT_REACHED();
     }
 
-    void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int /* encodedLength */) override
+    void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&& buffer, int /* encodedLength */) override
     {
         // This pattern is suggested by SharedBuffer.h.
         const char* segment;
index 6dd4c9f..f63d696 100644 (file)
@@ -27,7 +27,7 @@
 namespace WebCore {
 
 SharedBuffer::SharedBuffer(SoupBuffer* soupBuffer)
-    : m_buffer(adoptRef(new DataBuffer))
+    : m_buffer(*new DataBuffer)
     , m_soupBuffer(soupBuffer)
 {
     ASSERT(soupBuffer);
@@ -73,7 +73,7 @@ unsigned SharedBuffer::platformDataSize() const
     return m_soupBuffer->length;
 }
 
-bool SharedBuffer::maybeAppendPlatformData(SharedBuffer*)
+bool SharedBuffer::maybeAppendPlatformData(SharedBuffer&)
 {
     return false;
 }
index cdb913d..6358134 100644 (file)
@@ -114,7 +114,7 @@ void MockContentFilter::finishedAddingData()
 Ref<SharedBuffer> MockContentFilter::replacementData() const
 {
     ASSERT(didBlockData());
-    return adoptRef(*SharedBuffer::create(m_replacementData.data(), m_replacementData.size()).leakRef());
+    return SharedBuffer::create(m_replacementData.data(), m_replacementData.size()).leakRef();
 }
 
 ContentFilterUnblockHandler MockContentFilter::unblockHandler() const
index 001cdd2..958dd1b 100644 (file)
@@ -1,3 +1,34 @@
+2016-06-06  Alex Christensen  <achristensen@webkit.org>
+
+        Modernize loading code
+        https://bugs.webkit.org/show_bug.cgi?id=158332
+
+        Reviewed by Darin Adler.
+
+        * NetworkProcess/Downloads/PendingDownload.h:
+        * NetworkProcess/NetworkDataTask.h:
+        (WebKit::NetworkDataTask::client):
+        * NetworkProcess/NetworkLoad.cpp:
+        (WebKit::NetworkLoad::didReceiveResponseNetworkSession):
+        (WebKit::NetworkLoad::didReceiveData):
+        (WebKit::NetworkLoad::didReceiveBuffer):
+        * NetworkProcess/NetworkLoad.h:
+        * NetworkProcess/NetworkLoadClient.h:
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::didReceiveBuffer):
+        (WebKit::NetworkResourceLoader::didFinishLoading):
+        * NetworkProcess/NetworkResourceLoader.h:
+        * NetworkProcess/PingLoad.h:
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
+        (WebKit::NetworkCache::SpeculativeLoad::didReceiveBuffer):
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTask::didReceiveResponse):
+        (WebKit::NetworkDataTask::didReceiveData):
+        * Shared/WebHitTestResultData.cpp:
+        * WebProcess/Network/WebResourceLoader.cpp:
+        (WebKit::WebResourceLoader::didReceiveResource):
+
 2016-06-05  Sam Weinig  <sam@webkit.org>
 
         Add experimental support for spring based CSS animations
index 3c11ccc..bab1d44 100644 (file)
@@ -56,7 +56,7 @@ private:
     bool isSynchronous() const override { return false; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) override;
     ShouldContinueDidReceiveResponse didReceiveResponse(const WebCore::ResourceResponse&) override { return ShouldContinueDidReceiveResponse::No; };
-    void didReceiveBuffer(RefPtr<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override { };
+    void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override { };
     void didFinishLoading(double finishTime) override { };
     void didFailLoading(const WebCore::ResourceError&) override;
     void didBecomeDownload() override;
index b7f456a..d6cd0d4 100644 (file)
@@ -71,7 +71,7 @@ public:
     virtual void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler) = 0;
     virtual void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler) = 0;
     virtual void didReceiveResponseNetworkSession(const WebCore::ResourceResponse&, ResponseCompletionHandler) = 0;
-    virtual void didReceiveData(RefPtr<WebCore::SharedBuffer>&&) = 0;
+    virtual void didReceiveData(Ref<WebCore::SharedBuffer>&&) = 0;
     virtual void didCompleteWithError(const WebCore::ResourceError&) = 0;
     virtual void didBecomeDownload() = 0;
     virtual void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) = 0;
@@ -101,7 +101,7 @@ public:
     void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler);
     void didCompleteWithError(const WebCore::ResourceError&);
     void didReceiveResponse(const WebCore::ResourceResponse&, ResponseCompletionHandler);
-    void didReceiveData(RefPtr<WebCore::SharedBuffer>&&);
+    void didReceiveData(Ref<WebCore::SharedBuffer>&&);
     void didBecomeDownload();
     
     NetworkDataTaskClient* client() const { return m_client; }
index 4f7538c..08080a3 100644 (file)
@@ -34,6 +34,7 @@
 #include <WebCore/NotImplemented.h>
 #include <WebCore/ResourceHandle.h>
 #include <WebCore/SessionID.h>
+#include <WebCore/SharedBuffer.h>
 #include <wtf/MainThread.h>
 
 namespace WebKit {
@@ -249,9 +250,9 @@ void NetworkLoad::didReceiveResponseNetworkSession(const ResourceResponse& respo
         m_responseCompletionHandler = completionHandler;
 }
 
-void NetworkLoad::didReceiveData(RefPtr<SharedBuffer>&& buffer)
+void NetworkLoad::didReceiveData(Ref<SharedBuffer>&& buffer)
 {
-    ASSERT(buffer);
+    // FIXME: This should be the encoded data length, not the decoded data length.
     auto size = buffer->size();
     m_client.didReceiveBuffer(WTFMove(buffer), size);
 }
@@ -300,7 +301,7 @@ void NetworkLoad::didReceiveData(ResourceHandle*, const char* /* data */, unsign
     ASSERT_NOT_REACHED();
 }
 
-void NetworkLoad::didReceiveBuffer(ResourceHandle* handle, PassRefPtr<SharedBuffer> buffer, int reportedEncodedDataLength)
+void NetworkLoad::didReceiveBuffer(ResourceHandle* handle, Ref<SharedBuffer>&& buffer, int reportedEncodedDataLength)
 {
     ASSERT_UNUSED(handle, handle == m_handle);
     m_client.didReceiveBuffer(WTFMove(buffer), reportedEncodedDataLength);
index 123a64e..4a20664 100644 (file)
@@ -68,7 +68,7 @@ public:
     void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler) final;
     void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler) final;
     void didReceiveResponseNetworkSession(const WebCore::ResourceResponse&, ResponseCompletionHandler) final;
-    void didReceiveData(RefPtr<WebCore::SharedBuffer>&&) final;
+    void didReceiveData(Ref<WebCore::SharedBuffer>&&) final;
     void didCompleteWithError(const WebCore::ResourceError&) final;
     void didBecomeDownload() final;
     void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) override;
@@ -80,7 +80,7 @@ public:
     void didSendData(WebCore::ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
     void didReceiveResponseAsync(WebCore::ResourceHandle*, const WebCore::ResourceResponse&) override;
     void didReceiveData(WebCore::ResourceHandle*, const char*, unsigned, int encodedDataLength) override;
-    void didReceiveBuffer(WebCore::ResourceHandle*, PassRefPtr<WebCore::SharedBuffer>, int encodedDataLength) override;
+    void didReceiveBuffer(WebCore::ResourceHandle*, Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override;
     void didFinishLoading(WebCore::ResourceHandle*, double finishTime) override;
     void didFail(WebCore::ResourceHandle*, const WebCore::ResourceError&) override;
     void wasBlocked(WebCore::ResourceHandle*) override;
index fcd01dc..00a27ac 100644 (file)
@@ -29,7 +29,6 @@
 #include <WebCore/ResourceError.h>
 #include <WebCore/ResourceRequest.h>
 #include <WebCore/ResourceResponse.h>
-#include <WebCore/SharedBuffer.h>
 #include <wtf/Forward.h>
 
 #if PLATFORM(COCOA)
@@ -38,6 +37,7 @@ typedef const struct _CFCachedURLResponse* CFCachedURLResponseRef;
 
 namespace WebCore {
 class ProtectionSpace;
+class SharedBuffer;
 }
 
 namespace WebKit {
@@ -53,7 +53,7 @@ public:
     virtual void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) = 0;
     enum class ShouldContinueDidReceiveResponse { No, Yes };
     virtual ShouldContinueDidReceiveResponse didReceiveResponse(const WebCore::ResourceResponse&) = 0;
-    virtual void didReceiveBuffer(RefPtr<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) = 0;
+    virtual void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) = 0;
     virtual void didFinishLoading(double finishTime) = 0;
     virtual void didFailLoading(const WebCore::ResourceError&) = 0;
 #if USE(NETWORK_SESSION)
index 3a0c082..91c5a41 100644 (file)
@@ -331,7 +331,7 @@ auto NetworkResourceLoader::didReceiveResponse(const ResourceResponse& receivedR
     return ShouldContinueDidReceiveResponse::No;
 }
 
-void NetworkResourceLoader::didReceiveBuffer(RefPtr<SharedBuffer>&& buffer, int reportedEncodedDataLength)
+void NetworkResourceLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, int reportedEncodedDataLength)
 {
 #if ENABLE(NETWORK_CACHE)
     ASSERT(!m_cacheEntryForValidation);
@@ -355,7 +355,7 @@ void NetworkResourceLoader::didReceiveBuffer(RefPtr<SharedBuffer>&& buffer, int
         startBufferingTimerIfNeeded();
         return;
     }
-    sendBufferMaybeAborting(*buffer, encodedDataLength);
+    sendBufferMaybeAborting(buffer, encodedDataLength);
 }
 
 void NetworkResourceLoader::didFinishLoading(double finishTime)
index 62116e2..2f374e2 100644 (file)
@@ -89,7 +89,7 @@ public:
     bool isSynchronous() const override;
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&&) override;
     ShouldContinueDidReceiveResponse didReceiveResponse(const WebCore::ResourceResponse&) override;
-    void didReceiveBuffer(RefPtr<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override;
+    void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override;
     void didFinishLoading(double finishTime) override;
     void didFailLoading(const WebCore::ResourceError&) override;
 #if USE(NETWORK_SESSION)
index d1d9976..1eb8453 100644 (file)
@@ -63,7 +63,7 @@ private:
         completionHandler(WebCore::PolicyAction::PolicyIgnore);
         delete this;
     }
-    void didReceiveData(RefPtr<WebCore::SharedBuffer>&&)  override { ASSERT_NOT_REACHED(); }
+    void didReceiveData(Ref<WebCore::SharedBuffer>&&)  override { ASSERT_NOT_REACHED(); }
     void didCompleteWithError(const WebCore::ResourceError&) override { delete this; }
     void didBecomeDownload() override { ASSERT_NOT_REACHED(); }
     void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) override { }
index 2697258..23ac4fd 100644 (file)
@@ -88,7 +88,7 @@ auto SpeculativeLoad::didReceiveResponse(const ResourceResponse& receivedRespons
     return ShouldContinueDidReceiveResponse::Yes;
 }
 
-void SpeculativeLoad::didReceiveBuffer(RefPtr<SharedBuffer>&& buffer, int reportedEncodedDataLength)
+void SpeculativeLoad::didReceiveBuffer(Ref<SharedBuffer>&& buffer, int reportedEncodedDataLength)
 {
     ASSERT(!m_cacheEntryForValidation);
 
index f29d7bc..a9b61ac 100644 (file)
@@ -58,7 +58,7 @@ private:
     bool isSynchronous() const override { return false; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) override;
     ShouldContinueDidReceiveResponse didReceiveResponse(const WebCore::ResourceResponse&) override;
-    void didReceiveBuffer(RefPtr<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override;
+    void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override;
     void didFinishLoading(double finishTime) override;
     void didFailLoading(const WebCore::ResourceError&) override;
 #if USE(NETWORK_SESSION)
index f2c6cd7..af059ae 100644 (file)
@@ -175,7 +175,7 @@ void NetworkDataTask::didReceiveResponse(const WebCore::ResourceResponse& respon
     }
 }
 
-void NetworkDataTask::didReceiveData(RefPtr<WebCore::SharedBuffer>&& data)
+void NetworkDataTask::didReceiveData(Ref<WebCore::SharedBuffer>&& data)
 {
     if (m_client)
         m_client->didReceiveData(WTFMove(data));
index d31b299..6b585ca 100644 (file)
@@ -27,6 +27,7 @@
 #include <WebCore/HitTestResult.h>
 #include <WebCore/Node.h>
 #include <WebCore/RenderObject.h>
+#include <WebCore/SharedBuffer.h>
 #include <WebCore/URL.h>
 #include <wtf/text/WTFString.h>
 
index 16f755d..5df4051 100644 (file)
@@ -202,7 +202,7 @@ void WebResourceLoader::didReceiveResource(const ShareableResource::Handle& hand
 
     // Only send data to the didReceiveData callback if it exists.
     if (unsigned bufferSize = buffer->size())
-        m_coreLoader->didReceiveBuffer(buffer.release(), bufferSize, DataPayloadWholeResource);
+        m_coreLoader->didReceiveBuffer(buffer.releaseNonNull(), bufferSize, DataPayloadWholeResource);
 
     if (!m_coreLoader)
         return;