ThreadableBlobRegistry::blobSize should take a SessionID as parameter
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 13:42:37 +0000 (13:42 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 13:42:37 +0000 (13:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200671

Source/WebCore:

Reviewed by Alex Christensen.

Update FormData to compute its byte size based on a SessionID.
We keep a WK1 byte length computation for FormDataElement.
Update FormData call sites accordingly.
Update CacheStorageConnection to implement a SessionID getter.
No change of behavior.

* Modules/cache/CacheStorageConnection.cpp:
(WebCore::CacheStorageConnection::computeRealBodySize):
(WebCore::computeRealBodySize): Deleted.
* Modules/cache/CacheStorageConnection.h:
* Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::WorkerCacheStorageConnection::sessionID const):
* Modules/cache/WorkerCacheStorageConnection.h:
* fileapi/Blob.cpp:
(WebCore::Blob::size const):
* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::ThreadableBlobRegistry::blobSize):
* fileapi/ThreadableBlobRegistry.h:
* loader/cache/KeepaliveRequestTracker.cpp:
(WebCore::KeepaliveRequestTracker::tryRegisterRequest):
(WebCore::KeepaliveRequestTracker::registerRequest):
(WebCore::KeepaliveRequestTracker::unregisterRequest):
* page/CacheStorageProvider.h:
(WebCore::CacheStorageProvider::createCacheStorageConnection):
* platform/network/BlobRegistry.h:
* platform/network/FormData.cpp:
(WebCore::computeLengthInBytes):
(WebCore::FormDataElement::lengthInBytes const):
(WebCore::FormData::lengthInBytes const):
* platform/network/FormData.h:
* platform/network/cf/FormDataStreamCFNet.cpp:
(WebCore::createHTTPBodyCFReadStream):
* platform/network/curl/CurlFormDataStream.cpp:
(WebCore::m_sessionID):
(WebCore::CurlFormDataStream::computeContentLength):
(WebCore::CurlFormDataStream::CurlFormDataStream): Deleted.
* platform/network/curl/CurlFormDataStream.h:
* platform/network/curl/CurlRequest.cpp:
(WebCore::CurlRequest::CurlRequest):
* platform/network/curl/CurlRequest.h:
(WebCore::CurlRequest::create):

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest):

Source/WebKit:

Reviewed by Alex Christensen.

Update WebCacheStorageConnection to implement sessionID getter.
Update NetworkConnectionToWebProcess to get a sessionID as parameter to blobSize computation.

* NetworkProcess/curl/NetworkDataTaskCurl.cpp:
(WebKit::NetworkDataTaskCurl::createCurlRequest):
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::blobSize):
(WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkProcessPlatformStrategies.cpp:
(WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):
* WebProcess/Cache/WebCacheStorageConnection.h:
* WebProcess/FileAPI/BlobRegistryProxy.cpp:
(WebKit::BlobRegistryProxy::blobSize):
* WebProcess/FileAPI/BlobRegistryProxy.h:

Source/WebKitLegacy/mac:

Reviewed by ALex Christensen.

* WebCoreSupport/WebPlatformStrategies.mm:

Source/WebKitLegacy/win:

Reviewed by Alex Christensen.

* WebCoreSupport/WebPlatformStrategies.cpp:

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

34 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/CacheStorageConnection.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.h
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.h
Source/WebCore/fileapi/Blob.cpp
Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
Source/WebCore/fileapi/ThreadableBlobRegistry.h
Source/WebCore/loader/cache/KeepaliveRequestTracker.cpp
Source/WebCore/page/CacheStorageProvider.h
Source/WebCore/platform/network/BlobRegistry.h
Source/WebCore/platform/network/FormData.cpp
Source/WebCore/platform/network/FormData.h
Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp
Source/WebCore/platform/network/curl/CurlDownload.cpp
Source/WebCore/platform/network/curl/CurlFormDataStream.cpp
Source/WebCore/platform/network/curl/CurlFormDataStream.h
Source/WebCore/platform/network/curl/CurlRequest.cpp
Source/WebCore/platform/network/curl/CurlRequest.h
Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.cpp
Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.h
Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.cpp
Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp

index b8a8eb6..5412378 100644 (file)
@@ -1,3 +1,55 @@
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
+        ThreadableBlobRegistry::blobSize should take a SessionID as parameter
+        https://bugs.webkit.org/show_bug.cgi?id=200671
+
+        Reviewed by Alex Christensen.
+
+        Update FormData to compute its byte size based on a SessionID.
+        We keep a WK1 byte length computation for FormDataElement.
+        Update FormData call sites accordingly.
+        Update CacheStorageConnection to implement a SessionID getter.
+        No change of behavior.
+
+        * Modules/cache/CacheStorageConnection.cpp:
+        (WebCore::CacheStorageConnection::computeRealBodySize):
+        (WebCore::computeRealBodySize): Deleted.
+        * Modules/cache/CacheStorageConnection.h:
+        * Modules/cache/WorkerCacheStorageConnection.cpp:
+        (WebCore::WorkerCacheStorageConnection::sessionID const):
+        * Modules/cache/WorkerCacheStorageConnection.h:
+        * fileapi/Blob.cpp:
+        (WebCore::Blob::size const):
+        * fileapi/ThreadableBlobRegistry.cpp:
+        (WebCore::ThreadableBlobRegistry::blobSize):
+        * fileapi/ThreadableBlobRegistry.h:
+        * loader/cache/KeepaliveRequestTracker.cpp:
+        (WebCore::KeepaliveRequestTracker::tryRegisterRequest):
+        (WebCore::KeepaliveRequestTracker::registerRequest):
+        (WebCore::KeepaliveRequestTracker::unregisterRequest):
+        * page/CacheStorageProvider.h:
+        (WebCore::CacheStorageProvider::createCacheStorageConnection):
+        * platform/network/BlobRegistry.h:
+        * platform/network/FormData.cpp:
+        (WebCore::computeLengthInBytes):
+        (WebCore::FormDataElement::lengthInBytes const):
+        (WebCore::FormData::lengthInBytes const):
+        * platform/network/FormData.h:
+        * platform/network/cf/FormDataStreamCFNet.cpp:
+        (WebCore::createHTTPBodyCFReadStream):
+        * platform/network/curl/CurlFormDataStream.cpp:
+        (WebCore::m_sessionID):
+        (WebCore::CurlFormDataStream::computeContentLength):
+        (WebCore::CurlFormDataStream::CurlFormDataStream): Deleted.
+        * platform/network/curl/CurlFormDataStream.h:
+        * platform/network/curl/CurlRequest.cpp:
+        (WebCore::CurlRequest::CurlRequest):
+        * platform/network/curl/CurlRequest.h:
+        (WebCore::CurlRequest::create):
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::createRequest):
+
 2019-08-14  Antti Koivisto  <antti@apple.com>
 
         Remove TouchActionData
