Skip to content
Permalink
Browse files
Enable service worker to use cache storage api
https://bugs.webkit.org/show_bug.cgi?id=178684

Patch by Youenn Fablet <youenn@apple.com> on 2017-10-24
Reviewed by Brady Eidson.

Source/WebCore:

Test: http/tests/workers/service/service-worker-cache-api.https.html

Updated WorkerLoaderProxy so that it can create a CacheStorageConnection.
Update WorkerCacheStorageConnection to take benefit of that.
This allows creating a CacheStorageConnection based on the page for regular workers and differently for Service Worker context.

Added ServiceWorkerThreadProxy as a proxy to ServiceWorkerThread.
It is in particular responsible to do proxy for loading tasks.
It implements cache API support for service worker by creating a dedicated CacheStorageConnection.

* Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::WorkerCacheStorageConnection::create):
(WebCore::WorkerCacheStorageConnection::~WorkerCacheStorageConnection):
(WebCore::WorkerCacheStorageConnection::doOpen):
(WebCore::WorkerCacheStorageConnection::doRemove):
(WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
(WebCore::WorkerCacheStorageConnection::reference):
(WebCore::WorkerCacheStorageConnection::dereference):
(WebCore::WorkerCacheStorageConnection::doRetrieveRecords):
(WebCore::WorkerCacheStorageConnection::doBatchDeleteOperation):
(WebCore::WorkerCacheStorageConnection::doBatchPutOperation):
* WebCore.xcodeproj/project.pbxproj:
* workers/WorkerLoaderProxy.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::createCacheStorageConnection):
* workers/WorkerMessagingProxy.h:
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
* workers/service/context/ServiceWorkerThread.h:
* workers/service/context/ServiceWorkerThreadProxy.cpp: Added.
(WebCore::ServiceWorkerThreadProxy::create):
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
(WebCore::ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope):
(WebCore::ServiceWorkerThreadProxy::postTaskToLoader):
(WebCore::ServiceWorkerThreadProxy::createCacheStorageConnection):
* workers/service/context/ServiceWorkerThreadProxy.h: Added.

Source/WebKit:

Passing the WebPreferences store of the default page group of the WebProcessPool to its ServiceWorker process.
ServiceWorkerContextManager then uses it to initialize the preferences accordingly.
Patch is covered by new test which is using cache api previously disabled and now enabled through the store.

Made use of the new ServiceWorkerThreadProxy in ServiceWorkerContextManager to enable a cache storage connection.
Fixed the default size of quota in WebsiteDataStore.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::getWorkerContextProcessConnection):
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebProcess/Storage/ServiceWorkerContextManager.cpp:
(WebKit::ServiceWorkerContextManager::ServiceWorkerContextManager):
(WebKit::ServiceWorkerContextManager::updatePreferences):
(WebKit::ServiceWorkerContextManager::startServiceWorker):
(WebKit::ServiceWorkerContextManager::startFetch):
* WebProcess/Storage/ServiceWorkerContextManager.h:
(WebKit::ServiceWorkerContextManager::ServiceWorkerContextManager): Deleted.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::getWorkerContextConnection):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

LayoutTests:

* http/tests/workers/service/resources/service-worker-cache-api-worker.js: Added.
* http/tests/workers/service/resources/service-worker-cache-api.js: Added.
* http/tests/workers/service/service-worker-cache-api.https-expected.txt: Added.
* http/tests/workers/service/service-worker-cache-api.https.html: Added.

Canonical link: https://commits.webkit.org/194931@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223935 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf authored and webkit-commit-queue committed Oct 24, 2017
1 parent fd205b3 commit 8bf01d7062c10e140db5e8ebb1afdc47881b3d07
Showing with 408 additions and 68 deletions.
  1. +12 −0 LayoutTests/ChangeLog
  2. +38 −0 LayoutTests/http/tests/workers/service/resources/service-worker-cache-api-worker.js
  3. +31 −0 LayoutTests/http/tests/workers/service/resources/service-worker-cache-api.js
  4. +4 −0 LayoutTests/http/tests/workers/service/service-worker-cache-api.https-expected.txt
  5. +8 −0 LayoutTests/http/tests/workers/service/service-worker-cache-api.https.html
  6. +44 −0 Source/WebCore/ChangeLog
  7. +11 −14 Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
  8. +9 −1 Source/WebCore/WebCore.xcodeproj/project.pbxproj
  9. +22 −17 Source/WebCore/workers/WorkerLoaderProxy.h
  10. +9 −0 Source/WebCore/workers/WorkerMessagingProxy.cpp
  11. +1 −0 Source/WebCore/workers/WorkerMessagingProxy.h
  12. +7 −8 Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
  13. +2 −1 Source/WebCore/workers/service/context/ServiceWorkerThread.h
  14. +76 −0 Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
  15. +63 −0 Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h
  16. +29 −0 Source/WebKit/ChangeLog
  17. +1 −1 Source/WebKit/UIProcess/WebProcessPool.cpp
  18. +3 −3 Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
  19. +28 −13 Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp
  20. +6 −6 Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h
  21. +2 −2 Source/WebKit/WebProcess/WebProcess.cpp
  22. +1 −1 Source/WebKit/WebProcess/WebProcess.h
  23. +1 −1 Source/WebKit/WebProcess/WebProcess.messages.in
