Changeset 223650 in webkit
- Timestamp:
- Oct 18, 2017 7:26:00 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 1 deleted
- 34 edited
- 2 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223648 r223650 1 2017-10-18 Youenn Fablet <youenn@apple.com> 2 3 Add preliminary support for ServiceWorker Handle Fetch 4 https://bugs.webkit.org/show_bug.cgi?id=178475 5 6 Reviewed by Chris Dumez. 7 8 * http/tests/workers/service/basic-fetch.https-expected.txt: Added. 9 * http/tests/workers/service/basic-fetch.https.html: Added. 10 * http/tests/workers/service/resources/basic-fetch-worker.js: Added. 11 * http/tests/workers/service/resources/basic-fetch.js: Added. 12 1 13 2017-10-18 Youenn Fablet <youenn@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r223649 r223650 1 2017-10-18 Youenn Fablet <youenn@apple.com> 2 3 Add preliminary support for ServiceWorker Handle Fetch 4 https://bugs.webkit.org/show_bug.cgi?id=178475 5 6 Reviewed by Chris Dumez. 7 8 Test: http/tests/workers/service/basic-fetch.https.html 9 10 Adding parameters to allow WebKit to do loading through Service Worker or through regular networking. 11 A script context is now storing its selected service worker identifier. This should be fully implemented later on. 12 This selected service worker identifier is passed to loading code as a ResourceLoaderOptions field. 13 Service workers mode is also added as a ResourceLoaderOptions field so that the service worker can be bypassed. 14 15 * WebCore.xcodeproj/project.pbxproj: 16 * dom/ScriptExecutionContext.h: 17 (WebCore::ScriptExecutionContext::selectedServiceWorkerIdentifier const): 18 (WebCore::ScriptExecutionContext::setSelectedServiceWorkerIdentifier): 19 * loader/DocumentThreadableLoader.cpp: 20 (WebCore::DocumentThreadableLoader::DocumentThreadableLoader): 21 * loader/FetchOptions.h: 22 (WebCore::isPotentialNavigationOrSubresourceRequest): 23 (WebCore::isNonSubresourceRequest): 24 * loader/ResourceLoaderOptions.h: 25 * loader/WorkerThreadableLoader.cpp: 26 (WebCore::WorkerThreadableLoader::WorkerThreadableLoader): 27 (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): 28 * loader/WorkerThreadableLoader.h: 29 * platform/network/ResourceRequestBase.h: 30 * platform/network/ResourceResponseBase.h: 31 * workers/WorkerThread.h: 32 * workers/service/ServiceWorkerContainer.cpp: 33 (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): 34 * workers/service/ServiceWorkerProvider.h: 35 * workers/service/context/SWContextManager.cpp: Removed. 36 * workers/service/context/ServiceWorkerThread.h: 37 * workers/service/server/SWServer.h: 38 1 39 2017-10-18 Zalan Bujtas <zalan@apple.com> 2 40 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r223634 r223650 2328 2328 517B25A91CC82B2A0061C011 /* IDBConnectionProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517B25A71CC820320061C011 /* IDBConnectionProxy.cpp */; }; 2329 2329 517B25AA1CC82B2A0061C011 /* IDBConnectionProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 517B25A81CC820320061C011 /* IDBConnectionProxy.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2330 517C870A1F8EBB2500EB8076 /* SWContextManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */; };2331 517C870B1F8EBB2500EB8076 /* SWContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 517C87091F8EB9C000EB8076 /* SWContextManager.h */; settings = {ATTRIBUTES = (Private, ); }; };2332 2330 517C87181F8FD4D900EB8076 /* ServiceWorkerContextData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517C87161F8FD4D300EB8076 /* ServiceWorkerContextData.cpp */; }; 2333 2331 517DEEE51DE94ADC00B91644 /* ScrollingMomentumCalculatorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517DEEE31DE94ADC00B91644 /* ScrollingMomentumCalculatorMac.mm */; }; … … 10231 10229 517B25A71CC820320061C011 /* IDBConnectionProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBConnectionProxy.cpp; sourceTree = "<group>"; }; 10232 10230 517B25A81CC820320061C011 /* IDBConnectionProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBConnectionProxy.h; sourceTree = "<group>"; }; 10233 517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SWContextManager.cpp; path = workers/service/context/SWContextManager.cpp; sourceTree = SOURCE_ROOT; };10234 517C87091F8EB9C000EB8076 /* SWContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SWContextManager.h; path = workers/service/context/SWContextManager.h; sourceTree = SOURCE_ROOT; };10235 10231 517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ServiceWorkerThread.h; path = workers/service/context/ServiceWorkerThread.h; sourceTree = SOURCE_ROOT; }; 10236 10232 517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ServiceWorkerThread.cpp; path = workers/service/context/ServiceWorkerThread.cpp; sourceTree = SOURCE_ROOT; }; … … 19090 19086 517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */, 19091 19087 517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */, 19092 517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */,19093 517C87091F8EB9C000EB8076 /* SWContextManager.h */,19094 19088 ); 19095 19089 path = context; … … 30637 30631 B2E4EC980D00C22B00432643 /* SVGZoomEvent.h in Headers */, 30638 30632 517A531D1F4B53B100DCDC0A /* SWClientConnection.h in Headers */, 30639 517C870B1F8EBB2500EB8076 /* SWContextManager.h in Headers */,30640 30633 517A52F01F47535B00DCDC0A /* SWServer.h in Headers */, 30641 30634 51F645971F4A686F00B54DED /* SWServerRegistration.h in Headers */, … … 34369 34362 B2E4EC970D00C22B00432643 /* SVGZoomEvent.cpp in Sources */, 34370 34363 517A531C1F4B53B100DCDC0A /* SWClientConnection.cpp in Sources */, 34371 517C870A1F8EBB2500EB8076 /* SWContextManager.cpp in Sources */,34372 34364 517A52F11F4754E700DCDC0A /* SWServer.cpp in Sources */, 34373 34365 51F645961F4A686F00B54DED /* SWServerRegistration.cpp in Sources */, -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r220857 r223650 231 231 JSC::ExecState* execState(); 232 232 233 #if ENABLE(SERVICE_WORKER) 234 uint64_t selectedServiceWorkerIdentifier() const { return m_serviceWorkerIdentifier; } 235 void setSelectedServiceWorkerIdentifier(uint64_t identifier) { m_serviceWorkerIdentifier = identifier; } 236 #endif 237 233 238 protected: 234 239 class AddConsoleMessageTask : public Task { … … 298 303 bool m_activeDOMObjectRemovalForbidden { false }; 299 304 #endif 305 306 #if ENABLE(SERVICE_WORKER) 307 uint64_t m_serviceWorkerIdentifier { 0 }; 308 #endif 300 309 }; 301 310 -
trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp
r222467 r223650 104 104 relaxAdoptionRequirement(); 105 105 106 #if ENABLE(SERVICE_WORKER) 107 if (m_options.serviceWorkersMode == ServiceWorkersMode::All && !m_options.serviceWorkerIdentifier) 108 m_options.serviceWorkerIdentifier = document.selectedServiceWorkerIdentifier(); 109 #endif 110 106 111 // Setting a referrer header is only supported in the async code path. 107 112 ASSERT(m_async || m_referrer.isEmpty()); -
trunk/Source/WebCore/loader/FetchOptions.h
r223441 r223650 70 70 } 71 71 72 inline bool isPotentialNavigationOrSubresourceRequest(FetchOptions::Destination destination) 73 { 74 return destination == FetchOptions::Destination::Object 75 || destination == FetchOptions::Destination::Embed; 76 } 77 78 inline bool isNonSubresourceRequest(FetchOptions::Destination destination) 79 { 80 return destination == FetchOptions::Destination::Document 81 || destination == FetchOptions::Destination::Report 82 || destination == FetchOptions::Destination::Serviceworker 83 || destination == FetchOptions::Destination::Sharedworker 84 || destination == FetchOptions::Destination::Worker; 85 } 86 72 87 } 73 88 -
trunk/Source/WebCore/loader/ResourceLoaderOptions.h
r222467 r223650 93 93 }; 94 94 95 enum class ServiceWorkersMode { 96 All, 97 None, 98 }; 99 95 100 struct ResourceLoaderOptions : public FetchOptions { 96 101 ResourceLoaderOptions() { } … … 125 130 SameOriginDataURLFlag sameOriginDataURLFlag { SameOriginDataURLFlag::Unset }; 126 131 InitiatorContext initiatorContext { InitiatorContext::Document }; 132 ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All }; 133 uint64_t serviceWorkerIdentifier { 0 }; 127 134 128 135 ClientCredentialPolicy clientCredentialPolicy { ClientCredentialPolicy::CannotAskClientForCredentials }; -
trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp
r219954 r223650 56 56 : m_workerGlobalScope(workerGlobalScope) 57 57 , m_workerClientWrapper(ThreadableLoaderClientWrapper::create(client, options.initiator)) 58 , m_bridge(*new MainThreadBridge(m_workerClientWrapper.get(), workerGlobalScope.thread().workerLoaderProxy(), taskMode, WTFMove(request), options, referrer.isEmpty() ? workerGlobalScope.url().strippedForUseAsReferrer() : referrer, workerGlobalScope .securityOrigin(), workerGlobalScope.contentSecurityPolicy()))58 , m_bridge(*new MainThreadBridge(m_workerClientWrapper.get(), workerGlobalScope.thread().workerLoaderProxy(), taskMode, WTFMove(request), options, referrer.isEmpty() ? workerGlobalScope.url().strippedForUseAsReferrer() : referrer, workerGlobalScope)) 59 59 { 60 60 } … … 102 102 103 103 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClientWrapper& workerClientWrapper, WorkerLoaderProxy& loaderProxy, const String& taskMode, 104 ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer, 105 const SecurityOrigin* securityOrigin, const ContentSecurityPolicy* contentSecurityPolicy) 104 ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer, WorkerGlobalScope& globalScope) 106 105 : m_workerClientWrapper(&workerClientWrapper) 107 106 , m_loaderProxy(loaderProxy) 108 107 , m_taskMode(taskMode.isolatedCopy()) 109 108 { 109 110 auto* securityOrigin = globalScope.securityOrigin(); 111 auto* contentSecurityPolicy = globalScope.contentSecurityPolicy(); 112 110 113 ASSERT(securityOrigin); 111 114 ASSERT(contentSecurityPolicy); … … 121 124 ASSERT(optionsCopy->options.initiatorContext == InitiatorContext::Document); 122 125 optionsCopy->options.initiatorContext = InitiatorContext::Worker; 126 127 #if ENABLE(SERVICE_WORKER) 128 optionsCopy->options.serviceWorkersMode = globalScope.isServiceWorkerGlobalScope() ? ServiceWorkersMode::None : ServiceWorkersMode::All; 129 optionsCopy->options.serviceWorkerIdentifier = globalScope.selectedServiceWorkerIdentifier(); 130 #endif 123 131 124 132 // Can we benefit from request being an r-value to create more efficiently its isolated copy? -
trunk/Source/WebCore/loader/WorkerThreadableLoader.h
r219954 r223650 89 89 public: 90 90 // All executed on the worker context's thread. 91 MainThreadBridge(ThreadableLoaderClientWrapper&, WorkerLoaderProxy&, const String& taskMode, ResourceRequest&&, const ThreadableLoaderOptions&, const String& outgoingReferrer, const SecurityOrigin*, const ContentSecurityPolicy*);91 MainThreadBridge(ThreadableLoaderClientWrapper&, WorkerLoaderProxy&, const String& taskMode, ResourceRequest&&, const ThreadableLoaderOptions&, const String& outgoingReferrer, WorkerGlobalScope&); 92 92 void cancel(); 93 93 void destroy(); -
trunk/Source/WebCore/platform/network/ResourceRequestBase.h
r220632 r223650 101 101 WEBCORE_EXPORT String httpContentType() const; 102 102 WEBCORE_EXPORT void setHTTPContentType(const String&); 103 void clearHTTPContentType();103 WEBCORE_EXPORT void clearHTTPContentType(); 104 104 105 105 bool hasHTTPHeader(HTTPHeaderName) const; -
trunk/Source/WebCore/platform/network/ResourceResponseBase.h
r220764 r223650 154 154 } 155 155 156 void setType(Type);156 WEBCORE_EXPORT void setType(Type); 157 157 Type type() const { return m_type; } 158 158 -
trunk/Source/WebCore/workers/WorkerThread.h
r220857 r223650 62 62 virtual ~WorkerThread(); 63 63 64 bool start();64 WEBCORE_EXPORT bool start(); 65 65 void stop(); 66 66 -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp
r222980 r223650 180 180 } 181 181 182 // FIXME: Implement proper selection of service workers. 183 context->setSelectedServiceWorkerIdentifier(data.identifier); 184 182 185 auto registration = ServiceWorkerRegistration::create(*context, data); 183 186 job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get()); -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h
r223277 r223650 53 53 54 54 private: 55 ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID);55 WEBCORE_EXPORT ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID); 56 56 57 57 uint64_t m_serverConnectionIdentifier; -
trunk/Source/WebKit/CMakeLists.txt
r223608 r223650 684 684 WebProcess/Plugins/PluginProxy.messages.in 685 685 686 WebProcess/Storage/ServiceWorkerClientFetch.messages.in 686 687 WebProcess/Storage/WebSWClientConnection.messages.in 687 688 -
trunk/Source/WebKit/ChangeLog
r223647 r223650 1 2017-10-18 Youenn Fablet <youenn@apple.com> 2 3 Add preliminary support for ServiceWorker Handle Fetch 4 https://bugs.webkit.org/show_bug.cgi?id=178475 5 6 Reviewed by Chris Dumez. 7 8 Preliminary support of Handle Fetch algorithm and integration with fetch spec. 9 Adding ServiceWorkerClientFetch as the class responsible to do the load through ServiceWorker. 10 It is similar to WebResourceLoader that do the load through NetworkProcess. 11 In case ServiceWorkerClientFetch is not able to load through ServiceWorker, 12 it will fallback to WebResourceLoader through a fallback callback. 13 14 Loading through Service Worker is done currently if: 15 - There is a service worker registered for that origin 16 - Request is a subresource 17 - service workers mode is all 18 There will be cases where the service worker will not do the loading, for instance when fetch event handler is not set. 19 Future work should try to reduce the cases where the IPC dance is done unnecessarily. 20 21 ServiceWorkerClientFetch is responsible to adapt the ServiceWorker response to ResourceLoader. 22 In particular, it is calling ResourceLoader error callback if response is of type error. 23 It should call ResourceLoader redirection callback if response is a redirection response. 24 This will be done as a follow-up. 25 26 Implementing the IPC communication dedicated to fetch between WebProcess and ServiceWorker through StorageProcess. 27 In the future, WebProcess should create a direct IPC communication to the ServiceWorker process. 28 29 Moved SWContextManager from WebCore to WebKit and renamed it to ServiceWorkerContextManager. 30 This class is moved to WebKit as it will have to handle IPC and having a separation will add some unnecessary boilerplate. 31 32 * DerivedSources.make: 33 * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: 34 (WebKit::WebSWServerConnection::startFetch): 35 (WebKit::WebSWServerConnection::didReceiveFetchResponse): 36 (WebKit::WebSWServerConnection::didReceiveFetchData): 37 (WebKit::WebSWServerConnection::didFinishFetch): 38 (WebKit::WebSWServerConnection::failedFetch): 39 * StorageProcess/ServiceWorker/WebSWServerConnection.h: 40 * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: 41 * StorageProcess/StorageProcess.cpp: 42 (WebKit::StorageProcess::failedFetch): 43 (WebKit::StorageProcess::didReceiveFetchResponse): 44 (WebKit::StorageProcess::didReceiveFetchData): 45 (WebKit::StorageProcess::didFinishFetch): 46 * StorageProcess/StorageProcess.h: 47 * StorageProcess/StorageProcess.messages.in: 48 * WebKit.xcodeproj/project.pbxproj: 49 * WebProcess/Network/WebLoaderStrategy.cpp: 50 (WebKit::WebLoaderStrategy::scheduleLoad): 51 (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): 52 * WebProcess/Network/WebLoaderStrategy.h: 53 * WebProcess/Storage/ServiceWorkerClientFetch.cpp: Added. 54 (WebKit::ServiceWorkerClientFetch::didReceiveResponse): 55 (WebKit::ServiceWorkerClientFetch::didReceiveData): 56 (WebKit::ServiceWorkerClientFetch::didFinishFetch): 57 (WebKit::ServiceWorkerClientFetch::didFail): 58 * WebProcess/Storage/ServiceWorkerClientFetch.h: Added. 59 * WebProcess/Storage/ServiceWorkerClientFetch.messages.in: Added. 60 * WebProcess/Storage/ServiceWorkerContextManager.cpp: Renamed from Source/WebCore/workers/service/context/SWContextManager.cpp. 61 (WebKit::ServiceWorkerContextManager::startServiceWorkerContext): 62 (WebKit::ServiceWorkerContextManager::startFetch): 63 * WebProcess/Storage/ServiceWorkerContextManager.h: Renamed from Source/WebCore/workers/service/context/SWContextManager.h. 64 (WebKit::ServiceWorkerContextManager::ServiceWorkerContextManager): 65 * WebProcess/Storage/WebSWClientConnection.cpp: 66 (WebKit::WebSWClientConnection::startFetch): 67 * WebProcess/Storage/WebSWClientConnection.h: 68 * WebProcess/Storage/WebServiceWorkerProvider.cpp: 69 (WebKit::shouldHandleFetch): 70 (WebKit::WebServiceWorkerProvider::handleFetch): 71 (WebKit::WebServiceWorkerProvider::didReceiveServiceWorkerClientFetchMessage): 72 * WebProcess/Storage/WebServiceWorkerProvider.h: 73 * WebProcess/Storage/WebToStorageProcessConnection.cpp: 74 (WebKit::WebToStorageProcessConnection::didReceiveMessage): 75 * WebProcess/WebProcess.cpp: 76 (WebKit::WebProcess::getWorkerContextConnection): 77 (WebKit::WebProcess::startServiceWorkerContext): 78 (WebKit::WebProcess::startFetchInServiceWorker): 79 * WebProcess/WebProcess.h: 80 * WebProcess/WebProcess.messages.in: 81 1 82 2017-10-18 Chelsea Pugh <cpugh@apple.com> 2 83 -
trunk/Source/WebKit/DerivedSources.make
r221541 r223650 126 126 RemoteWebInspectorUI \ 127 127 SecItemShimProxy \ 128 ServiceWorkerClientFetch \ 128 129 SmartMagnificationController \ 129 130 StorageAreaMap \ -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
r223608 r223650 31 31 #include "DataReference.h" 32 32 #include "Logging.h" 33 #include "ServiceWorkerClientFetchMessages.h" 33 34 #include "StorageProcess.h" 34 35 #include "StorageToWebProcessConnectionMessages.h" 36 #include "WebCoreArgumentCoders.h" 35 37 #include "WebProcess.h" 36 38 #include "WebProcessMessages.h" … … 93 95 } 94 96 97 void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options) 98 { 99 sendToContextProcess(Messages::WebProcess::StartFetchInServiceWorker(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options)); 100 } 101 102 void WebSWServerConnection::didReceiveFetchResponse(uint64_t fetchIdentifier, const ResourceResponse& response) 103 { 104 m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidReceiveResponse { response }, fetchIdentifier); 105 } 106 107 void WebSWServerConnection::didReceiveFetchData(uint64_t fetchIdentifier, const IPC::DataReference& data, int64_t encodedDataLength) 108 { 109 m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidReceiveData { data, encodedDataLength }, fetchIdentifier); 110 } 111 112 void WebSWServerConnection::didFinishFetch(uint64_t fetchIdentifier) 113 { 114 m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidFinish { }, fetchIdentifier); 115 } 116 117 void WebSWServerConnection::didFailFetch(uint64_t fetchIdentifier) 118 { 119 m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidFail { }, fetchIdentifier); 120 } 121 95 122 template<typename U> bool WebSWServerConnection::sendToContextProcess(U&& message) 96 123 { -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
r223608 r223650 52 52 PAL::SessionID sessionID() const { return m_sessionID; } 53 53 54 void didReceiveFetchResponse(uint64_t fetchIdentifier, const WebCore::ResourceResponse&); 55 void didReceiveFetchData(uint64_t fetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength); 56 void didFinishFetch(uint64_t fetchIdentifier); 57 void didFailFetch(uint64_t fetchIdentifier); 58 54 59 private: 55 60 // Implement SWServer::Connection (Messages to the client WebProcess) … … 58 63 void startScriptFetchInClient(uint64_t jobIdentifier) final; 59 64 65 void startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&); 66 60 67 // Messages to the SW context WebProcess 61 68 void startServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final; 62 69 63 70 IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); } 64 71 uint64_t messageSenderDestinationID() final { return identifier(); } -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
r222980 r223650 27 27 ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData) 28 28 FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result) 29 30 StartFetch(uint64_t identifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options) 29 31 } 30 32 -
trunk/Source/WebKit/StorageProcess/StorageProcess.cpp
r223610 r223650 406 406 } 407 407 408 void StorageProcess::didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier) 409 { 410 if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier)) 411 connection->didFailFetch(fetchIdentifier); 412 } 413 414 void StorageProcess::didReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse& response) 415 { 416 if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier)) 417 connection->didReceiveFetchResponse(fetchIdentifier, response); 418 } 419 420 void StorageProcess::didReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference& data, int64_t encodedDataLength) 421 { 422 if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier)) 423 connection->didReceiveFetchData(fetchIdentifier, data, encodedDataLength); 424 } 425 426 void StorageProcess::didFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier) 427 { 428 if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier)) 429 connection->didFinishFetch(fetchIdentifier); 430 } 431 408 432 void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection) 409 433 { -
trunk/Source/WebKit/StorageProcess/StorageProcess.h
r223608 r223650 120 120 void serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, const String& workerID, const String& message); 121 121 void serviceWorkerContextStarted(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, uint64_t identifier, const String& workerID); 122 123 void didReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse&); 124 void didReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength); 125 void didFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier); 126 void didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier); 122 127 #endif 123 128 #if ENABLE(INDEXED_DATABASE) -
trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in
r223608 r223650 38 38 #if ENABLE(SERVICE_WORKER) 39 39 DidGetWorkerContextProcessConnection(IPC::Attachment connectionHandle) 40 40 41 ServiceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, String workerID, String message) 41 42 ServiceWorkerContextStarted(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, uint64_t identifier, String workerID) 43 44 DidFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier) 45 DidReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, WebCore::ResourceResponse response) 46 DidReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength) 47 DidFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier) 42 48 #endif 43 49 } -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r223608 r223650 891 891 413075B31DE85F580039EC69 /* LibWebRTCProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */; }; 892 892 413075B41DE85F580039EC69 /* LibWebRTCProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */; }; 893 4131F3D11F96BCCC0059995A /* ServiceWorkerClientFetch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */; }; 894 4131F3D41F96E9350059995A /* ServiceWorkerContextManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */; }; 895 4131F3D51F96E9350059995A /* ServiceWorkerContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */; }; 893 896 4135FBD11F4FB8090074C47B /* CacheStorageEngineCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */; }; 894 897 41897ECF1F415D620016FA42 /* WebCacheStorageConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41897ECE1F415D5C0016FA42 /* WebCacheStorageConnection.cpp */; }; … … 1030 1033 5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510CC7EA16138E7200D03ED3 /* NetworkProcessProxy.cpp */; }; 1031 1034 5179556E162877B300FA43B6 /* NetworkProcessProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 510CC7EB16138E7200D03ED3 /* NetworkProcessProxy.h */; }; 1035 617A52D81F43A9DA00DCDC0A /* ServiceWorkerClientFetchMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchConnectionMessageReceiver.cpp */; }; 1032 1036 517A52D81F43A9DA00DCDC0A /* WebSWServerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */; }; 1037 617A52D91F43A9DA00DCDC0A /* ServiceWorkerClientFetchMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 617A52D61F43A9B600DCDC0A /* ServiceWorkerClientFetchMessages.h */; }; 1033 1038 517A52D91F43A9DA00DCDC0A /* WebSWServerConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */; }; 1034 1039 517A53041F4793C600DCDC0A /* WebSWClientConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A53031F4793B200DCDC0A /* WebSWClientConnection.cpp */; }; … … 3179 3184 413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = LibWebRTCProvider.cpp; path = Network/webrtc/LibWebRTCProvider.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 3180 3185 413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = LibWebRTCProvider.h; path = Network/webrtc/LibWebRTCProvider.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3186 4131F3CE1F96A4950059995A /* ServiceWorkerClientFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerClientFetch.h; sourceTree = "<group>"; }; 3187 4131F3CF1F96A9360059995A /* ServiceWorkerClientFetch.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ServiceWorkerClientFetch.messages.in; sourceTree = "<group>"; }; 3188 4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerClientFetch.cpp; sourceTree = "<group>"; }; 3189 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerContextManager.h; sourceTree = "<group>"; }; 3190 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerContextManager.cpp; sourceTree = "<group>"; }; 3181 3191 4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStorageEngineCaches.cpp; sourceTree = "<group>"; }; 3182 3192 4135FBD01F4FB7F20074C47B /* CacheStorageEngineCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageEngineCaches.h; sourceTree = "<group>"; }; … … 3335 3345 517A33B3130B308C00F80CB5 /* WKApplicationCacheManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKApplicationCacheManager.cpp; sourceTree = "<group>"; }; 3336 3346 517A33B4130B308C00F80CB5 /* WKApplicationCacheManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKApplicationCacheManager.h; sourceTree = "<group>"; }; 3347 617A52D61F43A9B600DCDC0A /* ServiceWorkerFetchClientMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWServerConnectionMessages.h; sourceTree = "<group>"; }; 3337 3348 517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWServerConnectionMessages.h; sourceTree = "<group>"; }; 3349 617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerClientFetchMessageReceiver.cpp; sourceTree = "<group>"; }; 3338 3350 517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWServerConnectionMessageReceiver.cpp; sourceTree = "<group>"; }; 3339 3351 517A53021F4793B200DCDC0A /* WebSWClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWClientConnection.h; sourceTree = "<group>"; }; … … 6169 6181 isa = PBXGroup; 6170 6182 children = ( 6183 4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */, 6184 4131F3CE1F96A4950059995A /* ServiceWorkerClientFetch.h */, 6185 4131F3CF1F96A9360059995A /* ServiceWorkerClientFetch.messages.in */, 6186 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */, 6187 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */, 6171 6188 51BEB6291F3A5ACD005029B9 /* WebServiceWorkerProvider.cpp */, 6172 6189 51BEB62A1F3A5ACD005029B9 /* WebServiceWorkerProvider.h */, … … 8011 8028 E18E6913169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp */, 8012 8029 E18E6914169B667B009B6670 /* SecItemShimProxyMessages.h */, 8030 617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchConnectionMessageReceiver.cpp */, 8013 8031 2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */, 8014 8032 2DE6943C18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h */, … … 8782 8800 E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */, 8783 8801 514D9F5719119D35000063A7 /* ServicesController.h in Headers */, 8802 4131F3D51F96E9350059995A /* ServiceWorkerContextManager.h in Headers */, 8784 8803 1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */, 8785 8804 1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */, … … 10371 10390 E18E6917169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp in Sources */, 10372 10391 514D9F5819119D35000063A7 /* ServicesController.mm in Sources */, 10392 4131F3D11F96BCCC0059995A /* ServiceWorkerClientFetch.cpp in Sources */, 10393 617A52D81F43A9DA00DCDC0A /* ServiceWorkerClientFetchConnectionMessageReceiver.cpp in Sources */, 10394 4131F3D41F96E9350059995A /* ServiceWorkerContextManager.cpp in Sources */, 10373 10395 1AFDE6591954A42B00C48FFA /* SessionState.cpp in Sources */, 10374 10396 1A002D48196B345D00B9AD44 /* SessionStateCoding.mm in Sources */, -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
r223238 r223650 44 44 #include "WebProcess.h" 45 45 #include "WebResourceLoader.h" 46 #include "WebServiceWorkerProvider.h" 46 47 #include "WebURLSchemeHandlerProxy.h" 47 48 #include "WebURLSchemeTaskProxy.h" … … 216 217 } 217 218 219 #if ENABLE(SERVICE_WORKER) 220 WebServiceWorkerProvider::singleton().handleFetch(resourceLoader, resource, webPage ? webPage->sessionID() : PAL::SessionID::defaultSessionID(), [trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime = maximumBufferingTime(resource), resourceLoader = makeRef(resourceLoader)] (ServiceWorkerClientFetch::Result result) mutable { 221 if (result != ServiceWorkerClientFetch::Result::Unhandled) 222 return; 223 224 LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled through ServiceWorker handle fetch algorithm", resourceLoader->url().string().latin1().data()); 225 WebProcess::singleton().webLoaderStrategy().scheduleLoadFromNetworkProcess(resourceLoader.get(), resourceLoader->originalRequest(), WTFMove(trackingParameters), shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime); 226 }); 227 #else 228 LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled through ServiceWorker handle fetch algorithm", resourceLoader.url().string().latin1().data()); 229 scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource)); 230 #endif 231 } 232 233 void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceLoader, const ResourceRequest& request, const WebResourceLoader::TrackingParameters& trackingParameters, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime) 234 { 235 ResourceLoadIdentifier identifier = resourceLoader.identifier(); 236 ASSERT(identifier); 237 238 WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader.frameLoader()->client()); 239 WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr; 240 WebPage* webPage = webFrame ? webFrame->page() : nullptr; 241 218 242 LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled with the NetworkProcess with priority %d", resourceLoader.url().string().latin1().data(), static_cast<int>(resourceLoader.request().priority())); 219 243 … … 226 250 loadParameters.webFrameID = webFrame ? webFrame->frameID() : 0; 227 251 loadParameters.sessionID = webPage ? webPage->sessionID() : PAL::SessionID::defaultSessionID(); 228 loadParameters.request = re sourceLoader.request();252 loadParameters.request = request; 229 253 loadParameters.contentSniffingPolicy = contentSniffingPolicy; 230 254 loadParameters.storedCredentialsPolicy = storedCredentialsPolicy; … … 234 258 loadParameters.defersLoading = resourceLoader.defersLoading(); 235 259 loadParameters.needsCertificateInfo = resourceLoader.shouldIncludeCertificateInfo(); 236 loadParameters.maximumBufferingTime = maximumBufferingTime (resource);260 loadParameters.maximumBufferingTime = maximumBufferingTime; 237 261 loadParameters.derivedCachedDataTypesToRetrieve = resourceLoader.options().derivedCachedDataTypesToRetrieve; 238 262 … … 301 325 return; 302 326 } 303 327 328 #if ENABLE(SERVICE_WORKER) 329 if (WebServiceWorkerProvider::singleton().cancelFetch(identifier)) 330 return; 331 #endif 332 304 333 RefPtr<WebResourceLoader> loader = m_webResourceLoaders.take(identifier); 305 334 // Loader may not be registered if we created it, but haven't scheduled yet (a bundle client can decide to cancel such request via willSendRequest). -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
r222739 r223650 78 78 void removeURLSchemeTaskProxy(WebURLSchemeTaskProxy&); 79 79 80 void scheduleLoadFromNetworkProcess(WebCore::ResourceLoader&, const WebCore::ResourceRequest&, const WebResourceLoader::TrackingParameters&, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime); 81 80 82 private: 81 83 void scheduleLoad(WebCore::ResourceLoader&, WebCore::CachedResource*, bool shouldClearReferrerOnHTTPSToHTTPRedirect); -
trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h
r223649 r223650 28 28 #if ENABLE(SERVICE_WORKER) 29 29 30 #include "Connection.h"31 30 #include "MessageReceiver.h" 32 31 #include "MessageSender.h" 33 #include "SharedMemory.h" 34 #include <WebCore/SWClientConnection.h> 35 #include <pal/SessionID.h> 36 #include <wtf/UniqueRef.h> 37 38 namespace WebCore { 39 struct ExceptionData; 40 } 32 #include <WebCore/ResourceLoader.h> 33 #include <wtf/CompletionHandler.h> 41 34 42 35 namespace WebKit { 43 36 44 class WebS WOriginTable;37 class WebServiceWorkerProvider; 45 38 46 class WebSWClientConnection : public WebCore::SWClientConnection, public IPC::MessageSender, public IPC::MessageReceiver {39 class ServiceWorkerClientFetch final : public RefCounted<ServiceWorkerClientFetch>, public IPC::MessageSender, public IPC::MessageReceiver { 47 40 public: 48 WebSWClientConnection(IPC::Connection&, PAL::SessionID); 49 WebSWClientConnection(const WebSWClientConnection&) = delete; 50 ~WebSWClientConnection() final; 41 enum class Result { Succeeded, Cancelled, Unhandled }; 42 using Callback = WTF::CompletionHandler<void(Result)>; 51 43 52 uint64_t identifier() const final { return m_identifier; } 44 static Ref<ServiceWorkerClientFetch> create(WebServiceWorkerProvider& serviceWorkerProvider, Ref<WebCore::ResourceLoader>&& loader, uint64_t identifier, Ref<IPC::Connection>&& connection, Callback&& callback) 45 { 46 return adoptRef(*new ServiceWorkerClientFetch { serviceWorkerProvider, WTFMove(loader), identifier, WTFMove(connection), WTFMove(callback) }); 47 } 53 48 54 void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;55 void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;49 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 50 void cancel(); 56 51 57 void disconnectedFromWebProcess(); 58 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 59 60 bool hasServiceWorkerRegisteredForOrigin(const WebCore::SecurityOrigin&) const final; 52 bool isOngoing() const { return !!m_callback; } 61 53 62 54 private: 63 void scheduleStorageJob(const WebCore::ServiceWorkerJobData&); 55 ServiceWorkerClientFetch(WebServiceWorkerProvider&, Ref<WebCore::ResourceLoader>&&, uint64_t identifier, Ref<IPC::Connection>&&, Callback&&); 56 57 void didReceiveResponse(const WebCore::ResourceResponse&); 58 void didReceiveData(const IPC::DataReference&, int64_t encodedDataLength); 59 void didFinish(); 60 void didFail(); 64 61 65 62 IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); } 66 63 uint64_t messageSenderDestinationID() final { return m_identifier; } 67 64 68 void setSWOriginTableSharedMemory(const SharedMemory::Handle&); 69 70 PAL::SessionID m_sessionID; 71 uint64_t m_identifier; 72 65 WebServiceWorkerProvider& m_serviceWorkerProvider; 66 Ref<WebCore::ResourceLoader> m_loader; 67 uint64_t m_identifier { 0 }; 73 68 Ref<IPC::Connection> m_connection; 74 UniqueRef<WebSWOriginTable> m_swOriginTable;75 }; // class WebSWServerConnection69 Callback m_callback; 70 }; 76 71 77 72 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in
r223649 r223650 23 23 #if ENABLE(SERVICE_WORKER) 24 24 25 messages -> WebSWServerConnection { 26 # When possible, these messages can be implemented directly by WebCore::SWClientConnection 27 ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData) 28 FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result) 25 messages -> ServiceWorkerClientFetch { 26 DidReceiveResponse(WebCore::ResourceResponse response) 27 DidReceiveData(IPC::DataReference data, int64_t encodedDataLength) 28 DidFinish() 29 DidFail() 29 30 } 30 31 -
trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h
r223649 r223650 28 28 #if ENABLE(SERVICE_WORKER) 29 29 30 #include " ExceptionOr.h"31 #include "ServiceWorkerThread.h"30 #include "Connection.h" 31 #include <WebCore/ServiceWorkerThread.h> 32 32 #include <wtf/HashMap.h> 33 33 34 34 namespace WebCore { 35 struct FetchOptions; 36 class ResourceRequest; 37 struct ServiceWorkerContextData; 38 } 35 39 36 struct ServiceWorkerContextData; 40 namespace WebKit { 37 41 38 class S WContextManager {42 class ServiceWorkerContextManager { 39 43 public: 40 WEBCORE_EXPORT static SWContextManager& singleton(); 44 explicit ServiceWorkerContextManager(Ref<IPC::Connection>&& connection) 45 : m_connectionToStorageProcess(WTFMove(connection)) 46 { 47 } 41 48 42 WEBCORE_EXPORT ExceptionOr<uint64_t> startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&); 49 void startServiceWorkerContext(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&); 50 void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&); 43 51 44 52 private: 45 SWContextManager(); 46 47 HashMap<uint64_t, RefPtr<ServiceWorkerThread>> m_workerThreadMap; 53 Ref<IPC::Connection> m_connectionToStorageProcess; 54 HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThread>> m_workerThreadMap; 48 55 }; 49 56 50 } // namespace Web Core57 } // namespace WebKit 51 58 52 59 #endif // ENABLE(SERVICE_WORKER) -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
r223608 r223650 30 30 31 31 #include "Logging.h" 32 #include "ServiceWorkerClientFetch.h" 32 33 #include "StorageToWebProcessConnectionMessages.h" 33 34 #include "WebCoreArgumentCoders.h" … … 76 77 } 77 78 79 Ref<ServiceWorkerClientFetch> WebSWClientConnection::startFetch(WebServiceWorkerProvider& provider, Ref<WebCore::ResourceLoader>&& loader, uint64_t identifier, ServiceWorkerClientFetch::Callback&& callback) 80 { 81 ASSERT(loader->options().serviceWorkersMode == ServiceWorkersMode::All); 82 // FIXME: Decide whether to assert for loader->options().serviceWorkerIdentifier once we have a story for navigation loads. 83 84 send(Messages::WebSWServerConnection::StartFetch(identifier, loader->options().serviceWorkerIdentifier, loader->originalRequest(), loader->options())); 85 return ServiceWorkerClientFetch::create(provider, WTFMove(loader), identifier, m_connection.get(), WTFMove(callback)); 86 } 87 78 88 } // namespace WebKit 79 89 -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
r223608 r223650 31 31 #include "MessageReceiver.h" 32 32 #include "MessageSender.h" 33 #include "ServiceWorkerClientFetch.h" 33 34 #include "SharedMemory.h" 34 35 #include <WebCore/SWClientConnection.h> … … 38 39 namespace WebCore { 39 40 struct ExceptionData; 41 class ResourceLoader; 40 42 } 41 43 … … 43 45 44 46 class WebSWOriginTable; 47 class WebServiceWorkerProvider; 45 48 46 49 class WebSWClientConnection : public WebCore::SWClientConnection, public IPC::MessageSender, public IPC::MessageReceiver { … … 59 62 60 63 bool hasServiceWorkerRegisteredForOrigin(const WebCore::SecurityOrigin&) const final; 64 Ref<ServiceWorkerClientFetch> startFetch(WebServiceWorkerProvider&, Ref<WebCore::ResourceLoader>&&, uint64_t identifier, ServiceWorkerClientFetch::Callback&&); 61 65 62 66 private: -
trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp
r223608 r223650 59 59 } 60 60 61 static inline bool shouldHandleFetch(const WebSWClientConnection& connection, CachedResource* resource, const ResourceLoaderOptions& options) 62 { 63 if (options.serviceWorkersMode != ServiceWorkersMode::All) 64 return false; 65 66 // FIXME: We should probably assert that options.serviceWorkersIdentifier is not null. 67 if (isPotentialNavigationOrSubresourceRequest(options.destination)) 68 return false; 69 70 // FIXME: Implement non-subresource request loads. 71 if (isNonSubresourceRequest(options.destination)) 72 return false; 73 74 if (!resource) 75 return false; 76 77 return connection.hasServiceWorkerRegisteredForOrigin(*resource->origin()); 78 } 79 80 void WebServiceWorkerProvider::handleFetch(ResourceLoader& loader, CachedResource* resource, PAL::SessionID sessionID, ServiceWorkerClientFetch::Callback&& callback) 81 { 82 auto& connection = WebProcess::singleton().webToStorageProcessConnection()->serviceWorkerConnectionForSession(sessionID); 83 84 if (!shouldHandleFetch(connection, resource, loader.options())) { 85 // FIXME: Add an option to error resource load for DTL to actually go through preflight. 86 callback(ServiceWorkerClientFetch::Result::Unhandled); 87 return; 88 } 89 90 auto fetch = connection.startFetch(*this, loader, loader.identifier(), WTFMove(callback)); 91 ASSERT(fetch->isOngoing()); 92 93 m_ongoingFetchTasks.add(loader.identifier(), WTFMove(fetch)); 94 } 95 96 bool WebServiceWorkerProvider::cancelFetch(uint64_t fetchIdentifier) 97 { 98 auto fetch = m_ongoingFetchTasks.take(fetchIdentifier); 99 if (fetch) 100 (*fetch)->cancel(); 101 return !!fetch; 102 } 103 104 void WebServiceWorkerProvider::fetchFinished(uint64_t fetchIdentifier) 105 { 106 m_ongoingFetchTasks.take(fetchIdentifier); 107 } 108 109 void WebServiceWorkerProvider::didReceiveServiceWorkerClientFetchMessage(IPC::Connection& connection, IPC::Decoder& decoder) 110 { 111 if (auto fetch = m_ongoingFetchTasks.get(decoder.destinationID())) 112 fetch->didReceiveMessage(connection, decoder); 113 } 114 61 115 } // namespace WebKit 62 116 -
trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h
r223608 r223650 28 28 #if ENABLE(SERVICE_WORKER) 29 29 30 #include "ServiceWorkerClientFetch.h" 30 31 #include <WebCore/ServiceWorkerProvider.h> 31 32 #include <wtf/NeverDestroyed.h> … … 37 38 static WebServiceWorkerProvider& singleton(); 38 39 40 void handleFetch(WebCore::ResourceLoader&, WebCore::CachedResource*, PAL::SessionID, ServiceWorkerClientFetch::Callback&&); 41 bool cancelFetch(uint64_t fetchIdentifier); 42 void fetchFinished(uint64_t fetchIdentifier); 43 44 void didReceiveServiceWorkerClientFetchMessage(IPC::Connection&, IPC::Decoder&); 45 39 46 private: 40 47 friend NeverDestroyed<WebServiceWorkerProvider>; … … 43 50 WebCore::SWClientConnection& serviceWorkerConnectionForSession(PAL::SessionID) final; 44 51 52 HashMap<uint64_t, Ref<ServiceWorkerClientFetch>> m_ongoingFetchTasks; 45 53 }; // class WebServiceWorkerProvider 46 54 -
trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp
r223608 r223650 28 28 #include "WebToStorageProcessConnection.h" 29 29 30 #include "ServiceWorkerClientFetchMessages.h" 30 31 #include "StorageToWebProcessConnectionMessages.h" 31 32 #include "WebIDBConnectionToServerMessages.h" … … 33 34 #include "WebSWClientConnection.h" 34 35 #include "WebSWClientConnectionMessages.h" 36 #include "WebServiceWorkerProvider.h" 35 37 36 38 using namespace PAL; … … 66 68 if (serviceWorkerConnection) 67 69 serviceWorkerConnection->didReceiveMessage(connection, decoder); 70 return; 71 } 72 if (decoder.messageReceiverName() == Messages::ServiceWorkerClientFetch::messageReceiverName()) { 73 WebServiceWorkerProvider::singleton().didReceiveServiceWorkerClientFetchMessage(connection, decoder); 68 74 return; 69 75 } -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r223608 r223650 41 41 #include "NetworkSession.h" 42 42 #include "PluginProcessConnectionManager.h" 43 #include "ServiceWorkerContextManager.h" 43 44 #include "SessionTracker.h" 44 45 #include "StatisticsData.h" … … 106 107 #include <WebCore/ResourceLoadStatistics.h> 107 108 #include <WebCore/RuntimeApplicationChecks.h> 108 #include <WebCore/SWContextManager.h>109 109 #include <WebCore/SchemeRegistry.h> 110 110 #include <WebCore/SecurityOrigin.h> … … 1623 1623 void WebProcess::getWorkerContextConnection() 1624 1624 { 1625 ASSERT(!m_ workerContextConnection);1625 ASSERT(!m_serviceWorkerManager); 1626 1626 1627 1627 #if USE(UNIX_DOMAIN_SOCKETS) … … 1643 1643 #endif 1644 1644 1645 m_workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);1646 m_workerContextConnection->open();1647 1645 auto workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this); 1646 workerContextConnection->open(); 1647 m_serviceWorkerManager = ServiceWorkerContextManager(WTFMove(workerContextConnection)); 1648 1648 WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidGetWorkerContextConnection(connectionClientPort), 0); 1649 1649 } … … 1651 1651 void WebProcess::startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data) 1652 1652 { 1653 auto contextResult = SWContextManager::singleton().startServiceWorkerContext(serverConnectionIdentifier, data); 1654 1655 if (contextResult.hasException()) 1656 m_workerContextConnection->send(Messages::StorageProcess::ServiceWorkerContextFailedToStart(serverConnectionIdentifier, data.registrationKey, data.workerID, contextResult.exception().message()), 0); 1657 else 1658 m_workerContextConnection->send(Messages::StorageProcess::ServiceWorkerContextStarted(serverConnectionIdentifier, data.registrationKey, contextResult.returnValue(), data.workerID), 0); 1653 ASSERT(m_serviceWorkerManager); 1654 if (!m_serviceWorkerManager) 1655 return; 1656 1657 m_serviceWorkerManager->startServiceWorkerContext(serverConnectionIdentifier, data); 1658 } 1659 1660 void WebProcess::startFetchInServiceWorker(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options) 1661 { 1662 if (!m_serviceWorkerManager) 1663 return; 1664 1665 m_serviceWorkerManager->startFetch(serverConnectionIdentifier, fetchIdentifier, serviceWorkerIdentifier, request, options); 1659 1666 } 1660 1667 -
trunk/Source/WebKit/WebProcess/WebProcess.h
r223191 r223650 31 31 #include "ResourceCachesToClear.h" 32 32 #include "SandboxExtension.h" 33 #include "ServiceWorkerContextManager.h" 33 34 #include "TextCheckerState.h" 34 35 #include "ViewUpdateDispatcher.h" … … 301 302 void getWorkerContextConnection(); 302 303 void startServiceWorkerContext(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&); 303 RefPtr<IPC::Connection> m_workerContextConnection;304 void startFetchInServiceWorker(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&); 304 305 #endif 305 306 … … 439 440 std::unique_ptr<WaylandCompositorDisplay> m_waylandCompositorDisplay; 440 441 #endif 442 #if ENABLE(SERVICE_WORKER) 443 std::optional<ServiceWorkerContextManager> m_serviceWorkerManager; 444 #endif 441 445 }; 442 446 -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r223191 r223650 118 118 GetWorkerContextConnection() 119 119 StartServiceWorkerContext(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData) 120 StartFetchInServiceWorker(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options) 120 121 #endif 121 122 }
Note: See TracChangeset
for help on using the changeset viewer.