Blob registries should be keyed by session IDs
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2019 10:06:16 +0000 (10:06 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2019 10:06:16 +0000 (10:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200567
Source/WebCore:

<rdar://problem/54120212>

Reviewed by Alex Christensen.

Pass session IDs to all BlobRegistry methods in particular ThreadableLoaderRegistry.
The only exception is blobSize which should be dealt with a follow-up patch.
blobSize blob registry is retrieved from the connection -> sessionID map in Network Process.
Covered by existing tests.

* Modules/fetch/FetchLoader.cpp:
(WebCore::FetchLoader::~FetchLoader):
(WebCore::FetchLoader::startLoadingBlobURL):
* Modules/fetch/FetchLoader.h:
* fileapi/FileReaderLoader.cpp:
(WebCore::FileReaderLoader::~FileReaderLoader):
(WebCore::FileReaderLoader::start):
* fileapi/FileReaderLoader.h:
* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::ThreadableBlobRegistry::registerFileBlobURL):
(WebCore::ThreadableBlobRegistry::registerBlobURL):
(WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked):
* fileapi/ThreadableBlobRegistry.h:
* html/PublicURLManager.cpp:
* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::extendBlobURLLifetimeIfNecessary const):
* platform/network/BlobRegistry.h:
* platform/network/BlobRegistryImpl.cpp:
(WebCore::createBlobResourceHandle):
(WebCore::loadBlobResourceSynchronously):
(WebCore::BlobRegistryImpl::filesInBlob const):
* platform/network/BlobRegistryImpl.h:
* platform/network/FormData.cpp:
(WebCore::appendBlobResolved):
(WebCore::FormData::resolveBlobReferences):
* platform/network/FormData.h:
* platform/network/cf/FormDataStreamCFNet.cpp:
(WebCore::createHTTPBodyCFReadStream):
* platform/network/soup/ResourceRequest.h:
* platform/network/soup/ResourceRequestSoup.cpp:
(WebCore::ResourceRequest::updateSoupMessageBody const):
(WebCore::ResourceRequest::updateSoupMessage const):

Source/WebKit:

<rdar://problem/54120212>

Reviewed by Alex Christensen.

Move blob registry to NetworkSession so that it is partitioned by session ID.
In case session ID is not given through IPC, use the connection as key to get the network session.
This is used for blobSize.

* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
* NetworkProcess/Downloads/DownloadManager.h:
* NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
* NetworkProcess/FileAPI/NetworkBlobRegistry.h: Removed.
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::didClose):
(WebKit::NetworkConnectionToWebProcess::resolveBlobReferences):
(WebKit::NetworkConnectionToWebProcess::registerFileBlobURL):
(WebKit::NetworkConnectionToWebProcess::registerBlobURL):
(WebKit::NetworkConnectionToWebProcess::registerBlobURLFromURL):
(WebKit::NetworkConnectionToWebProcess::registerBlobURLOptionallyFileBacked):
(WebKit::NetworkConnectionToWebProcess::registerBlobURLForSlice):
(WebKit::NetworkConnectionToWebProcess::unregisterBlobURL):
(WebKit::NetworkConnectionToWebProcess::blobSize):
(WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
(WebKit::NetworkConnectionToWebProcess::filesInBlob):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::blobRegistry):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcessPlatformStrategies.cpp:
(WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::startNetworkLoad):
* NetworkProcess/NetworkSession.h:
(WebKit::NetworkSession::blobRegistry):
* NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::createRequest):
* NetworkProcess/soup/NetworkSessionSoup.cpp:
(WebKit::NetworkSessionSoup::createWebSocketTask):
* Sources.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/FileAPI/BlobRegistryProxy.cpp:
(WebKit::BlobRegistryProxy::registerFileBlobURL):
(WebKit::BlobRegistryProxy::registerBlobURL):
(WebKit::BlobRegistryProxy::registerBlobURLOptionallyFileBacked):
(WebKit::BlobRegistryProxy::unregisterBlobURL):
(WebKit::BlobRegistryProxy::registerBlobURLForSlice):
(WebKit::BlobRegistryProxy::writeBlobsToTemporaryFiles):
* WebProcess/FileAPI/BlobRegistryProxy.h:
* WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::writeBlobsToTemporaryFiles):
* WebProcess/Network/NetworkProcessConnection.h:

Source/WebKitLegacy/mac:

Reviewed by Alex Christensen.

* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::createBlobRegistry):
Ignore sessionID parameter for WK1.

Source/WebKitLegacy/win:

<rdar://problem/54120212>

Reviewed by Alex Christensen.

* WebCoreSupport/WebPlatformStrategies.cpp:
(WebPlatformStrategies::createBlobRegistry):

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

46 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchLoader.cpp
Source/WebCore/Modules/fetch/FetchLoader.h
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/fileapi/Blob.cpp
Source/WebCore/fileapi/File.cpp
Source/WebCore/fileapi/FileReaderLoader.cpp
Source/WebCore/fileapi/FileReaderLoader.h
Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
Source/WebCore/fileapi/ThreadableBlobRegistry.h
Source/WebCore/html/PublicURLManager.cpp
Source/WebCore/loader/PolicyChecker.cpp
Source/WebCore/platform/network/BlobRegistry.h
Source/WebCore/platform/network/BlobRegistryImpl.cpp
Source/WebCore/platform/network/BlobRegistryImpl.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/CurlFormDataStream.cpp
Source/WebCore/platform/network/soup/ResourceRequest.h
Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp
Source/WebKit/NetworkProcess/Downloads/DownloadManager.h
Source/WebKit/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp
Source/WebKit/NetworkProcess/FileAPI/NetworkBlobRegistry.h [deleted file]
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/NetworkProcess/NetworkSession.h
Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp
Source/WebKit/Sources.txt
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.cpp
Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.h
Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp

index a11cad2..8747511 100644 (file)
@@ -1,5 +1,51 @@
 2019-08-13  Youenn Fablet  <youenn@apple.com>
 
+        Blob registries should be keyed by session IDs
+        https://bugs.webkit.org/show_bug.cgi?id=200567
+        <rdar://problem/54120212>
+
+        Reviewed by Alex Christensen.
+
+        Pass session IDs to all BlobRegistry methods in particular ThreadableLoaderRegistry.
+        The only exception is blobSize which should be dealt with a follow-up patch.
+        blobSize blob registry is retrieved from the connection -> sessionID map in Network Process.
+        Covered by existing tests.
+
+        * Modules/fetch/FetchLoader.cpp:
+        (WebCore::FetchLoader::~FetchLoader):
+        (WebCore::FetchLoader::startLoadingBlobURL):
+        * Modules/fetch/FetchLoader.h:
+        * fileapi/FileReaderLoader.cpp:
+        (WebCore::FileReaderLoader::~FileReaderLoader):
+        (WebCore::FileReaderLoader::start):
+        * fileapi/FileReaderLoader.h:
+        * fileapi/ThreadableBlobRegistry.cpp:
+        (WebCore::ThreadableBlobRegistry::registerFileBlobURL):
+        (WebCore::ThreadableBlobRegistry::registerBlobURL):
+        (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked):
+        * fileapi/ThreadableBlobRegistry.h:
+        * html/PublicURLManager.cpp:
+        * loader/PolicyChecker.cpp:
+        (WebCore::PolicyChecker::extendBlobURLLifetimeIfNecessary const):
+        * platform/network/BlobRegistry.h:
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::createBlobResourceHandle):
+        (WebCore::loadBlobResourceSynchronously):
+        (WebCore::BlobRegistryImpl::filesInBlob const):
+        * platform/network/BlobRegistryImpl.h:
+        * platform/network/FormData.cpp:
+        (WebCore::appendBlobResolved):
+        (WebCore::FormData::resolveBlobReferences):
+        * platform/network/FormData.h:
+        * platform/network/cf/FormDataStreamCFNet.cpp:
+        (WebCore::createHTTPBodyCFReadStream):
+        * platform/network/soup/ResourceRequest.h:
+        * platform/network/soup/ResourceRequestSoup.cpp:
+        (WebCore::ResourceRequest::updateSoupMessageBody const):
+        (WebCore::ResourceRequest::updateSoupMessage const):
+
+2019-08-13  Youenn Fablet  <youenn@apple.com>
+
         User Agent and SessionID should be given to NetworkRTCProvider to set up the correct proxy information
         https://bugs.webkit.org/show_bug.cgi?id=200583
 
index c0dbf5f..d8db90c 100644 (file)
@@ -48,7 +48,7 @@ namespace WebCore {
 FetchLoader::~FetchLoader()
 {
     if (!m_urlForReading.isEmpty())
-        ThreadableBlobRegistry::unregisterBlobURL(m_urlForReading);
+        ThreadableBlobRegistry::unregisterBlobURL(*m_sessionID, m_urlForReading);
 }
 
 void FetchLoader::start(ScriptExecutionContext& context, const Blob& blob)
@@ -64,7 +64,8 @@ void FetchLoader::startLoadingBlobURL(ScriptExecutionContext& context, const URL
         return;
     }
 
-    ThreadableBlobRegistry::registerBlobURL(context.securityOrigin(), m_urlForReading, blobURL);
+    m_sessionID = context.sessionID();
+    ThreadableBlobRegistry::registerBlobURL(*m_sessionID, context.securityOrigin(), m_urlForReading, blobURL);
 
     ResourceRequest request(m_urlForReading);
     request.setInitiatorIdentifier(context.resourceRequestIdentifier());
index 4011b37..b6c6508 100644 (file)
@@ -67,6 +67,7 @@ private:
     FetchBodyConsumer* m_consumer;
     bool m_isStarted { false };
     URL m_urlForReading;
+    Optional<PAL::SessionID> m_sessionID;
 };
 
 } // namespace WebCore
index 1d0054c..114ff3c 100644 (file)
@@ -3569,13 +3569,12 @@ Vector<String> SerializedScriptValue::blobURLsIsolatedCopy() const
     return result;
 }
 
-void SerializedScriptValue::writeBlobsToDiskForIndexedDB(PAL::SessionID, CompletionHandler<void(IDBValue&&)>&& completionHandler)
+void SerializedScriptValue::writeBlobsToDiskForIndexedDB(PAL::SessionID sessionID, CompletionHandler<void(IDBValue&&)>&& completionHandler)
 {
     ASSERT(isMainThread());
     ASSERT(hasBlobURLs());
 
-    // FIXME: Get the right blob registry from the given sessionID.
-    blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)] (auto&& blobFilePaths) mutable {
+    blobRegistry().writeBlobsToTemporaryFiles(sessionID, m_blobURLs, [completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)] (auto&& blobFilePaths) mutable {
         ASSERT(isMainThread());
 
         if (blobFilePaths.isEmpty()) {
@@ -3586,7 +3585,7 @@ void SerializedScriptValue::writeBlobsToDiskForIndexedDB(PAL::SessionID, Complet
         }
 
         ASSERT(m_blobURLs.size() == blobFilePaths.size());
-        
+
         completionHandler({ *this, m_blobURLs, blobFilePaths });
     });
 }
