Enable ServiceWorker to fetch resources
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2017 21:17:46 +0000 (21:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2017 21:17:46 +0000 (21:17 +0000)
commit0927574c8935b210c33f29732e9e349713643a5a
treeaf6accda01e986c11d21946b4e6716017a16efcf
parent2acd6f1f798c62ed0015e29a7b07a613a6ce5d44
Enable ServiceWorker to fetch resources
https://bugs.webkit.org/show_bug.cgi?id=178673

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

Source/WebCore:

Test: http/tests/workers/service/service-worker-fetch.html

Allow reusing of EmptyFrameLoaderClient for network loading in WebKit Service Worker environment.
Allow overriding the creation of a document loader, pageID, frameID and sessionID getters.

Allow the possibility to create synthetic documents for all ports.

Beefing up ServiceWorkerThreadProxy as it owns a Document and a Page that do nothing but server
the purpose of loading resources for a service worker thread.

* WebCore.xcodeproj/project.pbxproj:
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::setResponse):
* loader/EmptyClients.cpp:
(WebCore::EmptyFrameLoaderClient::sessionID const):
(WebCore::EmptyFrameLoaderClient::createNetworkingContext):
(WebCore::createEmptyFrameNetworkingContext):
* loader/EmptyClients.h:
* loader/EmptyFrameLoaderClient.h: Added.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::initForSynthesizedDocument):
* loader/FrameLoader.h:
* loader/FrameLoaderClient.h:
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
(WebCore::m_workerObjectProxy):
* workers/service/context/ServiceWorkerThread.h:
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::create):
(WebCore::createPageForServiceWorker):
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
(WebCore::ServiceWorkerThreadProxy::postTaskToLoader):
* workers/service/context/ServiceWorkerThreadProxy.h:
Test: http/tests/workers/service/service-worker-fetch.html

Source/WebKit:

ServiceWorkerContextManager makes use of the new ServiceWorkerThreadProxy.
It creates the necessary environment for the thread to make use of network loads, web sockets and cache storage.
Fetch is functional with these changes.

ServiceWorkerProcessProxy is introduced as a UIProcess proxy to the service worker process.
This process proxy is responsible to give the pageID used by all service worker thread instances for network loads.
ServiceWorkerContextManager is responsible to give a unique frameID for all service worker threads.
This is necessary as these two ids are currently needed for any network load.

ServiceWorkerThreadProxy creates its own FrameLoaderClient which is now used to get pageID, frameID and sessionID.

* UIProcess/ServiceWorkerProcessProxy.cpp: Added.
(WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy):
(WebKit::m_serviceWorkerPageID):
(WebKit::ServiceWorkerProcessProxy::~ServiceWorkerProcessProxy):
(WebKit::ServiceWorkerProcessProxy::start):
* UIProcess/ServiceWorkerProcessProxy.h: Added.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::getWorkerContextProcessConnection):
(WebKit::WebProcessPool::createNewWebProcess):
(WebKit::WebProcessPool::initializeNewWebProcess):
(WebKit::WebProcessPool::disconnectProcess):
(WebKit::WebProcessPool::createNewWebProcessRespectingProcessCountLimit):
(WebKit::WebProcessPool::createWebPage):
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::generatePageID):
* UIProcess/WebProcessProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad):
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
(WebKit::WebLoaderStrategy::startPingLoad):
* WebProcess/Network/WebLoaderStrategy.h:
* WebProcess/Storage/ServiceWorkerContextManager.cpp:
(WebKit::ServiceWorkerContextManager::ServiceWorkerContextManager):
(WebKit::ServiceWorkerContextManager::startServiceWorker):
(WebKit::ServiceWorkerContextManager::startFetch):
* WebProcess/Storage/ServiceWorkerContextManager.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::pageID const):
(WebKit::WebFrameLoaderClient::frameID const):
(WebKit::WebFrameLoaderClient::sessionID const):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::getWorkerContextConnection):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::pageID const):
(WebFrameLoaderClient::frameID const):
(WebFrameLoaderClient::sessionID const):

Added implementation to the new getters.
They are noop in the context of WK1.

Source/WebKitLegacy/win:

Added implementation to the new getters.
They are noop in the context of WK1.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::pageID const):
(WebFrameLoaderClient::frameID const):
(WebFrameLoaderClient::sessionID const):
* WebCoreSupport/WebFrameLoaderClient.h:

LayoutTests:

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223981 268f45cc-cd09-0410-ab3c-d52691b4dbfc
42 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/service/resources/service-worker-fetch-worker.js [new file with mode: 0644]
LayoutTests/http/tests/workers/service/resources/service-worker-fetch.js [new file with mode: 0644]
LayoutTests/http/tests/workers/service/service-worker-fetch-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/service-worker-fetch.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyClients.h
Source/WebCore/loader/EmptyFrameLoaderClient.h [new file with mode: 0644]
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp
Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
Source/WebCore/workers/service/context/ServiceWorkerThread.h
Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h [new file with mode: 0644]
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp
Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h