index 4acb8aa..4c04d24 100644 (file)
 namespace WebCore {
 using namespace WebCore::DOMCacheEngine;
 
-static inline uint64_t computeRealBodySize(const DOMCacheEngine::ResponseBody& body)
+uint64_t CacheStorageConnection::computeRealBodySize(const DOMCacheEngine::ResponseBody& body)
 {
     uint64_t result = 0;
     WTF::switchOn(body, [&] (const Ref<WebCore::FormData>& formData) {
-        result = formData->lengthInBytes();
+        result = formData->lengthInBytes(sessionID());
     }, [&] (const Ref<WebCore::SharedBuffer>& buffer) {
         result = buffer->size();
     }, [] (const std::nullptr_t&) {
index 87eab71..d1dafa8 100644 (file)
@@ -57,6 +57,11 @@ public:
     virtual void engineRepresentation(CompletionHandler<void(const String&)>&& callback) { callback(String { }); }
     virtual void updateQuotaBasedOnSpaceUsage(const ClientOrigin&) { }
 
+    virtual PAL::SessionID sessionID() const = 0;
+
+private:
+    uint64_t computeRealBodySize(const DOMCacheEngine::ResponseBody&);
+
 protected:
     HashMap<uint64_t, uint64_t> m_opaqueResponseToSizeWithPaddingMap;
 };
index 206c241..ff06a6b 100644 (file)
@@ -134,6 +134,11 @@ WorkerCacheStorageConnection::~WorkerCacheStorageConnection()
         callOnMainThread([mainThreadConnection = WTFMove(m_mainThreadConnection)]() mutable { });
 }
 
+PAL::SessionID WorkerCacheStorageConnection::sessionID() const
+{
+    return m_scope.sessionID();
+}
+
 void WorkerCacheStorageConnection::open(const ClientOrigin& origin, const String& cacheName, CacheIdentifierCallback&& callback)
 {
     uint64_t requestIdentifier = ++m_lastRequestIdentifier;
index 119d4cc..2f3afad 100644 (file)
@@ -55,6 +55,8 @@ private:
     void reference(uint64_t cacheIdentifier) final;
     void dereference(uint64_t cacheIdentifier) final;
 
+    PAL::SessionID sessionID() const final;
+
     void doOpen(uint64_t requestIdentifier, const ClientOrigin&, const String& cacheName);
     void doRemove(uint64_t requestIdentifier, uint64_t cacheIdentifier);
     void doRetrieveCaches(uint64_t requestIdentifier, const ClientOrigin&, uint64_t updateCounter);
index d891c70..52a5367 100644 (file)
@@ -169,7 +169,7 @@ unsigned long long Blob::size() const
     if (!m_size) {
         // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to
         // come up with an exception to throw if file size is not representable.
-        unsigned long long actualSize = ThreadableBlobRegistry::blobSize(m_internalURL);
+        unsigned long long actualSize = ThreadableBlobRegistry::blobSize(m_sessionID, m_internalURL);
         m_size = WTF::isInBounds<long long>(actualSize) ? actualSize : 0;
     }
 
index a95b249..7610664 100644 (file)
@@ -128,15 +128,15 @@ void ThreadableBlobRegistry::registerBlobURLForSlice(PAL::SessionID sessionID, c
     });
 }
 
-unsigned long long ThreadableBlobRegistry::blobSize(const URL& url)
+unsigned long long ThreadableBlobRegistry::blobSize(PAL::SessionID sessionID, const URL& url)
 {
     if (isMainThread())
-        return blobRegistry().blobSize(url);
+        return blobRegistry().blobSize(sessionID, url);
 
     unsigned long long resultSize;
     BinarySemaphore semaphore;
-    callOnMainThread([url = url.isolatedCopy(), &semaphore, &resultSize] {
-        resultSize = blobRegistry().blobSize(url);
+    callOnMainThread([sessionID, url = url.isolatedCopy(), &semaphore, &resultSize] {
+        resultSize = blobRegistry().blobSize(sessionID, url);
         semaphore.signal();
     });
     semaphore.wait();
index 315f5ca..c576b2d 100644 (file)
@@ -47,7 +47,7 @@ public:
     static void registerBlobURLForSlice(PAL::SessionID, const URL& newURL, const URL& srcURL, long long start, long long end);
     static void unregisterBlobURL(PAL::SessionID, const URL&);
 
-    static unsigned long long blobSize(const URL&);
+    static unsigned long long blobSize(PAL::SessionID, const URL&);
 
     // Returns the origin for the given blob URL. This is because we are not able to embed the unique security origin or the origin of file URL
     // in the blob URL.
index 00c5505..47a3c7b 100644 (file)
@@ -44,7 +44,7 @@ bool KeepaliveRequestTracker::tryRegisterRequest(CachedResource& resource)
     if (!body)
         return true;
 
-    uint64_t bodySize = body->lengthInBytes();
+    uint64_t bodySize = body->lengthInBytes(resource.sessionID());
     if (m_inflightKeepaliveBytes + bodySize > maxInflightKeepaliveBytes)
         return false;
 
@@ -60,7 +60,7 @@ void KeepaliveRequestTracker::registerRequest(CachedResource& resource)
         return;
     ASSERT(!m_inflightKeepaliveRequests.contains(&resource));
     m_inflightKeepaliveRequests.append(&resource);
-    m_inflightKeepaliveBytes += body->lengthInBytes();
+    m_inflightKeepaliveBytes += body->lengthInBytes(resource.sessionID());
     ASSERT(m_inflightKeepaliveBytes <= maxInflightKeepaliveBytes);
 
     resource.addClient(*this);
@@ -87,7 +87,7 @@ void KeepaliveRequestTracker::unregisterRequest(CachedResource& resource)
     resource.removeClient(*this);
     bool wasRemoved = m_inflightKeepaliveRequests.removeFirst(&resource);
     ASSERT_UNUSED(wasRemoved, wasRemoved);
-    m_inflightKeepaliveBytes -= resource.resourceRequest().httpBody()->lengthInBytes();
+    m_inflightKeepaliveBytes -= resource.resourceRequest().httpBody()->lengthInBytes(resource.sessionID());
     ASSERT(m_inflightKeepaliveBytes <= maxInflightKeepaliveBytes);
 }
 
index 636f3d0..d9f3f3c 100644 (file)
@@ -35,9 +35,14 @@ class CacheStorageProvider : public RefCounted<CacheStorageProvider> {
 public:
     class DummyCacheStorageConnection final : public WebCore::CacheStorageConnection {
     public:
-        static Ref<DummyCacheStorageConnection> create() { return adoptRef(*new DummyCacheStorageConnection); }
+        static Ref<DummyCacheStorageConnection> create(PAL::SessionID sessionID) { return adoptRef(*new DummyCacheStorageConnection(sessionID)); }
 
     private:
+        explicit DummyCacheStorageConnection(PAL::SessionID sessionID)
+            : m_sessionID(sessionID)
+        {
+        }
+
         void open(const ClientOrigin&, const String&, DOMCacheEngine::CacheIdentifierCallback&&) final { }
         void remove(uint64_t, DOMCacheEngine::CacheIdentifierCallback&&) final { }
         void retrieveCaches(const ClientOrigin&, uint64_t, DOMCacheEngine::CacheInfosCallback&&) final { }
@@ -46,10 +51,13 @@ public:
         void batchPutOperation(uint64_t, Vector<DOMCacheEngine::Record>&&, DOMCacheEngine::RecordIdentifiersCallback&&) final { }
         void reference(uint64_t) final { }
         void dereference(uint64_t) final { }
+        PAL::SessionID sessionID() const final { return m_sessionID; }
+
+        PAL::SessionID m_sessionID;
     };
 
     static Ref<CacheStorageProvider> create() { return adoptRef(*new CacheStorageProvider); }
-    virtual Ref<CacheStorageConnection> createCacheStorageConnection(PAL::SessionID) { return DummyCacheStorageConnection::create(); }
+    virtual Ref<CacheStorageConnection> createCacheStorageConnection(PAL::SessionID sessionID) { return DummyCacheStorageConnection::create(sessionID); }
     virtual ~CacheStorageProvider() { };
 
 protected:
index 660a796..8cd391d 100644 (file)
@@ -64,7 +64,7 @@ public:
 
     virtual void unregisterBlobURL(PAL::SessionID, const URL&) = 0;
 
-    virtual unsigned long long blobSize(const URL&) = 0;
+    virtual unsigned long long blobSize(PAL::SessionID, const URL&) = 0;
 
     virtual void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) = 0;
 
index d71b1ed..216cb33 100644 (file)
@@ -124,9 +124,9 @@ Ref<FormData> FormData::isolatedCopy() const
     return formData;
 }
 
-uint64_t FormDataElement::lengthInBytes() const
+static inline uint64_t computeLengthInBytes(const FormDataElement& element, const Function<uint64_t(const URL&)>& blobSize)
 {
-    return switchOn(data,
+    return switchOn(element.data,
         [] (const Vector<char>& bytes) {
             return static_cast<uint64_t>(bytes.size());
         }, [] (const FormDataElement::EncodedFileData& fileData) {
@@ -136,12 +136,26 @@ uint64_t FormDataElement::lengthInBytes() const
             if (FileSystem::getFileSize(fileData.filename, fileSize))
                 return static_cast<uint64_t>(fileSize);
             return static_cast<uint64_t>(0);
-        }, [] (const FormDataElement::EncodedBlobData& blobData) {
-            return ThreadableBlobRegistry::blobSize(blobData.url);
+        }, [&blobSize] (const FormDataElement::EncodedBlobData& blobData) {
+            return blobSize(blobData.url);
         }
     );
 }
 
+uint64_t FormDataElement::lengthInBytes(BlobRegistryImpl* blobRegistry) const
+{
+    return computeLengthInBytes(*this, [&](auto& url) {
+        return blobRegistry ? blobRegistry->blobSize(url) : 0;
+    });
+}
+
+uint64_t FormDataElement::lengthInBytes(PAL::SessionID sessionID) const
+{
+    return computeLengthInBytes(*this, [&](auto& url) {
+        return blobRegistry().blobSize(sessionID, url);
+    });
+}
+
 FormDataElement FormDataElement::isolatedCopy() const
 {
     return switchOn(data,
@@ -380,12 +394,12 @@ FormDataForUpload::~FormDataForUpload()
         FileSystem::deleteFile(file);
 }
 
-uint64_t FormData::lengthInBytes() const
+uint64_t FormData::lengthInBytes(PAL::SessionID sessionID) const
 {
     if (!m_lengthInBytes) {
         uint64_t length = 0;
         for (auto& element : m_elements)
-            length += element.lengthInBytes();
+            length += element.lengthInBytes(sessionID);
         m_lengthInBytes = length;
     }
     return *m_lengthInBytes;
index 7c686e8..b8ec03d 100644 (file)
@@ -20,6 +20,7 @@
 #pragma once
 
 #include "BlobData.h"
+#include <pal/SessionID.h>
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 #include <wtf/URL.h>
@@ -50,7 +51,8 @@ struct FormDataElement {
     explicit FormDataElement(const URL& blobURL)
         : data(EncodedBlobData { blobURL }) { }
 
-    uint64_t lengthInBytes() const;
+    uint64_t lengthInBytes(BlobRegistryImpl*) const;
+    uint64_t lengthInBytes(PAL::SessionID) const;
 
     FormDataElement isolatedCopy() const;
 
@@ -249,7 +251,7 @@ public:
         return FormURLEncoded;
     }
 
-    uint64_t lengthInBytes() const;
+    uint64_t lengthInBytes(PAL::SessionID) const;
 
     WEBCORE_EXPORT URL asBlobURL() const;
 
index 53fea05..9a3a54f 100644 (file)
@@ -378,7 +378,7 @@ RetainPtr<CFReadStreamRef> createHTTPBodyCFReadStream(FormData& formData)
     // Precompute the content length so CFNetwork doesn't use chunked mode.
     unsigned long long length = 0;
     for (auto& element : dataForUpload.data().elements())
-        length += element.lengthInBytes();
+        length += element.lengthInBytes(blobRegistry().blobRegistryImpl());
 
     FormCreationContext* formContext = new FormCreationContext { WTFMove(dataForUpload), length };
     CFReadStreamCallBacksV1 callBacks = { 1, formCreate, formFinalize, nullptr, formOpen, nullptr, formRead, nullptr, formCanRead, formClose, formCopyProperty, nullptr, nullptr, formSchedule, formUnschedule };
index 1ace246..1a4150a 100644 (file)
@@ -76,7 +76,8 @@ bool CurlDownload::cancel()
 
 Ref<CurlRequest> CurlDownload::createCurlRequest(ResourceRequest& request)
 {
-    auto curlRequest = CurlRequest::create(request, *this);
+    // FIXME: Use a correct sessionID.
+    auto curlRequest = CurlRequest::create(request, *this, PAL::SessionID::emptySessionID());
     return curlRequest;
 }
 
index 2bba5a6..9fc66ec 100644 (file)
@@ -41,7 +41,8 @@
 
 namespace WebCore {
 
-CurlFormDataStream::CurlFormDataStream(const FormData* formData)
+CurlFormDataStream::CurlFormDataStream(const FormData* formData, PAL::SessionID sessionID)
+    : m_sessionID(sessionID)
 {
     ASSERT(isMainThread());
 
@@ -103,7 +104,7 @@ void CurlFormDataStream::computeContentLength()
     m_isContentLengthUpdated = true;
 
     for (const auto& element : m_formData->elements())
-        m_totalSize += element.lengthInBytes();
+        m_totalSize += element.lengthInBytes(m_sessionID);
 }
 
 Optional<size_t> CurlFormDataStream::read(char* buffer, size_t size)
index 09e7fdb..5a32630 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore {
 
 class CurlFormDataStream {
 public:
-    CurlFormDataStream(const FormData*);
+    CurlFormDataStream(const FormData*, PAL::SessionID);
     WEBCORE_EXPORT ~CurlFormDataStream();
 
     void clean();
@@ -54,6 +54,7 @@ private:
     Optional<size_t> readFromFile(const FormDataElement::EncodedFileData&, char*, size_t);
     Optional<size_t> readFromData(const Vector<char>&, char*, size_t);
 
+    PAL::SessionID m_sessionID;
     RefPtr<FormData> m_formData;
 
     std::unique_ptr<Vector<char>> m_postData;
index 17feddf..07034bb 100644 (file)
 
 namespace WebCore {
 
-CurlRequest::CurlRequest(const ResourceRequest&request, CurlRequestClient* client, ShouldSuspend shouldSuspend, EnableMultipart enableMultipart, CaptureNetworkLoadMetrics captureExtraMetrics, MessageQueue<Function<void()>>* messageQueue)
+CurlRequest::CurlRequest(const ResourceRequest&request, CurlRequestClient* client, PAL::SessionID sessionID, ShouldSuspend shouldSuspend, EnableMultipart enableMultipart, CaptureNetworkLoadMetrics captureExtraMetrics, MessageQueue<Function<void()>>* messageQueue)
     : m_client(client)
     , m_messageQueue(messageQueue)
     , m_request(request.isolatedCopy())
     , m_shouldSuspend(shouldSuspend == ShouldSuspend::Yes)
     , m_enableMultipart(enableMultipart == EnableMultipart::Yes)
-    , m_formDataStream(m_request.httpBody())
+    , m_formDataStream(m_request.httpBody(), sessionID)
     , m_captureExtraMetrics(captureExtraMetrics == CaptureNetworkLoadMetrics::Extended)
 {
     ASSERT(isMainThread());
index b08ecc1..606673d 100644 (file)
@@ -32,6 +32,7 @@
 #include "CurlResponse.h"
 #include "ProtectionSpace.h"
 #include "ResourceRequest.h"
+#include <pal/SessionID.h>
 #include <wtf/FileSystem.h>
 #include <wtf/MessageQueue.h>
 #include <wtf/MonotonicTime.h>
@@ -63,9 +64,9 @@ public:
         Extended
     };
 
-    static Ref<CurlRequest> create(const ResourceRequest& request, CurlRequestClient& client, ShouldSuspend shouldSuspend = ShouldSuspend::No, EnableMultipart enableMultipart = EnableMultipart::No, CaptureNetworkLoadMetrics captureMetrics = CaptureNetworkLoadMetrics::Basic, MessageQueue<Function<void()>>* messageQueue = nullptr)
+    static Ref<CurlRequest> create(const ResourceRequest& request, CurlRequestClient& client, PAL::SessionID sessionID, ShouldSuspend shouldSuspend = ShouldSuspend::No, EnableMultipart enableMultipart = EnableMultipart::No, CaptureNetworkLoadMetrics captureMetrics = CaptureNetworkLoadMetrics::Basic, MessageQueue<Function<void()>>* messageQueue = nullptr)
     {
-        return adoptRef(*new CurlRequest(request, &client, shouldSuspend, enableMultipart, captureMetrics, messageQueue));
+        return adoptRef(*new CurlRequest(request, &client, sessionID, shouldSuspend, enableMultipart, captureMetrics, messageQueue));
     }
 
     virtual ~CurlRequest() = default;
@@ -105,7 +106,7 @@ private:
         FinishTransfer
     };
 
-    CurlRequest(const ResourceRequest&, CurlRequestClient*, ShouldSuspend, EnableMultipart, CaptureNetworkLoadMetrics, MessageQueue<Function<void()>>*);
+    CurlRequest(const ResourceRequest&, CurlRequestClient*, PAL::SessionID, ShouldSuspend, EnableMultipart, CaptureNetworkLoadMetrics, MessageQueue<Function<void()>>*);
 
     void retain() override { ref(); }
     void release() override { deref(); }
index 7be00ad..47b3783 100644 (file)
@@ -154,7 +154,8 @@ Ref<CurlRequest> ResourceHandle::createCurlRequest(ResourceRequest&& request, Re
     }
 
     CurlRequest::ShouldSuspend shouldSuspend = d->m_defersLoading ? CurlRequest::ShouldSuspend::Yes : CurlRequest::ShouldSuspend::No;
-    auto curlRequest = CurlRequest::create(request, *delegate(), shouldSuspend, CurlRequest::EnableMultipart::Yes, CurlRequest::CaptureNetworkLoadMetrics::Basic, d->m_messageQueue);
+    // FIXME: Use a correct sessionID.
+    auto curlRequest = CurlRequest::create(request, *delegate(), PAL::SessionID::emptySessionID(), shouldSuspend, CurlRequest::EnableMultipart::Yes, CurlRequest::CaptureNetworkLoadMetrics::Basic, d->m_messageQueue);
     
     return curlRequest;
 }
index f0193d8..8e4424e 100644 (file)
@@ -621,7 +621,7 @@ ExceptionOr<void> XMLHttpRequest::createRequest()
     if (m_async) {
         m_progressEventThrottle.dispatchProgressEvent(eventNames().loadstartEvent);
         if (!m_uploadComplete && m_uploadListenerFlag)
-            m_upload->dispatchProgressEvent(eventNames().loadstartEvent, 0, request.httpBody()->lengthInBytes());
+            m_upload->dispatchProgressEvent(eventNames().loadstartEvent, 0, request.httpBody()->lengthInBytes(scriptExecutionContext()->sessionID()));
 
         if (readyState() != OPENED || !m_sendFlag || m_loader)
             return { };
index 4556673..19acb63 100644 (file)
@@ -1,5 +1,29 @@
 2019-08-14  Youenn Fablet  <youenn@apple.com>
 
+        ThreadableBlobRegistry::blobSize should take a SessionID as parameter
+        https://bugs.webkit.org/show_bug.cgi?id=200671
+
+        Reviewed by Alex Christensen.
+
+        Update WebCacheStorageConnection to implement sessionID getter.
+        Update NetworkConnectionToWebProcess to get a sessionID as parameter to blobSize computation.
+
+        * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
+        (WebKit::NetworkDataTaskCurl::createCurlRequest):
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::blobSize):
+        (WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        * NetworkProcess/NetworkProcessPlatformStrategies.cpp:
+        (WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):
+        * WebProcess/Cache/WebCacheStorageConnection.h:
+        * WebProcess/FileAPI/BlobRegistryProxy.cpp:
+        (WebKit::BlobRegistryProxy::blobSize):
+        * WebProcess/FileAPI/BlobRegistryProxy.h:
+
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
         Remove SessionID default constructor
         https://bugs.webkit.org/show_bug.cgi?id=200669
 
index 2e4f53d..1f1004e 100644 (file)
@@ -627,20 +627,17 @@ void NetworkConnectionToWebProcess::unregisterBlobURL(PAL::SessionID sessionID,
     session->blobRegistry().unregisterBlobURL(url);
 }
 
-void NetworkConnectionToWebProcess::blobSize(const URL& url, CompletionHandler<void(uint64_t)>&& completionHandler)
+void NetworkConnectionToWebProcess::blobSize(PAL::SessionID sessionID, const URL& url, CompletionHandler<void(uint64_t)>&& completionHandler)
 {
-    auto* blobRegistry = networkProcess().blobRegistry(*this);
-    if (!blobRegistry)
-        return;
-
-    completionHandler(blobRegistry->blobSize(url));
+    auto* session = networkProcess().networkSession(sessionID);
+    completionHandler(session ? session->blobRegistry().blobSize(url) : 0);
 }
 
 void NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles(PAL::SessionID sessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
 {
     auto* session = networkProcess().networkSession(sessionID);
     if (!session)
-        return;
+        return completionHandler({ });
 
     Vector<RefPtr<BlobDataFileReference>> fileReferences;
     for (auto& url : blobURLs)
index 8fe9f32..9286733 100644 (file)
@@ -186,7 +186,7 @@ private:
     void registerBlobURLFromURL(PAL::SessionID, const URL&, const URL& srcURL);
     void registerBlobURLOptionallyFileBacked(PAL::SessionID, const URL&, const URL& srcURL, const String& fileBackedPath, const String& contentType);
     void registerBlobURLForSlice(PAL::SessionID, const URL&, const URL& srcURL, int64_t start, int64_t end);
-    void blobSize(const URL&, CompletionHandler<void(uint64_t)>&&);
+    void blobSize(PAL::SessionID, const URL&, CompletionHandler<void(uint64_t)>&&);
     void unregisterBlobURL(PAL::SessionID, const URL&);
     void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&&);
 
index 1e77c8a..4b1189b 100644 (file)
@@ -47,7 +47,7 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver {
     RegisterBlobURLOptionallyFileBacked(PAL::SessionID sessionID, URL url, URL srcURL, String fileBackedPath, String contentType)
     RegisterBlobURLForSlice(PAL::SessionID sessionID, URL url, URL srcURL, int64_t start, int64_t end)
     UnregisterBlobURL(PAL::SessionID sessionID, URL url)
-    BlobSize(URL url) -> (uint64_t resultSize) Synchronous
+    BlobSize(PAL::SessionID sessionID, URL url) -> (uint64_t resultSize) Synchronous
     WriteBlobsToTemporaryFiles(PAL::SessionID sessionID, Vector<String> blobURLs) -> (Vector<String> fileNames) Async
 
     SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
index 0c846db..4672b3e 100644 (file)
@@ -58,7 +58,7 @@ BlobRegistry* NetworkProcessPlatformStrategies::createBlobRegistry()
         void registerBlobURLOptionallyFileBacked(PAL::SessionID, const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType) final { ASSERT_NOT_REACHED(); }
         void registerBlobURLForSlice(PAL::SessionID, const URL&, const URL& srcURL, long long start, long long end) final { ASSERT_NOT_REACHED(); }
         void unregisterBlobURL(PAL::SessionID, const URL&) final { ASSERT_NOT_REACHED(); }
-        unsigned long long blobSize(const URL&) final { ASSERT_NOT_REACHED(); return 0; }
+        unsigned long long blobSize(PAL::SessionID, const URL&) final { ASSERT_NOT_REACHED(); return 0; }
         void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final { ASSERT_NOT_REACHED(); }
     };
     static NeverDestroyed<EmptyBlobRegistry> blobRegistry;
index 24eb8f7..eb5570c 100644 (file)
@@ -128,7 +128,7 @@ Ref<CurlRequest> NetworkDataTaskCurl::createCurlRequest(ResourceRequest&& reques
     // Creates a CurlRequest in suspended state.
     // Then, NetworkDataTaskCurl::resume() will be called and communication resumes.
     const auto captureMetrics = shouldCaptureExtraNetworkLoadMetrics() ? CurlRequest::CaptureNetworkLoadMetrics::Extended : CurlRequest::CaptureNetworkLoadMetrics::Basic;
-    return CurlRequest::create(request, *this, CurlRequest::ShouldSuspend::Yes, CurlRequest::EnableMultipart::No, captureMetrics);
+    return CurlRequest::create(request, *this, m_session->sessionID(), CurlRequest::ShouldSuspend::Yes, CurlRequest::EnableMultipart::No, captureMetrics);
 }
 
 void NetworkDataTaskCurl::curlDidSendData(CurlRequest&, unsigned long long totalBytesSent, unsigned long long totalBytesExpectedToSend)
index 4e58afc..3e4d439 100644 (file)
@@ -67,6 +67,8 @@ private:
     void engineRepresentation(CompletionHandler<void(const String&)>&&) final;
     void updateQuotaBasedOnSpaceUsage(const WebCore::ClientOrigin&) final;
 
+    PAL::SessionID sessionID() const final { return m_sessionID; }
+
     WebCacheStorageProvider& m_provider;
     PAL::SessionID m_sessionID;
 };
index 2f3b6ba..7811207 100644 (file)
@@ -73,10 +73,10 @@ void BlobRegistryProxy::registerBlobURLForSlice(PAL::SessionID sessionID, const
     WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLForSlice(sessionID, url, srcURL, start, end), 0);
 }
 
-unsigned long long BlobRegistryProxy::blobSize(const URL& url)
+unsigned long long BlobRegistryProxy::blobSize(PAL::SessionID sessionID, const URL& url)
 {
     uint64_t resultSize;
-    if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::BlobSize(url), Messages::NetworkConnectionToWebProcess::BlobSize::Reply(resultSize), 0))
+    if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::BlobSize(sessionID, url), Messages::NetworkConnectionToWebProcess::BlobSize::Reply(resultSize), 0))
         return 0;
     return resultSize;
 }
index d766158..80924c0 100644 (file)
@@ -37,7 +37,7 @@ public:
     void registerBlobURLOptionallyFileBacked(PAL::SessionID, const URL&, const URL& srcURL, RefPtr<WebCore::BlobDataFileReference>&&, const String& contentType) final;
     void unregisterBlobURL(PAL::SessionID, const URL&) final;
     void registerBlobURLForSlice(PAL::SessionID, const URL&, const URL& srcURL, long long start, long long end) final;
-    unsigned long long blobSize(const URL&) final;
+    unsigned long long blobSize(PAL::SessionID, const URL&) final;
     void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final;
 };
 
index 0c44c2c..89ee3cb 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
+        ThreadableBlobRegistry::blobSize should take a SessionID as parameter
+        https://bugs.webkit.org/show_bug.cgi?id=200671
+
+        Reviewed by ALex Christensen.
+
+        * WebCoreSupport/WebPlatformStrategies.mm:
+
 2019-08-13  Youenn Fablet  <youenn@apple.com>
 
         Blob registries should be keyed by session IDs
index def98da..089e6a7 100644 (file)
@@ -70,7 +70,7 @@ private:
     void registerBlobURLOptionallyFileBacked(PAL::SessionID, const URL& url, const URL& srcURL, RefPtr<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerBlobURLOptionallyFileBacked(url, srcURL, WTFMove(reference), contentType); }
     void registerBlobURLForSlice(PAL::SessionID, const URL& url, const URL& srcURL, long long start, long long end) final { m_blobRegistry.registerBlobURLForSlice(url, srcURL, start, end); }
     void unregisterBlobURL(PAL::SessionID, const URL& url) final { m_blobRegistry.unregisterBlobURL(url); }
-    unsigned long long blobSize(const URL& url) final { return m_blobRegistry.blobSize(url); }
+    unsigned long long blobSize(PAL::SessionID, const URL& url) final { return m_blobRegistry.blobSize(url); }
     void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler) final { m_blobRegistry.writeBlobsToTemporaryFiles(blobURLs, WTFMove(completionHandler)); }
 
     BlobRegistryImpl* blobRegistryImpl() final { return &m_blobRegistry; }
index ab935e0..ca14599 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
+        ThreadableBlobRegistry::blobSize should take a SessionID as parameter
+        https://bugs.webkit.org/show_bug.cgi?id=200671
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebPlatformStrategies.cpp:
+
 2019-08-13  Youenn Fablet  <youenn@apple.com>
 
         Blob registries should be keyed by session IDs
index b7690df..5da9ed4 100644 (file)
@@ -68,7 +68,7 @@ private:
     void registerBlobURLOptionallyFileBacked(PAL::SessionID, const URL& url, const URL& srcURL, RefPtr<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerBlobURLOptionallyFileBacked(url, srcURL, WTFMove(reference), contentType); }
     void registerBlobURLForSlice(PAL::SessionID, const URL& url, const URL& srcURL, long long start, long long end) final { m_blobRegistry.registerBlobURLForSlice(url, srcURL, start, end); }
     void unregisterBlobURL(PAL::SessionID, const URL& url) final { m_blobRegistry.unregisterBlobURL(url); }
-    unsigned long long blobSize(const URL& url) final { return m_blobRegistry.blobSize(url); }
+    unsigned long long blobSize(PAL::SessionID, const URL& url) final { return m_blobRegistry.blobSize(url); }
     void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler) final { m_blobRegistry.writeBlobsToTemporaryFiles(blobURLs, WTFMove(completionHandler)); }
 
     BlobRegistryImpl* blobRegistryImpl() final { return &m_blobRegistry; }