index 2a06d03..d891c70 100644 (file)
@@ -58,12 +58,12 @@ public:
 void BlobURLRegistry::registerURL(ScriptExecutionContext& context, const URL& publicURL, URLRegistrable& blob)
 {
     ASSERT(&blob.registry() == this);
-    ThreadableBlobRegistry::registerBlobURL(context.securityOrigin(), publicURL, static_cast<Blob&>(blob).url());
+    ThreadableBlobRegistry::registerBlobURL(context.sessionID(), context.securityOrigin(), publicURL, static_cast<Blob&>(blob).url());
 }
 
-void BlobURLRegistry::unregisterURL(ScriptExecutionContext&, const URL& url)
+void BlobURLRegistry::unregisterURL(ScriptExecutionContext& context, const URL& url)
 {
-    ThreadableBlobRegistry::unregisterBlobURL(url);
+    ThreadableBlobRegistry::unregisterBlobURL(context.sessionID(), url);
 }
 
 URLRegistry& BlobURLRegistry::registry()
@@ -84,7 +84,7 @@ Blob::Blob(PAL::SessionID sessionID)
     , m_size(0)
 {
     m_internalURL = BlobURL::createInternalURL();
-    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { },  { });
+    ThreadableBlobRegistry::registerBlobURL(m_sessionID, m_internalURL, { },  { });
 }
 
 Blob::Blob(PAL::SessionID sessionID, Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)
@@ -101,7 +101,7 @@ Blob::Blob(PAL::SessionID sessionID, Vector<BlobPartVariant>&& blobPartVariants,
         );
     }
 
-    ThreadableBlobRegistry::registerBlobURL(m_internalURL, builder.finalize(), m_type);
+    ThreadableBlobRegistry::registerBlobURL(m_sessionID, m_internalURL, builder.finalize(), m_type);
 }
 
 Blob::Blob(PAL::SessionID sessionID, const SharedBuffer& buffer, const String& contentType)
@@ -115,7 +115,7 @@ Blob::Blob(PAL::SessionID sessionID, const SharedBuffer& buffer, const String& c
     Vector<BlobPart> blobParts;
     blobParts.append(BlobPart(WTFMove(data)));
     m_internalURL = BlobURL::createInternalURL();
-    ThreadableBlobRegistry::registerBlobURL(m_internalURL, WTFMove(blobParts), contentType);
+    ThreadableBlobRegistry::registerBlobURL(m_sessionID, m_internalURL, WTFMove(blobParts), contentType);
 }
 
 Blob::Blob(PAL::SessionID sessionID, Vector<uint8_t>&& data, const String& contentType)
@@ -126,7 +126,7 @@ Blob::Blob(PAL::SessionID sessionID, Vector<uint8_t>&& data, const String& conte
     Vector<BlobPart> blobParts;
     blobParts.append(BlobPart(WTFMove(data)));
     m_internalURL = BlobURL::createInternalURL();
-    ThreadableBlobRegistry::registerBlobURL(m_internalURL, WTFMove(blobParts), contentType);
+    ThreadableBlobRegistry::registerBlobURL(m_sessionID, m_internalURL, WTFMove(blobParts), contentType);
 }
 
 Blob::Blob(ReferencingExistingBlobConstructor, const Blob& blob)
@@ -135,7 +135,7 @@ Blob::Blob(ReferencingExistingBlobConstructor, const Blob& blob)
     , m_type(blob.type())
     , m_size(blob.size())
 {
-    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { BlobPart(blob.url()) } , m_type);
+    ThreadableBlobRegistry::registerBlobURL(m_sessionID, m_internalURL, { BlobPart(blob.url()) } , m_type);
 }
 
 Blob::Blob(DeserializationContructor, PAL::SessionID sessionID, const URL& srcURL, const String& type, Optional<unsigned long long> size, const String& fileBackedPath)