@@ -1,3 +1,15 @@
2017-10-24 Youenn Fablet <youenn@apple.com>

Enable service worker to use cache storage api
https://bugs.webkit.org/show_bug.cgi?id=178684

Reviewed by Brady Eidson.

* http/tests/workers/service/resources/service-worker-cache-api-worker.js: Added.
* http/tests/workers/service/resources/service-worker-cache-api.js: Added.
* http/tests/workers/service/service-worker-cache-api.https-expected.txt: Added.
* http/tests/workers/service/service-worker-cache-api.https.html: Added.

2017-10-24 Matt Lewis <jlewis3@apple.com>

Skipped imported/w3c/web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/011.html on High Sierra Release.
@@ -0,0 +1,38 @@
var status = "no status";
var cache;
var worker = self;

async function prepareCache()
{
status = "opening cache";
cache = await caches.open("test");
status = "creating response";
var response = new Response(new ArrayBuffer(12940), { status: 200, statusText: "OK"});
status = "filling cache";
await cache.put("/resources/square100.png", response);
status = "cache is ready";
}

function statusResponse()
{
return new Response(null, {status: 200, statusText: status});
}

self.addEventListener("fetch", (event) => {
if (event.request.url.indexOf("status") !== -1) {
event.respondWith(promise.then(statusResponse, statusResponse));
return;
}
if (!event.request.url.endsWith(".fromserviceworker")) {
state = "unknown url";
event.respondWith(new Response(null, {status: 404, statusText: "Not Found"}));
return;
}
event.respondWith(promise.then(() => {
status = event.request.url.substring(0, event.request.url.length - 18);
return caches.open("test").then((cache) => {
return cache.match(event.request.url.substring(0, event.request.url.length - 18));
});
}));
});
var promise = prepareCache();
@@ -0,0 +1,31 @@
function done()
{
finishSWTest();
}

async function logStatus()
{
var response = await fetch("status");
log("Status is " + response.statusText);
}

async function test()
{
try {
await navigator.serviceWorker.register("resources/service-worker-cache-api-worker.js", { });

await logStatus();

var response = await fetch("/resources/square100.png.fromserviceworker");
var buffer = await response.arrayBuffer();
log("Response buffer byte length is " + buffer.byteLength);

await logStatus();
} catch(e) {
await logStatus();
log("Got exception: " + e);
}
finishSWTest();
}

test();
@@ -0,0 +1,4 @@
Status is cache is ready
Response buffer byte length is 12940
Status is https://127.0.0.1:8443/resources/square100.png

@@ -0,0 +1,8 @@
<html>
<head>
<script src="resources/sw-test-pre.js"></script>
</head>
<body>
<script src="resources/service-worker-cache-api.js"></script>
</body>
</html>
@@ -1,3 +1,47 @@
2017-10-24 Youenn Fablet <youenn@apple.com>

Enable service worker to use cache storage api
https://bugs.webkit.org/show_bug.cgi?id=178684

Reviewed by Brady Eidson.

Test: http/tests/workers/service/service-worker-cache-api.https.html

Updated WorkerLoaderProxy so that it can create a CacheStorageConnection.
Update WorkerCacheStorageConnection to take benefit of that.
This allows creating a CacheStorageConnection based on the page for regular workers and differently for Service Worker context.

Added ServiceWorkerThreadProxy as a proxy to ServiceWorkerThread.
It is in particular responsible to do proxy for loading tasks.
It implements cache API support for service worker by creating a dedicated CacheStorageConnection.

* Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::WorkerCacheStorageConnection::create):
(WebCore::WorkerCacheStorageConnection::~WorkerCacheStorageConnection):
(WebCore::WorkerCacheStorageConnection::doOpen):
(WebCore::WorkerCacheStorageConnection::doRemove):
(WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
(WebCore::WorkerCacheStorageConnection::reference):
(WebCore::WorkerCacheStorageConnection::dereference):
(WebCore::WorkerCacheStorageConnection::doRetrieveRecords):
(WebCore::WorkerCacheStorageConnection::doBatchDeleteOperation):
(WebCore::WorkerCacheStorageConnection::doBatchPutOperation):
* WebCore.xcodeproj/project.pbxproj:
* workers/WorkerLoaderProxy.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::createCacheStorageConnection):
* workers/WorkerMessagingProxy.h:
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
* workers/service/context/ServiceWorkerThread.h:
* workers/service/context/ServiceWorkerThreadProxy.cpp: Added.
(WebCore::ServiceWorkerThreadProxy::create):
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
(WebCore::ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope):
(WebCore::ServiceWorkerThreadProxy::postTaskToLoader):
(WebCore::ServiceWorkerThreadProxy::createCacheStorageConnection):
* workers/service/context/ServiceWorkerThreadProxy.h: Added.

2017-10-24 Alex Christensen <achristensen@webkit.org>