@@ -145,9 +145,9 @@ Blob::Blob(DeserializationContructor, PAL::SessionID sessionID, const URL& srcUR
 {
     m_internalURL = BlobURL::createInternalURL();
     if (fileBackedPath.isEmpty())
-        ThreadableBlobRegistry::registerBlobURL(nullptr, m_internalURL, srcURL);
+        ThreadableBlobRegistry::registerBlobURL(m_sessionID, nullptr, m_internalURL, srcURL);
     else
-        ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(m_internalURL, srcURL, fileBackedPath, m_type);
+        ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(m_sessionID, m_internalURL, srcURL, fileBackedPath, m_type);
 }
 
 Blob::Blob(PAL::SessionID sessionID, const URL& srcURL, long long start, long long end, const String& type)
@@ -156,12 +156,12 @@ Blob::Blob(PAL::SessionID sessionID, const URL& srcURL, long long start, long lo
     // m_size is not necessarily equal to end - start so we do not initialize it here.
 {
     m_internalURL = BlobURL::createInternalURL();
-    ThreadableBlobRegistry::registerBlobURLForSlice(m_internalURL, srcURL, start, end);
+    ThreadableBlobRegistry::registerBlobURLForSlice(m_sessionID, m_internalURL, srcURL, start, end);
 }
 
 Blob::~Blob()
 {
-    ThreadableBlobRegistry::unregisterBlobURL(m_internalURL);
+    ThreadableBlobRegistry::unregisterBlobURL(m_sessionID, m_internalURL);
 }
 
 unsigned long long Blob::size() const
index c72723b..a8f46d1 100644 (file)
@@ -53,7 +53,7 @@ Ref<File> File::create(PAL::SessionID sessionID, const String& path, const Strin
     computeNameAndContentType(path, nameOverride, name, type);
 
     auto internalURL = BlobURL::createInternalURL();
-    ThreadableBlobRegistry::registerFileBlobURL(internalURL, path, type);
+    ThreadableBlobRegistry::registerFileBlobURL(sessionID, internalURL, path, type);
 
     return adoptRef(*new File(sessionID, WTFMove(internalURL), WTFMove(type), String { path }, WTFMove(name)));
 }
index 897155a..4dcd0dd 100644 (file)
@@ -68,7 +68,7 @@ FileReaderLoader::~FileReaderLoader()
 {
     terminate();
     if (!m_urlForReading.isEmpty())
-        ThreadableBlobRegistry::unregisterBlobURL(m_urlForReading);
+        ThreadableBlobRegistry::unregisterBlobURL(*m_sessionID, m_urlForReading);
 }
 
 void FileReaderLoader::start(ScriptExecutionContext* scriptExecutionContext, Blob& blob)
@@ -81,7 +81,8 @@ void FileReaderLoader::start(ScriptExecutionContext* scriptExecutionContext, Blo
         failed(FileError::SECURITY_ERR);
         return;
     }
-    ThreadableBlobRegistry::registerBlobURL(scriptExecutionContext->securityOrigin(), m_urlForReading, blob.url());
+    m_sessionID = scriptExecutionContext->sessionID();
+    ThreadableBlobRegistry::registerBlobURL(*m_sessionID, scriptExecutionContext->securityOrigin(), m_urlForReading, blob.url());
 
     // Construct and load the request.
     ResourceRequest request(m_urlForReading);
index 7a428be..419b209 100644 (file)
@@ -35,6 +35,7 @@
 #include <wtf/URL.h>
 #include "TextEncoding.h"
 #include "ThreadableLoaderClient.h"
+#include <pal/SessionID.h>
 #include <wtf/Forward.h>
 #include <wtf/text/WTFString.h>
 
@@ -102,6 +103,7 @@ private:
     String m_dataType;
 
     URL m_urlForReading;
+    Optional<PAL::SessionID> m_sessionID;
     RefPtr<ThreadableLoader> m_loader;
 
     RefPtr<JSC::ArrayBuffer> m_rawData;
index 5bc9baf..a95b249 100644 (file)
@@ -64,109 +64,97 @@ static ThreadSpecific<BlobUrlOriginMap>& originMap()
     return *map;
 }
 
-static void postToMainThread(CrossThreadTask&& task)
+void ThreadableBlobRegistry::registerFileBlobURL(PAL::SessionID sessionID, const URL& url, const String& path, const String& contentType)
 {
-    static std::once_flag onceFlag;
-    static CrossThreadQueue<CrossThreadTask>* queue;
-    std::call_once(onceFlag, [] {
-        queue = new CrossThreadQueue<CrossThreadTask>;
-    });
-
-    queue->append(WTFMove(task));
+    if (isMainThread()) {
+        blobRegistry().registerFileBlobURL(sessionID, url, BlobDataFileReference::create(path), contentType);
+        return;
+    }
 
-    callOnMainThread([] {
-        auto task = queue->tryGetMessage();
-        ASSERT(task);
-        task->performTask();
+    callOnMainThread([sessionID, url = url.isolatedCopy(), path = path.isolatedCopy(), contentType = contentType.isolatedCopy()] {
+        blobRegistry().registerFileBlobURL(sessionID, url, BlobDataFileReference::create(path), contentType);
     });
 }
 
-void ThreadableBlobRegistry::registerFileBlobURL(const URL& url, const String& path, const String& contentType)
-{
-    if (isMainThread())
-        blobRegistry().registerFileBlobURL(url, BlobDataFileReference::create(path), contentType);
-    else {
-        callOnMainThread([url = url.isolatedCopy(), path = path.isolatedCopy(), contentType = contentType.isolatedCopy()] {
-            blobRegistry().registerFileBlobURL(url, BlobDataFileReference::create(path), contentType);
-        });
-    }
-}
-
-void ThreadableBlobRegistry::registerBlobURL(const URL& url, Vector<BlobPart>&& blobParts, const String& contentType)
+void ThreadableBlobRegistry::registerBlobURL(PAL::SessionID sessionID, const URL& url, Vector<BlobPart>&& blobParts, const String& contentType)
 {
-    if (isMainThread())
-        blobRegistry().registerBlobURL(url, WTFMove(blobParts), contentType);
-    else {
-        for (auto& part : blobParts)
-            part.detachFromCurrentThread();
-        callOnMainThread([url = url.isolatedCopy(), blobParts = WTFMove(blobParts), contentType = contentType.isolatedCopy()]() mutable {
-            blobRegistry().registerBlobURL(url, WTFMove(blobParts), contentType);
-        });
+    if (isMainThread()) {
+        blobRegistry().registerBlobURL(sessionID, url, WTFMove(blobParts), contentType);
+        return;
     }
+    for (auto& part : blobParts)
+        part.detachFromCurrentThread();
+    callOnMainThread([sessionID, url = url.isolatedCopy(), blobParts = WTFMove(blobParts), contentType = contentType.isolatedCopy()]() mutable {
+        blobRegistry().registerBlobURL(sessionID, url, WTFMove(blobParts), contentType);
+    });
 }
 
-void ThreadableBlobRegistry::registerBlobURL(SecurityOrigin* origin, const URL& url, const URL& srcURL)
+void ThreadableBlobRegistry::registerBlobURL(PAL::SessionID sessionID, SecurityOrigin* origin, const URL& url, const URL& srcURL)
 {
     // If the blob URL contains null origin, as in the context with unique security origin or file URL, save the mapping between url and origin so that the origin can be retrived when doing security origin check.
     if (origin && BlobURL::getOrigin(url) == "null")
         originMap()->add(url.string(), origin);
 
-    if (isMainThread())
-        blobRegistry().registerBlobURL(url, srcURL);
-    else {
-        callOnMainThread([url = url.isolatedCopy(), srcURL = srcURL.isolatedCopy()] {
-            blobRegistry().registerBlobURL(url, srcURL);
-        });
+    if (isMainThread()) {
+        blobRegistry().registerBlobURL(sessionID, url, srcURL);
+        return;
     }
+
+    callOnMainThread([sessionID, url = url.isolatedCopy(), srcURL = srcURL.isolatedCopy()] {
+        blobRegistry().registerBlobURL(sessionID, url, srcURL);
+    });
 }
 
-void ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(const URL& url, const URL& srcURL, const String& fileBackedPath, const String& contentType)
+void ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(PAL::SessionID sessionID, const URL& url, const URL& srcURL, const String& fileBackedPath, const String& contentType)
 {
-    if (isMainThread())
-        blobRegistry().registerBlobURLOptionallyFileBacked(url, srcURL, BlobDataFileReference::create(fileBackedPath), contentType);
-    else
-        postToMainThread(createCrossThreadTask(ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked, url, srcURL, fileBackedPath, contentType));
+    if (isMainThread()) {
+        blobRegistry().registerBlobURLOptionallyFileBacked(sessionID, url, srcURL, BlobDataFileReference::create(fileBackedPath), contentType);
+        return;
+    }
+    callOnMainThread([sessionID, url = url.isolatedCopy(), srcURL = srcURL.isolatedCopy(), fileBackedPath = fileBackedPath.isolatedCopy(), contentType = contentType.isolatedCopy()] {
+        blobRegistry().registerBlobURLOptionallyFileBacked(sessionID, url, srcURL, BlobDataFileReference::create(fileBackedPath), contentType);
+    });
 }
 
-void ThreadableBlobRegistry::registerBlobURLForSlice(const URL& newURL, const URL& srcURL, long long start, long long end)
+void ThreadableBlobRegistry::registerBlobURLForSlice(PAL::SessionID sessionID, const URL& newURL, const URL& srcURL, long long start, long long end)
 {
-    if (isMainThread())
-        blobRegistry().registerBlobURLForSlice(newURL, srcURL, start, end);
-    else {
-        callOnMainThread([newURL = newURL.isolatedCopy(), srcURL = srcURL.isolatedCopy(), start, end] {
-            blobRegistry().registerBlobURLForSlice(newURL, srcURL, start, end);
-        });
+    if (isMainThread()) {
+        blobRegistry().registerBlobURLForSlice(sessionID, newURL, srcURL, start, end);
+        return;
     }
+
+    callOnMainThread([sessionID, newURL = newURL.isolatedCopy(), srcURL = srcURL.isolatedCopy(), start, end] {
+        blobRegistry().registerBlobURLForSlice(sessionID, newURL, srcURL, start, end);
+    });
 }
 
 unsigned long long ThreadableBlobRegistry::blobSize(const URL& url)
 {
-    unsigned long long resultSize;
     if (isMainThread())
+        return blobRegistry().blobSize(url);
+
+    unsigned long long resultSize;
+    BinarySemaphore semaphore;
+    callOnMainThread([url = url.isolatedCopy(), &semaphore, &resultSize] {
         resultSize = blobRegistry().blobSize(url);
-    else {
-        BinarySemaphore semaphore;
-        callOnMainThread([url = url.isolatedCopy(), &semaphore, &resultSize] {
-            resultSize = blobRegistry().blobSize(url);
-            semaphore.signal();
-        });
-        semaphore.wait();
-    }
+        semaphore.signal();
+    });
+    semaphore.wait();
     return resultSize;
 }
 
-void ThreadableBlobRegistry::unregisterBlobURL(const URL& url)
+void ThreadableBlobRegistry::unregisterBlobURL(PAL::SessionID sessionID, const URL& url)
 {
     if (BlobURL::getOrigin(url) == "null")
         originMap()->remove(url.string());
 
-    if (isMainThread())
-        blobRegistry().unregisterBlobURL(url);
-    else {
-        callOnMainThread([url = url.isolatedCopy()] {
-            blobRegistry().unregisterBlobURL(url);
-        });
+    if (isMainThread()) {
+        blobRegistry().unregisterBlobURL(sessionID, url);
+        return;
     }
+    callOnMainThread([sessionID, url = url.isolatedCopy()] {
+        blobRegistry().unregisterBlobURL(sessionID, url);
+    });
 }
 
 RefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const URL& url)
index a9c79fe..315f5ca 100644 (file)
@@ -40,12 +40,12 @@ class SecurityOrigin;
 
 class ThreadableBlobRegistry {
 public:
-    static void registerFileBlobURL(const URL&, const String& path, const String& contentType);
-    static void registerBlobURL(const URL&, Vector<BlobPart>&& blobParts, const String& contentType);
-    static void registerBlobURL(SecurityOrigin*, const URL&, const URL& srcURL);
-    static void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, const String& fileBackedPath, const String& contentType);
-    static void registerBlobURLForSlice(const URL& newURL, const URL& srcURL, long long start, long long end);
-    static void unregisterBlobURL(const URL&);
+    static void registerFileBlobURL(PAL::SessionID, const URL&, const String& path, const String& contentType);
+    static void registerBlobURL(PAL::SessionID, const URL&, Vector<BlobPart>&& blobParts, const String& contentType);
+    static void registerBlobURL(PAL::SessionID, SecurityOrigin*, const URL&, const URL& srcURL);
+    static void registerBlobURLOptionallyFileBacked(PAL::SessionID, const URL&, const URL& srcURL, const String& fileBackedPath, const String& contentType);
+    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&);
 
index d5b9bed..7bebc7a 100644 (file)
@@ -26,8 +26,9 @@
 
 #include "config.h"
 #include "PublicURLManager.h"
-#include <wtf/URL.h>
+
 #include "URLRegistry.h"
+#include <wtf/URL.h>
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
index 8b91e1c..5363703 100644 (file)
@@ -106,10 +106,11 @@ CompletionHandlerCallingScope PolicyChecker::extendBlobURLLifetimeIfNecessary(Re
 
     // Create a new temporary blobURL in case this one gets revoked during the asynchronous navigation policy decision.
     URL temporaryBlobURL = BlobURL::createPublicURL(&m_frame.document()->securityOrigin());
-    blobRegistry().registerBlobURL(temporaryBlobURL, request.url());
+    auto sessionID = m_frame.document()->sessionID();
+    blobRegistry().registerBlobURL(sessionID, temporaryBlobURL, request.url());
     request.setURL(temporaryBlobURL);
-    return CompletionHandler<void()>([temporaryBlobURL = WTFMove(temporaryBlobURL)] {
-        blobRegistry().unregisterBlobURL(temporaryBlobURL);
+    return CompletionHandler<void()>([sessionID, temporaryBlobURL = WTFMove(temporaryBlobURL)] {
+        blobRegistry().unregisterBlobURL(sessionID, temporaryBlobURL);
     });
 }
 
index 2e893bd..660a796 100644 (file)
@@ -31,6 +31,7 @@
 
 #pragma once
 
+#include <pal/SessionID.h>
 #include <wtf/Forward.h>
 
 namespace WebCore {
@@ -38,6 +39,7 @@ namespace WebCore {
 class BlobDataFileReference;
 class BlobPart;
 class BlobRegistry;
+class BlobRegistryImpl;
 
 WEBCORE_EXPORT BlobRegistry& blobRegistry();
 
@@ -46,27 +48,27 @@ class WEBCORE_EXPORT BlobRegistry {
 public:
 
     // Registers a blob URL referring to the specified file.
-    virtual void registerFileBlobURL(const URL&, Ref<BlobDataFileReference>&&, const String& contentType) = 0;
+    virtual void registerFileBlobURL(PAL::SessionID, const URL&, Ref<BlobDataFileReference>&&, const String& contentType) = 0;
 
     // Registers a blob URL referring to the specified blob data.
-    virtual void registerBlobURL(const URL&, Vector<BlobPart>&&, const String& contentType) = 0;
+    virtual void registerBlobURL(PAL::SessionID, const URL&, Vector<BlobPart>&&, const String& contentType) = 0;
     
     // Registers a new blob URL referring to the blob data identified by the specified srcURL.
-    virtual void registerBlobURL(const URL&, const URL& srcURL) = 0;
+    virtual void registerBlobURL(PAL::SessionID, const URL&, const URL& srcURL) = 0;
 
     // Registers a new blob URL referring to the blob data identified by the specified srcURL or, if none found, referring to the file found at the given path.
-    virtual void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType) = 0;
+    virtual void registerBlobURLOptionallyFileBacked(PAL::SessionID, const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType) = 0;
 
     // Negative start and end values select from the end.
-    virtual void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) = 0;
+    virtual void registerBlobURLForSlice(PAL::SessionID, const URL&, const URL& srcURL, long long start, long long end) = 0;
 
-    virtual void unregisterBlobURL(const URL&) = 0;
+    virtual void unregisterBlobURL(PAL::SessionID, const URL&) = 0;
 
     virtual unsigned long long blobSize(const URL&) = 0;
 
-    virtual void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) = 0;
+    virtual void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) = 0;
 
-    virtual bool isBlobRegistryImpl() const { return false; }
+    virtual BlobRegistryImpl* blobRegistryImpl() { return nullptr; }
 
 protected:
     virtual ~BlobRegistry();
index 129095b..5b22bd1 100644 (file)
@@ -54,12 +54,12 @@ BlobRegistryImpl::~BlobRegistryImpl() = default;
 
 static Ref<ResourceHandle> createBlobResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
 {
-    return static_cast<BlobRegistryImpl&>(blobRegistry()).createResourceHandle(request, client);
+    return blobRegistry().blobRegistryImpl()->createResourceHandle(request, client);
 }
 
 static void loadBlobResourceSynchronously(NetworkingContext*, const ResourceRequest& request, StoredCredentialsPolicy, ResourceError& error, ResourceResponse& response, Vector<char>& data)
 {
-    BlobData* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(request.url());
+    auto* blobData = blobRegistry().blobRegistryImpl()->getBlobDataFromURL(request.url());
     BlobResourceHandle::loadResourceSynchronously(blobData, request, error, response, data);
 }
 
@@ -343,4 +343,19 @@ void BlobRegistryImpl::writeBlobToFilePath(const URL& blobURL, const String& pat
     });
 }
 
+Vector<RefPtr<BlobDataFileReference>> BlobRegistryImpl::filesInBlob(const URL& url) const
+{
+    auto* blobData = getBlobDataFromURL(url);
+    if (!blobData)
+        return { };
+
+    Vector<RefPtr<BlobDataFileReference>> result;
+    for (const BlobDataItem& item : blobData->items()) {
+        if (item.type() == BlobDataItem::Type::File)
+            result.append(item.file());
+    }
+
+    return result;
+}
+
 } // namespace WebCore
index e151d3a..db9d6df 100644 (file)
@@ -46,7 +46,7 @@ class ResourceRequest;
 class ThreadSafeDataBuffer;
 
 // BlobRegistryImpl is not thread-safe. It should only be called from main thread.
-class WEBCORE_EXPORT BlobRegistryImpl final : public BlobRegistry {
+class WEBCORE_EXPORT BlobRegistryImpl {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     virtual ~BlobRegistryImpl();
@@ -58,17 +58,16 @@ public:
 
     void appendStorageItems(BlobData*, const BlobDataItemList&, long long offset, long long length);
 
-    void registerFileBlobURL(const URL&, Ref<BlobDataFileReference>&&, const String& contentType) override;
-    void registerBlobURL(const URL&, Vector<BlobPart>&&, const String& contentType) override;
-    void registerBlobURL(const URL&, const URL& srcURL) override;
-    void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType) override;
-    void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) override;
-    void unregisterBlobURL(const URL&) override;
-    bool isBlobRegistryImpl() const override { return true; }
+    void registerFileBlobURL(const URL&, Ref<BlobDataFileReference>&&, const String& contentType);
+    void registerBlobURL(const URL&, Vector<BlobPart>&&, const String& contentType);
+    void registerBlobURL(const URL&, const URL& srcURL);
+    void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType);
+    void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end);
+    void unregisterBlobURL(const URL&);
 
-    unsigned long long blobSize(const URL&) override;
+    unsigned long long blobSize(const URL&);
 
-    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) override;
+    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&);
 
     struct BlobForFileWriting {
         String blobURL;
@@ -76,6 +75,7 @@ public:
     };
 
     bool populateBlobsForFileWriting(const Vector<String>& blobURLs, Vector<BlobForFileWriting>&);