Optionally store entire ResourceRequest for ping loads
@@ -91,12 +91,9 @@ static Record fromCrossThreadRecordData(CrossThreadRecordData&& data)
Ref<WorkerCacheStorageConnection> WorkerCacheStorageConnection::create(WorkerGlobalScope& scope)
{
auto connection = adoptRef(*new WorkerCacheStorageConnection(scope));
connection->m_proxy.postTaskToLoader([protectedConnection = makeRef(connection.get())](ScriptExecutionContext& context) mutable {
callOnMainThread([protectedConnection = connection.copyRef()]() mutable {
ASSERT(isMainThread());
Document& document = downcast<Document>(context);

ASSERT(document.page());
protectedConnection->m_mainThreadConnection = document.page()->cacheStorageProvider().createCacheStorageConnection(document.page()->sessionID());
protectedConnection->m_mainThreadConnection = protectedConnection->m_proxy.createCacheStorageConnection();
});
return connection;
}
@@ -111,12 +108,12 @@ WorkerCacheStorageConnection::WorkerCacheStorageConnection(WorkerGlobalScope& sc
WorkerCacheStorageConnection::~WorkerCacheStorageConnection()
{
if (m_mainThreadConnection)
m_proxy.postTaskToLoader([mainThreadConnection = WTFMove(m_mainThreadConnection)](ScriptExecutionContext&) mutable { });
callOnMainThread([mainThreadConnection = WTFMove(m_mainThreadConnection)]() mutable { });
}

void WorkerCacheStorageConnection::doOpen(uint64_t requestIdentifier, const String& origin, const String& cacheName)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), requestIdentifier, origin = origin.isolatedCopy(), cacheName = cacheName.isolatedCopy()](ScriptExecutionContext&) mutable {
callOnMainThread([this, protectedThis = makeRef(*this), requestIdentifier, origin = origin.isolatedCopy(), cacheName = cacheName.isolatedCopy()]() mutable {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -131,7 +128,7 @@ void WorkerCacheStorageConnection::doOpen(uint64_t requestIdentifier, const Stri

void WorkerCacheStorageConnection::doRemove(uint64_t requestIdentifier, uint64_t cacheIdentifier)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier](ScriptExecutionContext&) mutable {
callOnMainThread([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier]() mutable {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -147,7 +144,7 @@ void WorkerCacheStorageConnection::doRemove(uint64_t requestIdentifier, uint64_t

void WorkerCacheStorageConnection::doRetrieveCaches(uint64_t requestIdentifier, const String& origin, uint64_t updateCounter)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), requestIdentifier, origin = origin.isolatedCopy(), updateCounter](ScriptExecutionContext&) mutable {
callOnMainThread([this, protectedThis = makeRef(*this), requestIdentifier, origin = origin.isolatedCopy(), updateCounter]() mutable {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -168,7 +165,7 @@ void WorkerCacheStorageConnection::doRetrieveCaches(uint64_t requestIdentifier,

void WorkerCacheStorageConnection::reference(uint64_t cacheIdentifier)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), cacheIdentifier](ScriptExecutionContext&) {
callOnMainThread([this, protectedThis = makeRef(*this), cacheIdentifier]() {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -178,7 +175,7 @@ void WorkerCacheStorageConnection::reference(uint64_t cacheIdentifier)

void WorkerCacheStorageConnection::dereference(uint64_t cacheIdentifier)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), cacheIdentifier](ScriptExecutionContext&) {
callOnMainThread([this, protectedThis = makeRef(*this), cacheIdentifier]() {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -213,7 +210,7 @@ static inline RecordsOrError recordsOrErrorFromRecordsData(Expected<Vector<Cross

void WorkerCacheStorageConnection::doRetrieveRecords(uint64_t requestIdentifier, uint64_t cacheIdentifier, const URL& url)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier, url = url.isolatedCopy()](ScriptExecutionContext&) mutable {
callOnMainThread([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier, url = url.isolatedCopy()]() mutable {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -228,7 +225,7 @@ void WorkerCacheStorageConnection::doRetrieveRecords(uint64_t requestIdentifier,

void WorkerCacheStorageConnection::doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, const ResourceRequest& request, CacheQueryOptions&& options)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier, request = request.isolatedCopy(), options = options.isolatedCopy()](ScriptExecutionContext&) mutable {
callOnMainThread([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier, request = request.isolatedCopy(), options = options.isolatedCopy()]() mutable {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -244,7 +241,7 @@ void WorkerCacheStorageConnection::doBatchDeleteOperation(uint64_t requestIdenti

void WorkerCacheStorageConnection::doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&& records)
{
m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier, recordsData = recordsDataFromRecords(records)](ScriptExecutionContext&) mutable {
callOnMainThread([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier, recordsData = recordsDataFromRecords(records)]() mutable {
ASSERT(isMainThread());
ASSERT(m_mainThreadConnection);

@@ -565,7 +565,7 @@
185BCF290F3279CE000EA262 /* ThreadTimers.h in Headers */ = {isa = PBXBuildFile; fileRef = 185BCF270F3279CE000EA262 /* ThreadTimers.h */; };
188604B30F2E654A000B6443 /* DOMTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 188604B10F2E654A000B6443 /* DOMTimer.cpp */; };
188604B40F2E654A000B6443 /* DOMTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 188604B20F2E654A000B6443 /* DOMTimer.h */; settings = {ATTRIBUTES = (Private, ); }; };
18F831B80FD48C7800D8C56B /* WorkerLoaderProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 18F831B70FD48C7800D8C56B /* WorkerLoaderProxy.h */; };
18F831B80FD48C7800D8C56B /* WorkerLoaderProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 18F831B70FD48C7800D8C56B /* WorkerLoaderProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
1921327411C0E6BB00456238 /* SVGFEConvolveMatrixElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1921327111C0E6BB00456238 /* SVGFEConvolveMatrixElement.cpp */; };
1921327511C0E6BB00456238 /* SVGFEConvolveMatrixElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1921327211C0E6BB00456238 /* SVGFEConvolveMatrixElement.h */; };
197B180C1506353200E4ADA8 /* SVGRenderingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 197B180B150634C000E4ADA8 /* SVGRenderingContext.h */; };
@@ -1383,6 +1383,8 @@
41103AAD1E39791000769F14 /* RealtimeIncomingAudioSourceCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 41103AA91E39790A00769F14 /* RealtimeIncomingAudioSourceCocoa.h */; };
41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */; };
41103AAE1E39791000769F14 /* RealtimeIncomingAudioSourceCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41103AAA1E39790A00769F14 /* RealtimeIncomingAudioSourceCocoa.cpp */; };
4112B5421F9F9CA000E67875 /* ServiceWorkerThreadProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4112B5411F9F9C9C00E67875 /* ServiceWorkerThreadProxy.cpp */; };
4112B5431F9F9CA000E67875 /* ServiceWorkerThreadProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4112B53F1F9F9C9B00E67875 /* ServiceWorkerThreadProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
41230913138C42FF00BCCFCA /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* JavaScriptCore.framework */; };
4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */ = {isa = PBXBuildFile; fileRef = 413015D61C7B570400091C6F /* FetchBodySource.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8232,6 +8234,8 @@
41103AA91E39790A00769F14 /* RealtimeIncomingAudioSourceCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeIncomingAudioSourceCocoa.h; sourceTree = "<group>"; };
41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingAudioSource.cpp; sourceTree = "<group>"; };
41103AAA1E39790A00769F14 /* RealtimeIncomingAudioSourceCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingAudioSourceCocoa.cpp; sourceTree = "<group>"; };
4112B53F1F9F9C9B00E67875 /* ServiceWorkerThreadProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerThreadProxy.h; sourceTree = "<group>"; };
4112B5411F9F9C9C00E67875 /* ServiceWorkerThreadProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerThreadProxy.cpp; sourceTree = "<group>"; };
41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultController.idl; sourceTree = "<group>"; };
41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableByteStreamController.idl; sourceTree = "<group>"; };
41189EF71AD8232800B95672 /* ReadableStreamBYOBRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamBYOBRequest.idl; sourceTree = "<group>"; };
@@ -18178,6 +18182,8 @@
419ACF8E1F97E7D5009F1A83 /* ServiceWorkerFetch.h */,
517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */,
517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */,
4112B5411F9F9C9C00E67875 /* ServiceWorkerThreadProxy.cpp */,
4112B53F1F9F9C9B00E67875 /* ServiceWorkerThreadProxy.h */,
);
path = context;
sourceTree = "<group>";
@@ -29580,6 +29586,7 @@
517A53291F4B90B900DCDC0A /* ServiceWorkerRegistrationKey.h in Headers */,
51F175691F3EBC8300C74950 /* ServiceWorkerRegistrationOptions.h in Headers */,
51BCCE301F8F179E006BA0ED /* ServiceWorkerThread.h in Headers */,
4112B5431F9F9CA000E67875 /* ServiceWorkerThreadProxy.h in Headers */,
51F1756C1F3EBC8300C74950 /* ServiceWorkerUpdateViaCache.h in Headers */,
46EF142A1F97B7D800C2A524 /* ServiceWorkerWindowClient.h in Headers */,
93309E10099E64920056E581 /* SetNodeAttributeCommand.h in Headers */,
@@ -32108,6 +32115,7 @@
517A53281F4B90B900DCDC0A /* ServiceWorkerRegistrationKey.cpp in Sources */,
51F645A21F4BF53C00B54DED /* ServiceWorkerRegistrationOptions.cpp in Sources */,
51BCCE2F1F8F1795006BA0ED /* ServiceWorkerThread.cpp in Sources */,
4112B5421F9F9CA000E67875 /* ServiceWorkerThreadProxy.cpp in Sources */,
46EF142E1F97B7D800C2A524 /* ServiceWorkerWindowClient.cpp in Sources */,
7CD58DFD1F9565A800112791 /* Settings.cpp in Sources */,
7CC660A21F93CB9000D500E9 /* SettingsBase.cpp in Sources */,
@@ -34,22 +34,27 @@

namespace WebCore {

// A proxy to talk to the loader context. Normally, the document on the main thread
// provides loading services for the subordinate workers. This interface provides 2-way
// communications to the Document context and back to the worker.
// Note that in multi-process browsers, the Worker object context and the Document
// context can be distinct.
class WorkerLoaderProxy {
public:
virtual ~WorkerLoaderProxy() = default;

// Posts a task to the thread which runs the loading code (normally, the main thread).
virtual void postTaskToLoader(ScriptExecutionContext::Task&&) = 0;

// Posts callbacks from loading code to the WorkerGlobalScope. The 'mode' is used to differentiate
// specific synchronous loading requests so they can be 'nested', per spec.
// Returns true if the task was posted successfully.
virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String& mode) = 0;
};
class CacheStorageConnection;

// A proxy to talk to the loader context. Normally, the document on the main thread
// provides loading services for the subordinate workers. This interface provides 2-way
// communications to the Document context and back to the worker.
// Note that in multi-process browsers, the Worker object context and the Document
// context can be distinct.
class WorkerLoaderProxy {
public:
virtual ~WorkerLoaderProxy() = default;

// Creates a cache storage connection to be used on the main thread. Method must be called on the main thread.
virtual Ref<CacheStorageConnection> createCacheStorageConnection() = 0;

// Posts a task to the thread which runs the loading code (normally, the main thread).
virtual void postTaskToLoader(ScriptExecutionContext::Task&&) = 0;

// Posts callbacks from loading code to the WorkerGlobalScope. The 'mode' is used to differentiate
// specific synchronous loading requests so they can be 'nested', per spec.
// Returns true if the task was posted successfully.
virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String& mode) = 0;
};

} // namespace WebCore

0 comments on commit 8bf01d7

Please sign in to comment.