+    Vector<RefPtr<BlobDataFileReference>> filesInBlob(const URL&) const;
 
 private:
     HashMap<String, RefPtr<BlobData>> m_blobs;
index d6f2916..d71b1ed 100644 (file)
@@ -286,14 +286,14 @@ String FormData::flattenToString() const
     return Latin1Encoding().decode(reinterpret_cast<const char*>(bytes.data()), bytes.size());
 }
 
-static void appendBlobResolved(BlobRegistry& blobRegistry, FormData& formData, const URL& url)
+static void appendBlobResolved(BlobRegistryImpl* blobRegistry, FormData& formData, const URL& url)
 {
-    if (!blobRegistry.isBlobRegistryImpl()) {
+    if (!blobRegistry) {
         LOG_ERROR("Tried to resolve a blob without a usable registry");
         return;
     }
 
-    auto* blobData = static_cast<BlobRegistryImpl&>(blobRegistry).getBlobDataFromURL(url);
+    auto* blobData = blobRegistry->getBlobDataFromURL(url);
     if (!blobData) {
         LOG_ERROR("Could not get blob data from a registry");
         return;
@@ -310,7 +310,7 @@ static void appendBlobResolved(BlobRegistry& blobRegistry, FormData& formData, c
     }
 }
 
-Ref<FormData> FormData::resolveBlobReferences(BlobRegistry& blobRegistry)
+Ref<FormData> FormData::resolveBlobReferences(BlobRegistryImpl* blobRegistry)
 {
     // First check if any blobs needs to be resolved, or we can take the fast path.
     bool hasBlob = false;
index 20bf62e..7c686e8 100644 (file)
@@ -29,7 +29,7 @@
 
 namespace WebCore {
 
-class BlobRegistry;
+class BlobRegistryImpl;
 class DOMFormData;
 class File;
 class SharedBuffer;
@@ -219,7 +219,7 @@ public:
 
     // Resolve all blob references so we only have file and data.
     // If the FormData has no blob references to resolve, this is returned.
-    WEBCORE_EXPORT Ref<FormData> resolveBlobReferences(BlobRegistry&);
+    WEBCORE_EXPORT Ref<FormData> resolveBlobReferences(BlobRegistryImpl*);
 
     WEBCORE_EXPORT FormDataForUpload prepareForUpload();
 
index 47f1541..53fea05 100644 (file)
@@ -372,7 +372,7 @@ static void formEventCallback(CFReadStreamRef stream, CFStreamEventType type, vo
 
 RetainPtr<CFReadStreamRef> createHTTPBodyCFReadStream(FormData& formData)
 {
-    auto resolvedFormData = formData.resolveBlobReferences(blobRegistry());
+    auto resolvedFormData = formData.resolveBlobReferences(blobRegistry().blobRegistryImpl());
     auto dataForUpload = resolvedFormData->prepareForUpload();
 
     // Precompute the content length so CFNetwork doesn't use chunked mode.
index dd63a4a..2bba5a6 100644 (file)
@@ -51,7 +51,7 @@ CurlFormDataStream::CurlFormDataStream(const FormData* formData)
     m_formData = formData->isolatedCopy();
 
     // Resolve the blob elements so the formData can correctly report it's size.
-    m_formData = m_formData->resolveBlobReferences(blobRegistry());
+    m_formData = m_formData->resolveBlobReferences(blobRegistry().blobRegistryImpl());
 }
 
 CurlFormDataStream::~CurlFormDataStream()
index 31c6a0e..e98ba18 100644 (file)
@@ -33,6 +33,8 @@
 
 namespace WebCore {
 
+    class BlobRegistryImpl;
+
     class ResourceRequest : public ResourceRequestBase {
     public:
         ResourceRequest(const String& url)
@@ -87,7 +89,7 @@ namespace WebCore {
 
         void updateSoupMessageHeaders(SoupMessageHeaders*) const;
         void updateFromSoupMessageHeaders(SoupMessageHeaders*);
-        void updateSoupMessage(SoupMessage*) const;
+        void updateSoupMessage(SoupMessage*, BlobRegistryImpl&) const;
         void updateFromSoupMessage(SoupMessage*);
         void updateSoupRequest(SoupRequest*) const;
         void updateFromSoupRequest(SoupRequest*);
@@ -111,7 +113,7 @@ namespace WebCore {
         Optional<PageIdentifier> m_initiatingPageID;
 
         void updateSoupMessageMembers(SoupMessage*) const;
-        void updateSoupMessageBody(SoupMessage*) const;
+        void updateSoupMessageBody(SoupMessage*, BlobRegistryImpl&) const;
         void doUpdatePlatformRequest() { }
         void doUpdateResourceRequest() { }
         void doUpdatePlatformHTTPBody() { }
index 9601e66..335b3d9 100644 (file)
@@ -68,7 +68,7 @@ static uint64_t appendEncodedBlobItemToSoupMessageBody(SoupMessage* soupMessage,
     return 0;
 }
 
-void ResourceRequest::updateSoupMessageBody(SoupMessage* soupMessage) const
+void ResourceRequest::updateSoupMessageBody(SoupMessage* soupMessage, BlobRegistryImpl& blobRegistry) const
 {
     auto* formData = httpBody();
     if (!formData || formData->isEmpty())
@@ -92,7 +92,7 @@ void ResourceRequest::updateSoupMessageBody(SoupMessage* soupMessage) const
                         soup_message_body_append_buffer(soupMessage->request_body, soupBuffer.get());
                 }
             }, [&] (const FormDataElement::EncodedBlobData& blob) {
-                if (auto* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(blob.url)) {
+                if (auto* blobData = blobRegistry.getBlobDataFromURL(blob.url)) {
                     for (const auto& item : blobData->items())
                         bodySize += appendEncodedBlobItemToSoupMessageBody(soupMessage, item);
                 }
@@ -140,7 +140,7 @@ void ResourceRequest::updateFromSoupMessageHeaders(SoupMessageHeaders* soupHeade
         m_httpHeaderFields.set(String(headerName), String(headerValue));
 }
 
-void ResourceRequest::updateSoupMessage(SoupMessage* soupMessage) const
+void ResourceRequest::updateSoupMessage(SoupMessage* soupMessage, BlobRegistryImpl& blobRegistry) const
 {
     g_object_set(soupMessage, SOUP_MESSAGE_METHOD, httpMethod().ascii().data(), NULL);
 
@@ -148,7 +148,7 @@ void ResourceRequest::updateSoupMessage(SoupMessage* soupMessage) const
     soup_message_set_uri(soupMessage, uri.get());
 
     updateSoupMessageMembers(soupMessage);
-    updateSoupMessageBody(soupMessage);
+    updateSoupMessageBody(soupMessage, blobRegistry);
 }
 
 void ResourceRequest::updateFromSoupMessage(SoupMessage* soupMessage)
index 2b80c8c..1a4e4e5 100644 (file)
@@ -1,5 +1,63 @@
 2019-08-13  Youenn Fablet  <youenn@apple.com>
 
+        Blob registries should be keyed by session IDs
+        https://bugs.webkit.org/show_bug.cgi?id=200567
+        <rdar://problem/54120212>
+
+        Reviewed by Alex Christensen.
+
+        Move blob registry to NetworkSession so that it is partitioned by session ID.
+        In case session ID is not given through IPC, use the connection as key to get the network session.
+        This is used for blobSize.
+
+        * NetworkProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::startDownload):
+        * NetworkProcess/Downloads/DownloadManager.h:
+        * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
+        * NetworkProcess/FileAPI/NetworkBlobRegistry.h: Removed.
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::didClose):
+        (WebKit::NetworkConnectionToWebProcess::resolveBlobReferences):
+        (WebKit::NetworkConnectionToWebProcess::registerFileBlobURL):
+        (WebKit::NetworkConnectionToWebProcess::registerBlobURL):
+        (WebKit::NetworkConnectionToWebProcess::registerBlobURLFromURL):
+        (WebKit::NetworkConnectionToWebProcess::registerBlobURLOptionallyFileBacked):
+        (WebKit::NetworkConnectionToWebProcess::registerBlobURLForSlice):
+        (WebKit::NetworkConnectionToWebProcess::unregisterBlobURL):
+        (WebKit::NetworkConnectionToWebProcess::blobSize):
+        (WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
+        (WebKit::NetworkConnectionToWebProcess::filesInBlob):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::blobRegistry):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcessPlatformStrategies.cpp:
+        (WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::startNetworkLoad):
+        * NetworkProcess/NetworkSession.h:
+        (WebKit::NetworkSession::blobRegistry):
+        * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
+        (WebKit::NetworkDataTaskSoup::createRequest):
+        * NetworkProcess/soup/NetworkSessionSoup.cpp:
+        (WebKit::NetworkSessionSoup::createWebSocketTask):
+        * Sources.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/FileAPI/BlobRegistryProxy.cpp:
+        (WebKit::BlobRegistryProxy::registerFileBlobURL):
+        (WebKit::BlobRegistryProxy::registerBlobURL):
+        (WebKit::BlobRegistryProxy::registerBlobURLOptionallyFileBacked):
+        (WebKit::BlobRegistryProxy::unregisterBlobURL):
+        (WebKit::BlobRegistryProxy::registerBlobURLForSlice):
+        (WebKit::BlobRegistryProxy::writeBlobsToTemporaryFiles):
+        * WebProcess/FileAPI/BlobRegistryProxy.h:
+        * WebProcess/Network/NetworkProcessConnection.cpp:
+        (WebKit::NetworkProcessConnection::writeBlobsToTemporaryFiles):
+        * WebProcess/Network/NetworkProcessConnection.h:
+
+2019-08-13  Youenn Fablet  <youenn@apple.com>
+
         User Agent and SessionID should be given to NetworkRTCProvider to set up the correct proxy information
         https://bugs.webkit.org/show_bug.cgi?id=200583
 
index 80fe1a2..fffb473 100644 (file)
@@ -27,7 +27,6 @@
 #include "DownloadManager.h"
 
 #include "Download.h"
-#include "NetworkBlobRegistry.h"
 #include "NetworkConnectionToWebProcess.h"
 #include "NetworkLoad.h"
 #include "NetworkSession.h"
@@ -55,10 +54,10 @@ void DownloadManager::startDownload(PAL::SessionID sessionID, DownloadID downloa
     parameters.request = request;
     parameters.clientCredentialPolicy = ClientCredentialPolicy::MayAskClientForCredentials;
     if (request.url().protocolIsBlob())
-        parameters.blobFileReferences = client().networkBlobRegistry().filesInBlob(request.url());
+        parameters.blobFileReferences = client().networkSession(sessionID)->blobRegistry().filesInBlob(request.url());
     parameters.storedCredentialsPolicy = sessionID.isEphemeral() ? StoredCredentialsPolicy::DoNotUse : StoredCredentialsPolicy::Use;
 
-    m_pendingDownloads.add(downloadID, std::make_unique<PendingDownload>(m_client.parentProcessConnectionForDownloads(), WTFMove(parameters), downloadID, *networkSession, &client().networkBlobRegistry().blobRegistry(), suggestedName));
+    m_pendingDownloads.add(downloadID, std::make_unique<PendingDownload>(m_client.parentProcessConnectionForDownloads(), WTFMove(parameters), downloadID, *networkSession, &client().networkSession(sessionID)->blobRegistry(), suggestedName));
 }
 
 void DownloadManager::dataTaskBecameDownloadTask(DownloadID downloadID, std::unique_ptr<Download>&& download)
index 386c9e7..74ed13b 100644 (file)
@@ -55,7 +55,6 @@ namespace WebKit {
 
 class AuthenticationManager;
 class Download;
-class NetworkBlobRegistry;
 class NetworkConnectionToWebProcess;
 class NetworkLoad;
 class PendingDownload;
@@ -75,7 +74,6 @@ public:
         virtual AuthenticationManager& downloadsAuthenticationManager() = 0;
         virtual void pendingDownloadCanceled(DownloadID) = 0;
         virtual NetworkSession* networkSession(const PAL::SessionID&) const = 0;
-        virtual NetworkBlobRegistry& networkBlobRegistry() = 0;
         virtual void ref() const = 0;
         virtual void deref() const = 0;
         virtual uint32_t downloadMonitorSpeedMultiplier() const = 0;
index 63998d5..764ae94 100644 (file)
@@ -166,20 +166,4 @@ Vector<RefPtr<BlobDataFileReference>> NetworkBlobRegistry::filesInBlob(NetworkCo
     return filesInBlob(url);
 }
 
-Vector<RefPtr<BlobDataFileReference>> NetworkBlobRegistry::filesInBlob(const URL& url)
-{
-    ASSERT(m_blobRegistry.isBlobRegistryImpl());
-    BlobData* blobData = m_blobRegistry.getBlobDataFromURL(url);
-    if (!blobData)
-        return { };
-
-    Vector<RefPtr<BlobDataFileReference>> result;
-    for (const BlobDataItem& item : blobData->items()) {
-        if (item.type() == BlobDataItem::Type::File)
-            result.append(item.file());
-    }
-
-    return result;
-}
-
 }
diff --git a/Source/WebKit/NetworkProcess/FileAPI/NetworkBlobRegistry.h b/Source/WebKit/NetworkProcess/FileAPI/NetworkBlobRegistry.h
deleted file mode 100644 (file)
index b64cfed..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <WebCore/BlobRegistryImpl.h>
-#include <wtf/Function.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/URLHash.h>
-
-namespace WebCore {
-class BlobDataFileReference;
-class BlobPart;
-}
-
-namespace WebKit {
-
-class NetworkConnectionToWebProcess;
-class SandboxExtension;
-
-class NetworkBlobRegistry {
-WTF_MAKE_NONCOPYABLE(NetworkBlobRegistry);
-public:
-    NetworkBlobRegistry();
-    ~NetworkBlobRegistry();
-
-    void registerFileBlobURL(NetworkConnectionToWebProcess&, const URL&, const String& path, RefPtr<SandboxExtension>&&, const String& contentType);
-    void registerBlobURL(NetworkConnectionToWebProcess&, const URL&, Vector<WebCore::BlobPart>&&, const String& contentType);
-    void registerBlobURL(NetworkConnectionToWebProcess&, const URL&, const URL& srcURL, bool shouldBypassConnectionCheck);
-    void registerBlobURLOptionallyFileBacked(NetworkConnectionToWebProcess&, const URL&, const URL& srcURL, const String& fileBackedPath, const String& contentType);
-    void registerBlobURLForSlice(NetworkConnectionToWebProcess&, const URL&, const URL& srcURL, int64_t start, int64_t end);
-    void unregisterBlobURL(NetworkConnectionToWebProcess&, const URL&);
-    uint64_t blobSize(NetworkConnectionToWebProcess&, const URL&);
-    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&&);
-    void writeBlobToFilePath(const URL& blobURL, const String& path, CompletionHandler<void(bool success)>&&);
-
-    void connectionToWebProcessDidClose(NetworkConnectionToWebProcess&);
-
-    Vector<RefPtr<WebCore::BlobDataFileReference>> filesInBlob(NetworkConnectionToWebProcess&, const URL&);
-    Vector<RefPtr<WebCore::BlobDataFileReference>> filesInBlob(const URL&);
-    
-    WebCore::BlobRegistryImpl& blobRegistry() { return m_blobRegistry; }
-
-private:
-    typedef HashMap<NetworkConnectionToWebProcess*, HashSet<URL>> BlobForConnectionMap;
-    BlobForConnectionMap m_blobsForConnection;
-    WebCore::BlobRegistryImpl m_blobRegistry;
-};
-
-}
index 9b1b9b8..2e4f53d 100644 (file)
@@ -301,7 +301,6 @@ void NetworkConnectionToWebProcess::didClose(IPC::Connection& connection)
 
     m_networkProcess->webProcessWasDisconnected(connection);
 
-    m_networkProcess->networkBlobRegistry().connectionToWebProcessDidClose(*this);
     m_networkProcess->removeNetworkConnectionToWebProcess(*this);
 
 #if USE(LIBWEBRTC)
@@ -374,13 +373,19 @@ void NetworkConnectionToWebProcess::endSuspension()
 
 Vector<RefPtr<WebCore::BlobDataFileReference>> NetworkConnectionToWebProcess::resolveBlobReferences(const NetworkResourceLoadParameters& parameters)
 {
+    auto* session = networkProcess().networkSession(parameters.sessionID);
+    if (!session)
+        return { };
+
+    auto& blobRegistry = session->blobRegistry();
+
     Vector<RefPtr<WebCore::BlobDataFileReference>> files;
     if (auto* body = parameters.request.httpBody()) {
         for (auto& element : body->elements()) {
             if (auto* blobData = WTF::get_if<FormDataElement::EncodedBlobData>(element.data))
-                files.appendVector(m_networkProcess->networkBlobRegistry().filesInBlob(*this, blobData->url));
+                files.appendVector(blobRegistry.filesInBlob(blobData->url));
         }
-        const_cast<WebCore::ResourceRequest&>(parameters.request).setHTTPBody(body->resolveBlobReferences(m_networkProcess->networkBlobRegistry().blobRegistry()));
+        const_cast<WebCore::ResourceRequest&>(parameters.request).setHTTPBody(body->resolveBlobReferences(&blobRegistry));
     }
 
     return files;
@@ -568,67 +573,89 @@ void NetworkConnectionToWebProcess::deleteCookie(PAL::SessionID sessionID, const
     storageSession(networkProcess(), sessionID).deleteCookie(url, cookieName);
 }
 
-void NetworkConnectionToWebProcess::registerFileBlobURL(const URL& url, const String& path, SandboxExtension::Handle&& extensionHandle, const String& contentType)
+void NetworkConnectionToWebProcess::registerFileBlobURL(PAL::SessionID sessionID, const URL& url, const String& path, SandboxExtension::Handle&& extensionHandle, const String& contentType)
 {
-    m_networkProcess->networkBlobRegistry().registerFileBlobURL(*this, url, path, SandboxExtension::create(WTFMove(extensionHandle)), contentType);
+    auto* session = networkProcess().networkSession(sessionID);
+    if (!session)
+        return;
+
+    session->blobRegistry().registerFileBlobURL(url, BlobDataFileReferenceWithSandboxExtension::create(path, SandboxExtension::create(WTFMove(extensionHandle))), contentType);
 }
 
-void NetworkConnectionToWebProcess::registerBlobURL(const URL& url, Vector<BlobPart>&& blobParts, const String& contentType)
+void NetworkConnectionToWebProcess::registerBlobURL(PAL::SessionID sessionID, const URL& url, Vector<BlobPart>&& blobParts, const String& contentType)
 {
-    m_networkProcess->networkBlobRegistry().registerBlobURL(*this, url, WTFMove(blobParts), contentType);
+    auto* session = networkProcess().networkSession(sessionID);
+    if (!session)
+        return;
+
+    session->blobRegistry().registerBlobURL(url, WTFMove(blobParts), contentType);
 }
 
-void NetworkConnectionToWebProcess::registerBlobURLFromURL(const URL& url, const URL& srcURL, bool shouldBypassConnectionCheck)
+void NetworkConnectionToWebProcess::registerBlobURLFromURL(PAL::SessionID sessionID, const URL& url, const URL& srcURL)
 {
-    m_networkProcess->networkBlobRegistry().registerBlobURL(*this, url, srcURL, shouldBypassConnectionCheck);
+    auto* session = networkProcess().networkSession(sessionID);
+    if (!session)
+        return;
+
+    session->blobRegistry().registerBlobURL(url, srcURL);
 }
 
-void NetworkConnectionToWebProcess::registerBlobURLOptionallyFileBacked(const URL& url, const URL& srcURL, const String& fileBackedPath, const String& contentType)
+void NetworkConnectionToWebProcess::registerBlobURLOptionallyFileBacked(PAL::SessionID sessionID, const URL& url, const URL& srcURL, const String& fileBackedPath, const String& contentType)
 {
-    m_networkProcess->networkBlobRegistry().registerBlobURLOptionallyFileBacked(*this, url, srcURL, fileBackedPath, contentType);
+    auto* session = networkProcess().networkSession(sessionID);
+    if (!session)
+        return;
+
+    session->blobRegistry().registerBlobURLOptionallyFileBacked(url, srcURL, BlobDataFileReferenceWithSandboxExtension::create(fileBackedPath, nullptr), contentType);
 }
 
-void NetworkConnectionToWebProcess::registerBlobURLForSlice(const URL& url, const URL& srcURL, int64_t start, int64_t end)
+void NetworkConnectionToWebProcess::registerBlobURLForSlice(PAL::SessionID sessionID, const URL& url, const URL& srcURL, int64_t start, int64_t end)
 {
-    m_networkProcess->networkBlobRegistry().registerBlobURLForSlice(*this, url, srcURL, start, end);
+    auto* session = networkProcess().networkSession(sessionID);
+    if (!session)
+        return;
+
+    session->blobRegistry().registerBlobURLForSlice(url, srcURL, start, end);
 }
 
-void NetworkConnectionToWebProcess::unregisterBlobURL(const URL& url)
+void NetworkConnectionToWebProcess::unregisterBlobURL(PAL::SessionID sessionID, const URL& url)
 {
-    m_networkProcess->networkBlobRegistry().unregisterBlobURL(*this, url);
+    auto* session = networkProcess().networkSession(sessionID);
+    if (!session)
+        return;
+
+    session->blobRegistry().unregisterBlobURL(url);
 }
 
 void NetworkConnectionToWebProcess::blobSize(const URL& url, CompletionHandler<void(uint64_t)>&& completionHandler)
 {
-    completionHandler(m_networkProcess->networkBlobRegistry().blobSize(*this, url));
+    auto* blobRegistry = networkProcess().blobRegistry(*this);
+    if (!blobRegistry)
+        return;
+
+    completionHandler(blobRegistry->blobSize(url));
 }
 
-void NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+void NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles(PAL::SessionID sessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
 {
+    auto* session = networkProcess().networkSession(sessionID);
+    if (!session)
+        return;
+
     Vector<RefPtr<BlobDataFileReference>> fileReferences;
     for (auto& url : blobURLs)
-        fileReferences.appendVector(m_networkProcess->networkBlobRegistry().filesInBlob(*this, { { }, url }));
+        fileReferences.appendVector(session->blobRegistry().filesInBlob({ { }, url }));
 
     for (auto& file : fileReferences)
         file->prepareForFileAccess();
 
-    m_networkProcess->networkBlobRegistry().writeBlobsToTemporaryFiles(blobURLs, [fileReferences = WTFMove(fileReferences), completionHandler = WTFMove(completionHandler)](auto&& fileNames) mutable {
+    session->blobRegistry().writeBlobsToTemporaryFiles(blobURLs, [fileReferences = WTFMove(fileReferences), completionHandler = WTFMove(completionHandler)](auto&& fileNames) mutable {
         for (auto& file : fileReferences)
             file->revokeFileAccess();
         completionHandler(WTFMove(fileNames));
     });
 }
 
-Vector<RefPtr<WebCore::BlobDataFileReference>> NetworkConnectionToWebProcess::filesInBlob(const URL& url)
-{
-    return m_networkProcess->networkBlobRegistry().filesInBlob(*this, url);
-}
-
-WebCore::BlobRegistryImpl& NetworkConnectionToWebProcess::blobRegistry()
-{
-    return m_networkProcess->networkBlobRegistry().blobRegistry();
-}
-
 void NetworkConnectionToWebProcess::setCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
 {
     m_captureExtraNetworkLoadMetricsEnabled = enabled;
index d7b2f1b..8fe9f32 100644 (file)
@@ -138,8 +138,6 @@ public:
     Optional<NetworkActivityTracker> startTrackingResourceLoad(WebCore::PageIdentifier, ResourceLoadIdentifier resourceID, bool isMainResource, const PAL::SessionID&);
     void stopTrackingResourceLoad(ResourceLoadIdentifier resourceID, NetworkActivityTracker::CompletionCode);
 
-    WebCore::BlobRegistryImpl& blobRegistry();
-    Vector<RefPtr<WebCore::BlobDataFileReference>> filesInBlob(const URL&);
     Vector<RefPtr<WebCore::BlobDataFileReference>> resolveBlobReferences(const NetworkResourceLoadParameters&);
 
     void webPageWasAdded(PAL::SessionID, WebCore::PageIdentifier, WebCore::PageIdentifier oldPageID);
@@ -183,14 +181,14 @@ private:
     void getRawCookies(PAL::SessionID, const URL& firstParty, const WebCore::SameSiteInfo&, const URL&, Optional<uint64_t> frameID, Optional<WebCore::PageIdentifier>, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&&);
     void deleteCookie(PAL::SessionID, const URL&, const String& cookieName);
 
-    void registerFileBlobURL(const URL&, const String& path, SandboxExtension::Handle&&, const String& contentType);
-    void registerBlobURL(const URL&, Vector<WebCore::BlobPart>&&, const String& contentType);
-    void registerBlobURLFromURL(const URL&, const URL& srcURL, bool shouldBypassConnectionCheck);
-    void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, const String& fileBackedPath, const String& contentType);
-    void registerBlobURLForSlice(const URL&, const URL& srcURL, int64_t start, int64_t end);
+    void registerFileBlobURL(PAL::SessionID, const URL&, const String& path, SandboxExtension::Handle&&, const String& contentType);
+    void registerBlobURL(PAL::SessionID, const URL&, Vector<WebCore::BlobPart>&&, const String& contentType);
+    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 unregisterBlobURL(const URL&);
-    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&&);
+    void unregisterBlobURL(PAL::SessionID, const URL&);
+    void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&&);
 
     void setCaptureExtraNetworkLoadMetricsEnabled(bool);
 
index fa2c31a..1e77c8a 100644 (file)
@@ -41,14 +41,14 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver {
     GetRawCookies(PAL::SessionID sessionID, URL firstParty, struct WebCore::SameSiteInfo sameSiteInfo, URL url, Optional<uint64_t> frameID, Optional<WebCore::PageIdentifier> pageID) -> (Vector<WebCore::Cookie> cookies) Synchronous
     DeleteCookie(PAL::SessionID sessionID, URL url, String cookieName)
 
-    RegisterFileBlobURL(URL url, String path, WebKit::SandboxExtension::Handle extensionHandle, String contentType)
-    RegisterBlobURL(URL url, Vector<WebCore::BlobPart> blobParts, String contentType)
-    RegisterBlobURLFromURL(URL url, URL srcURL, bool shouldBypassConnectionCheck)
-    RegisterBlobURLOptionallyFileBacked(URL url, URL srcURL, String fileBackedPath, String contentType)
-    RegisterBlobURLForSlice(URL url, URL srcURL, int64_t start, int64_t end)
-    UnregisterBlobURL(URL url)
+    RegisterFileBlobURL(PAL::SessionID sessionID, URL url, String path, WebKit::SandboxExtension::Handle extensionHandle, String contentType)
+    RegisterBlobURL(PAL::SessionID sessionID, URL url, Vector<WebCore::BlobPart> blobParts, String contentType)
+    RegisterBlobURLFromURL(PAL::SessionID sessionID, URL url, URL srcURL)
+    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
-    WriteBlobsToTemporaryFiles(Vector<String> blobURLs) -> (Vector<String> fileNames) Async
+    WriteBlobsToTemporaryFiles(PAL::SessionID sessionID, Vector<String> blobURLs) -> (Vector<String> fileNames) Async
 
     SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
 
index 9cb4a92..a98f70f 100644 (file)
@@ -612,6 +612,13 @@ void NetworkProcess::destroySession(const PAL::SessionID& sessionID)
     m_storageQuotaManagers.remove(sessionID);
 }
 
+BlobRegistryImpl* NetworkProcess::blobRegistry(NetworkConnectionToWebProcess& connection)
+{
+    // FIXME: Deprecate this method and use sessionID -> NetworkSession -> blob registry.
+    auto* session = networkSessionByConnection(connection.connection());
+    return session ? &session->blobRegistry() : nullptr;
+}
+
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 void NetworkProcess::dumpResourceLoadStatistics(PAL::SessionID sessionID, CompletionHandler<void(String)>&& completionHandler)
 {
index fb7a6cd..9486904 100644 (file)
@@ -29,7 +29,6 @@
 #include "CacheModel.h"
 #include "DownloadManager.h"
 #include "LocalStorageDatabaseTracker.h"
-#include "NetworkBlobRegistry.h"
 #include "NetworkContentRuleListManager.h"
 #include "NetworkHTTPSUpgradeChecker.h"
 #include "SandboxExtension.h"
@@ -327,7 +326,7 @@ public:
     void removeCacheEngine(const PAL::SessionID&);
     void requestStorageSpace(PAL::SessionID, const WebCore::ClientOrigin&, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired, CompletionHandler<void(Optional<uint64_t>)>&&);
 
-    NetworkBlobRegistry& networkBlobRegistry() override { return m_networkBlobRegistry; }
+    WebCore::BlobRegistryImpl* blobRegistry(NetworkConnectionToWebProcess&);
 
     void storeAdClickAttribution(PAL::SessionID, WebCore::AdClickAttribution&&);
     void dumpAdClickAttribution(PAL::SessionID, CompletionHandler<void(String)>&&);
@@ -498,7 +497,6 @@ private:
     HashMap<PAL::SessionID, std::unique_ptr<NetworkSession>> m_networkSessions;
     HashMap<PAL::SessionID, std::unique_ptr<WebCore::NetworkStorageSession>> m_networkStorageSessions;
     mutable std::unique_ptr<WebCore::NetworkStorageSession> m_defaultNetworkStorageSession;
-    NetworkBlobRegistry m_networkBlobRegistry;
 
 #if PLATFORM(COCOA)
     void platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters&);
index f234e29..0c846db 100644 (file)
@@ -52,15 +52,14 @@ BlobRegistry* NetworkProcessPlatformStrategies::createBlobRegistry()
 {
     using namespace WebCore;
     class EmptyBlobRegistry : public WebCore::BlobRegistry {
-        void registerFileBlobURL(const URL&, Ref<BlobDataFileReference>&&, const String& contentType) final { ASSERT_NOT_REACHED(); }
-        void registerBlobURL(const URL&, Vector<BlobPart>&&, const String& contentType) final { ASSERT_NOT_REACHED(); }
-        void registerBlobURL(const URL&, const URL& srcURL) final { ASSERT_NOT_REACHED(); }
-        void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType) final { ASSERT_NOT_REACHED(); }
-        void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) final { ASSERT_NOT_REACHED(); }
-        void unregisterBlobURL(const URL&) final { ASSERT_NOT_REACHED(); }
+        void registerFileBlobURL(PAL::SessionID, const URL&, Ref<BlobDataFileReference>&&, const String& contentType) final { ASSERT_NOT_REACHED(); }
+        void registerBlobURL(PAL::SessionID, const URL&, Vector<BlobPart>&&, const String& contentType) final { ASSERT_NOT_REACHED(); }
+        void registerBlobURL(PAL::SessionID, const URL&, const URL& srcURL) final { ASSERT_NOT_REACHED(); }
+        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; }
-        void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final { ASSERT_NOT_REACHED(); }
-        bool isBlobRegistryImpl() const { return false; }
+        void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final { ASSERT_NOT_REACHED(); }
     };
     static NeverDestroyed<EmptyBlobRegistry> blobRegistry;
     return &blobRegistry.get();
index ce06e36..4782ef1 100644 (file)
@@ -301,9 +301,6 @@ void NetworkResourceLoader::startNetworkLoad(ResourceRequest&& request, FirstLoa
     if (parameters.storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::Use && m_networkLoadChecker)
         parameters.storedCredentialsPolicy = m_networkLoadChecker->storedCredentialsPolicy();
 
-    if (request.url().protocolIsBlob())
-        parameters.blobFileReferences = m_connection->filesInBlob(originalRequest().url());
-
     auto* networkSession = m_connection->networkProcess().networkSession(parameters.sessionID);
     if (!networkSession && parameters.sessionID.isEphemeral()) {
         m_connection->networkProcess().addWebsiteDataStore(WebsiteDataStoreParameters::privateSessionParameters(parameters.sessionID));
@@ -317,8 +314,11 @@ void NetworkResourceLoader::startNetworkLoad(ResourceRequest&& request, FirstLoa
         return;
     }
 
+    if (request.url().protocolIsBlob())
+        parameters.blobFileReferences = networkSession->blobRegistry().filesInBlob(originalRequest().url());
+
     parameters.request = WTFMove(request);
-    m_networkLoad = std::make_unique<NetworkLoad>(*this, &m_connection->blobRegistry(), WTFMove(parameters), *networkSession);
+    m_networkLoad = std::make_unique<NetworkLoad>(*this, &networkSession->blobRegistry(), WTFMove(parameters), *networkSession);
 
     RELEASE_LOG_IF_ALLOWED("startNetworkLoad: (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", description = %{public}s)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, m_networkLoad->description().utf8().data());
 }
index c2bf43d..c4e102e 100644 (file)
@@ -29,6 +29,7 @@
 #include "SandboxExtension.h"
 #include "WebResourceLoadStatisticsStore.h"
 #include <WebCore/AdClickAttribution.h>
+#include <WebCore/BlobRegistryImpl.h>
 #include <WebCore/RegistrableDomain.h>
 #include <pal/SessionID.h>
 #include <wtf/HashSet.h>
@@ -114,6 +115,8 @@ public:
     virtual void removeWebSocketTask(WebSocketTask&) { }
     virtual void addWebSocketTask(WebSocketTask&) { }
 
+    WebCore::BlobRegistryImpl& blobRegistry() { return m_blobRegistry; }
+
 protected:
     NetworkSession(NetworkProcess&, const NetworkSessionCreationParameters&);
 
@@ -143,6 +146,7 @@ protected:
     bool m_isInvalidated { false };
 #endif
     RefPtr<NetworkCache::Cache> m_cache;
+    WebCore::BlobRegistryImpl m_blobRegistry;
 };
 
 } // namespace WebKit
index 87e85b5..d46c503 100644 (file)
@@ -134,7 +134,7 @@ void NetworkDataTaskSoup::createRequest(ResourceRequest&& request)
 
     unsigned messageFlags = SOUP_MESSAGE_NO_REDIRECT;
 
-    m_currentRequest.updateSoupMessage(soupMessage.get());
+    m_currentRequest.updateSoupMessage(soupMessage.get(), m_session->blobRegistry());
     if (m_shouldContentSniff == ContentSniffingPolicy::DoNotSniffContent)
         soup_message_disable_feature(soupMessage.get(), SOUP_TYPE_CONTENT_SNIFFER);
     if (m_user.isEmpty() && m_password.isEmpty() && m_storedCredentialsPolicy == StoredCredentialsPolicy::DoNotUse) {
index 7355257..30fc8a5 100644 (file)
@@ -121,7 +121,7 @@ std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(NetworkSo
         return nullptr;
 
     GRefPtr<SoupMessage> soupMessage = adoptGRef(soup_message_new_from_uri(SOUP_METHOD_GET, soupURI.get()));
-    request.updateSoupMessage(soupMessage.get());
+    request.updateSoupMessage(soupMessage.get(), blobRegistry());
     if (request.url().protocolIs("wss"))
         g_signal_connect(soupMessage.get(), "network-event", G_CALLBACK(webSocketMessageNetworkEventCallback), nullptr);
     return std::make_unique<WebSocketTask>(channel, soupSession(), soupMessage.get(), protocol);
index 5b4ff69..aeb5898 100644 (file)
@@ -57,8 +57,6 @@ NetworkProcess/Downloads/DownloadMap.cpp
 NetworkProcess/Downloads/DownloadMonitor.cpp
 NetworkProcess/Downloads/PendingDownload.cpp
 
-NetworkProcess/FileAPI/NetworkBlobRegistry.cpp
-
 NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp
 
 NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp @no-unify
index a1b978c..a65c7f9 100644 (file)
                9FB5F395169E6A80002C25BF /* WKContextPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FB5F393169E6A80002C25BF /* WKContextPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A102A7081EC0EEE900D81D82 /* com.macromedia.Flash Player ESR.plugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7A5E39491D5BD8A700B4B7CE /* com.macromedia.Flash Player ESR.plugin.sb */; };
                A1046EA12079263100F0C5D8 /* WKPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = A1046E9F2079263100F0C5D8 /* WKPDFView.h */; };
-               A105D0D1212734B20034F6C7 /* NetworkBlobRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = A105D0D0212734B10034F6C7 /* NetworkBlobRegistry.h */; };
                A115DC72191D82DA00DA8072 /* _WKWebViewPrintFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */; };
                A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9FB5F393169E6A80002C25BF /* WKContextPrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKContextPrivateMac.h; path = mac/WKContextPrivateMac.h; sourceTree = "<group>"; };
                A1046E9F2079263100F0C5D8 /* WKPDFView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKPDFView.h; path = ios/WKPDFView.h; sourceTree = "<group>"; };
                A1046EA02079263100F0C5D8 /* WKPDFView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKPDFView.mm; path = ios/WKPDFView.mm; sourceTree = "<group>"; };
-               A105D0D0212734B10034F6C7 /* NetworkBlobRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkBlobRegistry.h; sourceTree = "<group>"; };
                A115DC6D191D82AB00DA8072 /* _WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKWebViewPrintFormatter.mm; sourceTree = "<group>"; };
                A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKWebViewPrintFormatter.h; sourceTree = "<group>"; };
                A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = QuickLookDocumentData.cpp; path = ios/QuickLookDocumentData.cpp; sourceTree = "<group>"; };
                E164A2F0191AF14E0010737D /* BlobDataFileReferenceWithSandboxExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobDataFileReferenceWithSandboxExtension.h; sourceTree = "<group>"; };
                E170876916D6CA6900F99226 /* BlobRegistryProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobRegistryProxy.cpp; path = WebProcess/FileAPI/BlobRegistryProxy.cpp; sourceTree = "<group>"; };
                E170876A16D6CA6900F99226 /* BlobRegistryProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobRegistryProxy.h; path = WebProcess/FileAPI/BlobRegistryProxy.h; sourceTree = "<group>"; };
-               E1798C7716E6818800240139 /* NetworkBlobRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkBlobRegistry.cpp; sourceTree = "<group>"; };
                E17AE2C116B9C139001C42F1 /* com.apple.WebKit.NetworkProcess.sb.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = com.apple.WebKit.NetworkProcess.sb.in; sourceTree = "<group>"; };
                E17AE2C216B9C63A001C42F1 /* com.apple.WebKit.NetworkProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebKit.NetworkProcess.sb; path = DerivedSources/WebKit2/com.apple.WebKit.NetworkProcess.sb; sourceTree = BUILT_PRODUCTS_DIR; };
                E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintInfo.cpp; sourceTree = "<group>"; };
                                5C1426F21C23F82D00D41183 /* CustomProtocols */,
                                5C1426F11C23F81700D41183 /* Downloads */,
                                BC82837C16B45DA500A278FE /* EntryPoint */,
-                               E1798C7616E6815500240139 /* FileAPI */,
                                939288E021404DF000EBBA33 /* IndexedDB */,
                                2DA944BB188511DD00ED86DB /* ios */,
                                510CC7DC16138E2900D03ED3 /* mac */,
                        name = FileAPI;
                        sourceTree = "<group>";
                };
-               E1798C7616E6815500240139 /* FileAPI */ = {
-                       isa = PBXGroup;
-                       children = (
-                               E1798C7716E6818800240139 /* NetworkBlobRegistry.cpp */,
-                               A105D0D0212734B10034F6C7 /* NetworkBlobRegistry.h */,
-                       );
-                       path = FileAPI;
-                       sourceTree = "<group>";
-               };
                E199875B142BF9CF00BB2DE7 /* PDF */ = {
                        isa = PBXGroup;
                        children = (
                                1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */,
                                1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */,
                                535BCB922069C49C00CCCE02 /* NetworkActivityTracker.h in Headers */,
-                               A105D0D1212734B20034F6C7 /* NetworkBlobRegistry.h in Headers */,
                                E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */,
                                E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */,
                                E489D28C1A0A2DB80078C06A /* NetworkCacheCoders.h in Headers */,
index 24e3559..2f3b6ba 100644 (file)
@@ -36,7 +36,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-void BlobRegistryProxy::registerFileBlobURL(const URL& url, Ref<BlobDataFileReference>&& file, const String& contentType)
+void BlobRegistryProxy::registerFileBlobURL(PAL::SessionID sessionID, const URL& url, Ref<BlobDataFileReference>&& file, const String& contentType)
 {
     SandboxExtension::Handle extensionHandle;
 
@@ -44,37 +44,33 @@ void BlobRegistryProxy::registerFileBlobURL(const URL& url, Ref<BlobDataFileRefe
     if (!file->path().isEmpty())
         SandboxExtension::createHandle(file->path(), SandboxExtension::Type::ReadOnly, extensionHandle);
 
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterFileBlobURL(url, file->path(), extensionHandle, contentType), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterFileBlobURL(sessionID, url, file->path(), extensionHandle, contentType), 0);
 }
 
-void BlobRegistryProxy::registerBlobURL(const URL& url, Vector<BlobPart>&& blobParts, const String& contentType)
+void BlobRegistryProxy::registerBlobURL(PAL::SessionID sessionID, const URL& url, Vector<BlobPart>&& blobParts, const String& contentType)
 {
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURL(url, blobParts, contentType), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURL(sessionID, url, blobParts, contentType), 0);
 }
 
-void BlobRegistryProxy::registerBlobURL(const URL& url, const URL& srcURL)
+void BlobRegistryProxy::registerBlobURL(PAL::SessionID sessionID, const URL& url, const URL& srcURL)
 {
-    bool shouldBypassConnectionCheck = false;
-#if ENABLE(SERVICE_WORKER)
-    shouldBypassConnectionCheck = SWContextManager::singleton().connection();
-#endif
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLFromURL { url, srcURL, shouldBypassConnectionCheck }, 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLFromURL { sessionID, url, srcURL }, 0);
 }
 
-void BlobRegistryProxy::registerBlobURLOptionallyFileBacked(const URL& url, const URL& srcURL, RefPtr<WebCore::BlobDataFileReference>&& file, const String& contentType)
+void BlobRegistryProxy::registerBlobURLOptionallyFileBacked(PAL::SessionID sessionID, const URL& url, const URL& srcURL, RefPtr<WebCore::BlobDataFileReference>&& file, const String& contentType)
 {
     ASSERT(file);
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLOptionallyFileBacked(url, srcURL, file->path(), contentType), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLOptionallyFileBacked(sessionID, url, srcURL, file->path(), contentType), 0);
 }
 
-void BlobRegistryProxy::unregisterBlobURL(const URL& url)
+void BlobRegistryProxy::unregisterBlobURL(PAL::SessionID sessionID, const URL& url)
 {
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UnregisterBlobURL(url), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UnregisterBlobURL(sessionID, url), 0);
 }
 
-void BlobRegistryProxy::registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end)
+void BlobRegistryProxy::registerBlobURLForSlice(PAL::SessionID sessionID, const URL& url, const URL& srcURL, long long start, long long end)
 {
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLForSlice(url, srcURL, start, end), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLForSlice(sessionID, url, srcURL, start, end), 0);
 }
 
 unsigned long long BlobRegistryProxy::blobSize(const URL& url)
@@ -85,9 +81,9 @@ unsigned long long BlobRegistryProxy::blobSize(const URL& url)
     return resultSize;
 }
 
-void BlobRegistryProxy::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler)
+void BlobRegistryProxy::writeBlobsToTemporaryFiles(PAL::SessionID sessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler)
 {
-    WebProcess::singleton().ensureNetworkProcessConnection().writeBlobsToTemporaryFiles(blobURLs, WTFMove(completionHandler));
+    WebProcess::singleton().ensureNetworkProcessConnection().writeBlobsToTemporaryFiles(sessionID, blobURLs, WTFMove(completionHandler));
 }
 
 }
index 6abee36..d766158 100644 (file)
@@ -31,14 +31,14 @@ namespace WebKit {
 
 class BlobRegistryProxy final : public WebCore::BlobRegistry {
 public:
-    void registerFileBlobURL(const URL&, Ref<WebCore::BlobDataFileReference>&&, const String& contentType) override;
-    void registerBlobURL(const URL&, Vector<WebCore::BlobPart>&&, const String& contentType) override;
-    void registerBlobURL(const URL&, const URL& srcURL) override;
-    void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<WebCore::BlobDataFileReference>&&, const String& contentType) override;
-    void unregisterBlobURL(const URL&) override;
-    void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) override;
-    unsigned long long blobSize(const URL&) override;
-    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) override;
+    void registerFileBlobURL(PAL::SessionID, const URL&, Ref<WebCore::BlobDataFileReference>&&, const String& contentType) final;
+    void registerBlobURL(PAL::SessionID, const URL&, Vector<WebCore::BlobPart>&&, const String& contentType) final;
+    void registerBlobURL(PAL::SessionID, const URL&, const URL& srcURL) final;
+    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;
+    void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final;
 };
 
 }
index d9adcc2..afd747a 100644 (file)
@@ -211,9 +211,9 @@ void NetworkProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::S
 {
 }
 
-void NetworkProcessConnection::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler)
+void NetworkProcessConnection::writeBlobsToTemporaryFiles(PAL::SessionID sessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler)
 {
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::WriteBlobsToTemporaryFiles(blobURLs), WTFMove(completionHandler));
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::WriteBlobsToTemporaryFiles(sessionID, blobURLs), WTFMove(completionHandler));
 }
 
 void NetworkProcessConnection::didFinishPingLoad(uint64_t pingLoadIdentifier, ResourceError&& error, ResourceResponse&& response)
index 0cde599..626dab1 100644 (file)
@@ -65,7 +65,7 @@ public:
 
     void didReceiveNetworkProcessConnectionMessage(IPC::Connection&, IPC::Decoder&);
 
-    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&);
+    void writeBlobsToTemporaryFiles(PAL::SessionID, const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&);
 
 #if ENABLE(INDEXED_DATABASE)
     WebIDBConnectionToServer* existingIDBConnectionToServerForIdentifier(uint64_t identifier) const { return m_webIDBConnectionsByIdentifier.get(identifier); };
index 6855356..0c44c2c 100644 (file)
@@ -1,3 +1,14 @@
+2019-08-13  Youenn Fablet  <youenn@apple.com>
+
+        Blob registries should be keyed by session IDs
+        https://bugs.webkit.org/show_bug.cgi?id=200567
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::createBlobRegistry):
+        Ignore sessionID parameter for WK1.
+
 2019-08-12  Chris Dumez  <cdumez@apple.com>
 
         Add threading assertions to RefCounted
index 08a9026..def98da 100644 (file)
@@ -62,9 +62,25 @@ PasteboardStrategy* WebPlatformStrategies::createPasteboardStrategy()
     return this;
 }
 
+class WebBlobRegistry final : public BlobRegistry {
+private:
+    void registerFileBlobURL(PAL::SessionID, const URL& url, Ref<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerFileBlobURL(url, WTFMove(reference), contentType); }
+    void registerBlobURL(PAL::SessionID, const URL& url, Vector<BlobPart>&& parts, const String& contentType) final { m_blobRegistry.registerBlobURL(url, WTFMove(parts), contentType); }
+    void registerBlobURL(PAL::SessionID, const URL& url, const URL& srcURL) final { m_blobRegistry.registerBlobURL(url, srcURL); }
+    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); }
+    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; }
+
+    BlobRegistryImpl m_blobRegistry;
+};
+
 BlobRegistry* WebPlatformStrategies::createBlobRegistry()
 {
-    return new WebCore::BlobRegistryImpl;
+    return new WebBlobRegistry;
 }
 
 void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteboardName)
index f51e044..ab935e0 100644 (file)
@@ -1,3 +1,14 @@
+2019-08-13  Youenn Fablet  <youenn@apple.com>
+
+        Blob registries should be keyed by session IDs
+        https://bugs.webkit.org/show_bug.cgi?id=200567
+        <rdar://problem/54120212>
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebPlatformStrategies::createBlobRegistry):
+
 2019-08-12  Youenn Fablet  <youenn@apple.com>
 
         Remove IDB-specific quota
index 98c9c09..b7690df 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "WebFrameNetworkingContext.h"
 #include "WebResourceLoadScheduler.h"
+#include <WebCore/BlobRegistry.h>
 #include <WebCore/BlobRegistryImpl.h>
 #include <WebCore/FrameLoader.h>
 #include <WebCore/NetworkStorageSession.h>
@@ -59,7 +60,23 @@ PasteboardStrategy* WebPlatformStrategies::createPasteboardStrategy()
     return nullptr;
 }
 
+class WebBlobRegistry final : public BlobRegistry {
+private:
+    void registerFileBlobURL(PAL::SessionID, const URL& url, Ref<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerFileBlobURL(url, WTFMove(reference), contentType); }
+    void registerBlobURL(PAL::SessionID, const URL& url, Vector<BlobPart>&& parts, const String& contentType) final { m_blobRegistry.registerBlobURL(url, WTFMove(parts), contentType); }
+    void registerBlobURL(PAL::SessionID, const URL& url, const URL& srcURL) final { m_blobRegistry.registerBlobURL(url, srcURL); }
+    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); }
+    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; }
+
+    BlobRegistryImpl m_blobRegistry;
+};
+
 BlobRegistry* WebPlatformStrategies::createBlobRegistry()
 {
-    return new BlobRegistryImpl;
+    return new WebBlobRegistry;
 }