Changeset 225403 in webkit
- Timestamp:
- Dec 1, 2017 11:45:41 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 33 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r225402 r225403 1 2017-12-01 Brady Eidson <beidson@apple.com> 2 3 Add Internals.terminateServiceWorker, and the ability to restart service workers for postMessage. 4 https://bugs.webkit.org/show_bug.cgi?id=180170 5 6 Reviewed by Chris Dumez. 7 8 * http/tests/workers/service/postmessage-after-terminate.https-expected.txt: Added. 9 * http/tests/workers/service/postmessage-after-terminate.https.html: Added. 10 * http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js: 11 (then): 12 * http/tests/workers/service/resources/postmessage-after-terminate.js: Copied from LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js. 13 (then): 14 * http/tests/workers/service/resources/postmessage-echo-worker.js: Renamed from LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js. 15 1 16 2017-12-01 Zalan Bujtas <zalan@apple.com> 2 17 -
trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js
r225308 r225403 10 10 }); 11 11 12 navigator.serviceWorker.register("resources/ basic-ServiceWorker-postMessage-worker.js", { }).then(function(registration) {12 navigator.serviceWorker.register("resources/postmessage-echo-worker.js", { }).then(function(registration) { 13 13 registration.installing.postMessage("Message 1"); 14 14 }); -
trunk/LayoutTests/http/tests/workers/service/resources/postmessage-after-terminate.js
r225402 r225403 4 4 log(event.data); 5 5 if (messageNumber == 1) { 6 window.internals.terminateServiceWorker(event.source); 6 7 event.source.postMessage("Message 2"); 7 8 messageNumber++; … … 10 11 }); 11 12 12 navigator.serviceWorker.register("resources/ basic-ServiceWorker-postMessage-worker.js", { }).then(function(registration) {13 navigator.serviceWorker.register("resources/postmessage-echo-worker.js", { }).then(function(registration) { 13 14 registration.installing.postMessage("Message 1"); 14 15 }); -
trunk/Source/WTF/ChangeLog
r225375 r225403 1 2017-12-01 Brady Eidson <beidson@apple.com> 2 3 Add Internals.terminateServiceWorker, and the ability to restart service workers for postMessage. 4 https://bugs.webkit.org/show_bug.cgi?id=180170 5 6 Reviewed by Chris Dumez. 7 8 * wtf/CompletionHandler.h: 9 (WTF::CompletionHandler<Out): 10 1 11 2017-11-30 Yusuke Suzuki <utatane.tea@gmail.com> 2 12 -
trunk/Source/WTF/wtf/CompletionHandler.h
r223617 r225403 54 54 explicit operator bool() const { return !!m_function; } 55 55 56 Out operator()(In... in) 56 Out operator()(In... in) const 57 57 { 58 58 ASSERT_WITH_MESSAGE(m_function, "Completion handler should not be called more than once"); … … 62 62 63 63 private: 64 WTF::Function<Out(In...)> m_function;64 mutable WTF::Function<Out(In...)> m_function; 65 65 }; 66 66 -
trunk/Source/WebCore/ChangeLog
r225402 r225403 1 2017-12-01 Brady Eidson <beidson@apple.com> 2 3 Add Internals.terminateServiceWorker, and the ability to restart service workers for postMessage. 4 https://bugs.webkit.org/show_bug.cgi?id=180170 5 6 Reviewed by Chris Dumez. 7 8 Test: http/tests/workers/service/postmessage-after-terminate.https.html 9 10 * dom/ActiveDOMObject.cpp: 11 (WebCore::ActiveDOMObject::~ActiveDOMObject): 12 13 * testing/Internals.cpp: 14 (WebCore::Internals::terminateServiceWorker): 15 * testing/Internals.h: 16 * testing/Internals.idl: 17 18 * workers/service/SWClientConnection.h: 19 20 * workers/service/ServiceWorker.idl: 21 22 * workers/service/context/SWContextManager.cpp: 23 (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): 24 (WebCore::SWContextManager::terminateWorker): 25 * workers/service/context/SWContextManager.h: 26 27 * workers/service/context/ServiceWorkerThreadProxy.h: 28 29 * workers/service/server/SWServer.cpp: 30 (WebCore::SWServer::workerByID const): 31 (WebCore::SWServer::Connection::syncTerminateWorker): 32 (WebCore::SWServer::installContextData): 33 (WebCore::SWServer::invokeRunServiceWorker): 34 (WebCore::SWServer::terminateWorker): 35 (WebCore::SWServer::syncTerminateWorker): 36 (WebCore::SWServer::terminateWorkerInternal): 37 (WebCore::SWServer::workerContextTerminated): 38 * workers/service/server/SWServer.h: 39 (WebCore::SWServer::workerByID const): Deleted. 40 41 * workers/service/server/SWServerToContextConnection.h: 42 43 * workers/service/server/SWServerWorker.cpp: 44 (WebCore::SWServerWorker::contextData const): 45 * workers/service/server/SWServerWorker.h: 46 (WebCore::SWServerWorker::isRunning const): 47 (WebCore::SWServerWorker::isTerminating const): 48 (WebCore::SWServerWorker::setState): 49 (WebCore::SWServerWorker::server): 50 1 51 2017-12-01 Zalan Bujtas <zalan@apple.com> 2 52 -
trunk/Source/WebCore/dom/ActiveDOMObject.cpp
r192848 r225403 48 48 ActiveDOMObject::~ActiveDOMObject() 49 49 { 50 if (!m_scriptExecutionContext)51 return;52 53 ASSERT(m_suspendIfNeededWasCalled);54 55 50 // ActiveDOMObject may be inherited by a sub-class whose life-cycle 56 51 // exceeds that of the associated ScriptExecutionContext. In those cases, … … 59 54 // inherit). Hence, we should ensure that this is not 0 before use it 60 55 // here. 61 if (m_scriptExecutionContext) { 62 ASSERT(m_scriptExecutionContext->isContextThread()); 63 m_scriptExecutionContext->willDestroyActiveDOMObject(*this); 64 } 56 if (!m_scriptExecutionContext) 57 return; 58 59 ASSERT(m_suspendIfNeededWasCalled); 60 ASSERT(m_scriptExecutionContext->isContextThread()); 61 m_scriptExecutionContext->willDestroyActiveDOMObject(*this); 65 62 } 66 63 -
trunk/Source/WebCore/testing/Internals.cpp
r225395 r225403 133 133 #include "SecurityOrigin.h" 134 134 #include "SerializedScriptValue.h" 135 #include "ServiceWorker.h" 135 136 #include "ServiceWorkerProvider.h" 136 137 #include "ServiceWorkerRegistrationData.h" … … 4271 4272 }); 4272 4273 } 4274 4275 void Internals::terminateServiceWorker(ServiceWorker& worker) 4276 { 4277 if (!contextDocument()) 4278 return; 4279 4280 ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(contextDocument()->sessionID()).syncTerminateWorker(worker.identifier()); 4281 } 4273 4282 #endif 4274 4283 -
trunk/Source/WebCore/testing/Internals.h
r225223 r225403 91 91 class XMLHttpRequest; 92 92 93 #if ENABLE(SERVICE_WORKER) 94 class ServiceWorker; 95 #endif 96 93 97 class Internals final : public RefCounted<Internals>, private ContextDestructionObserver 94 98 #if ENABLE(MEDIA_STREAM) … … 624 628 using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>; 625 629 void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&); 630 void terminateServiceWorker(ServiceWorker&); 626 631 #endif 627 632 -
trunk/Source/WebCore/testing/Internals.idl
r225223 r225403 568 568 [Conditional=SERVICE_WORKER, CallWith=ScriptExecutionContext] FetchEvent createBeingDispatchedFetchEvent(); 569 569 [Conditional=SERVICE_WORKER] Promise<boolean> hasServiceWorkerRegistration(DOMString scopeURL); 570 [Conditional=SERVICE_WORKER] void terminateServiceWorker(ServiceWorker worker); 570 571 571 572 [EnabledAtRuntime=WebAnimations] DOMString timelineDescription(AnimationTimeline timeline); -
trunk/Source/WebCore/workers/service/SWClientConnection.h
r225399 r225403 74 74 virtual SWServerConnectionIdentifier serverConnectionIdentifier() const = 0; 75 75 virtual bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOrigin&) const = 0; 76 virtual void syncTerminateWorker(ServiceWorkerIdentifier) = 0; 76 77 77 78 virtual void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier) = 0; -
trunk/Source/WebCore/workers/service/ServiceWorker.idl
r225221 r225403 32 32 Exposed=(Window,ServiceWorker), 33 33 Conditional=SERVICE_WORKER, 34 EnabledAtRuntime=ServiceWorker 34 EnabledAtRuntime=ServiceWorker, 35 ExportMacro=WEBCORE_EXPORT 35 36 ] interface ServiceWorker : EventTarget { 36 37 readonly attribute USVString scriptURL; -
trunk/Source/WebCore/workers/service/context/SWContextManager.cpp
r225341 r225403 70 70 { 71 71 auto* serviceWorker = m_workerMap.get(destination); 72 if (!serviceWorker)73 return;72 ASSERT(serviceWorker); 73 ASSERT(!serviceWorker->isTerminatingOrTerminated()); 74 74 75 75 // FIXME: We should pass valid MessagePortChannels. … … 95 95 } 96 96 97 void SWContextManager::terminateWorker(ServiceWorkerIdentifier identifier )97 void SWContextManager::terminateWorker(ServiceWorkerIdentifier identifier, Function<void()>&& completionHandler) 98 98 { 99 99 auto* serviceWorker = m_workerMap.get(identifier); … … 101 101 return; 102 102 103 serviceWorker->thread().stop([identifier] { 103 serviceWorker->setTerminatingOrTerminated(true); 104 105 serviceWorker->thread().stop([this, identifier, completionHandler = WTFMove(completionHandler)] { 104 106 if (auto* connection = SWContextManager::singleton().connection()) 105 107 connection->workerTerminated(identifier); 108 109 if (completionHandler) 110 completionHandler(); 111 112 auto worker = m_workerMap.take(identifier); 113 ASSERT(worker); 114 115 // Spin the runloop before releasing the worker thread proxy, as there would otherwise be 116 // a race towards its destruction. 117 callOnMainThread([worker = WTFMove(worker)] { }); 106 118 }); 107 119 } -
trunk/Source/WebCore/workers/service/context/SWContextManager.h
r225341 r225403 62 62 WEBCORE_EXPORT void fireInstallEvent(ServiceWorkerIdentifier); 63 63 WEBCORE_EXPORT void fireActivateEvent(ServiceWorkerIdentifier); 64 WEBCORE_EXPORT void terminateWorker(ServiceWorkerIdentifier );64 WEBCORE_EXPORT void terminateWorker(ServiceWorkerIdentifier, Function<void()>&&); 65 65 66 66 void forEachServiceWorkerThread(const WTF::Function<void(ServiceWorkerThreadProxy&)>&); -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h
r224801 r225403 57 57 ServiceWorkerInspectorProxy& inspectorProxy() { return m_inspectorProxy; } 58 58 59 bool isTerminatingOrTerminated() const { return m_isTerminatingOrTerminated; } 60 void setTerminatingOrTerminated(bool terminating) { m_isTerminatingOrTerminated = terminating; } 61 59 62 private: 60 63 WEBCORE_EXPORT ServiceWorkerThreadProxy(PageConfiguration&&, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&); … … 75 78 RefPtr<CacheStorageConnection> m_cacheStorageConnection; 76 79 PAL::SessionID m_sessionID; 80 bool m_isTerminatingOrTerminated { false }; 81 77 82 ServiceWorkerInspectorProxy m_inspectorProxy; 78 83 #if ENABLE(REMOTE_INSPECTOR) -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r225298 r225403 88 88 } 89 89 90 SWServerWorker* SWServer::workerByID(ServiceWorkerIdentifier identifier) const 91 { 92 auto* worker = SWServerWorker::existingWorkerForIdentifier(identifier); 93 ASSERT(!worker || &worker->server() == this); 94 return worker; 95 } 96 90 97 SWServerRegistration* SWServer::getRegistration(const ServiceWorkerRegistrationKey& registrationKey) 91 98 { … … 189 196 } 190 197 198 void SWServer::Connection::syncTerminateWorker(ServiceWorkerIdentifier identifier) 199 { 200 if (auto* worker = m_server.workerByID(identifier)) 201 m_server.syncTerminateWorker(*worker); 202 } 203 191 204 SWServer::SWServer(UniqueRef<SWOriginStore>&& originStore) 192 205 : m_originStore(WTFMove(originStore)) … … 298 311 if (auto* registration = getRegistration(worker.registrationKey())) 299 312 SWServerJobQueue::didFinishActivation(*registration, worker.identifier()); 300 }301 302 void SWServer::workerContextTerminated(SWServerWorker& worker)303 {304 auto result = m_workersByID.remove(worker.identifier());305 ASSERT_UNUSED(result, result);306 313 } 307 314 … … 388 395 RELEASE_ASSERT(registration); 389 396 390 auto result = m_workersByID.add(data.serviceWorkerIdentifier, SWServerWorker::create(*this, *registration, connection->identifier(), data.scriptURL, data.script, data.workerType, data.serviceWorkerIdentifier)); 391 ASSERT_UNUSED(result, result.isNewEntry); 397 auto result = m_runningOrTerminatingWorkers.add(data.serviceWorkerIdentifier, SWServerWorker::create(*this, *registration, connection->identifier(), data.scriptURL, data.script, data.workerType, data.serviceWorkerIdentifier)); 398 ASSERT(result.isNewEntry); 399 400 result.iterator->value->setState(SWServerWorker::State::Running); 392 401 393 402 connection->installServiceWorkerContext(data); 394 403 } 395 404 405 bool SWServer::invokeRunServiceWorker(ServiceWorkerIdentifier identifier) 406 { 407 if (auto* worker = m_runningOrTerminatingWorkers.get(identifier)) { 408 if (worker->isRunning()) 409 return true; 410 } 411 412 // Nobody should have a ServiceWorkerIdentifier for a SWServerWorker that doesn't exist. 413 auto* worker = workerByID(identifier); 414 ASSERT(worker); 415 416 // If the registration for a working has been removed then the request to run 417 // the worker is moot. 418 if (!getRegistration(worker->registrationKey())) 419 return false; 420 421 m_runningOrTerminatingWorkers.add(identifier, *worker); 422 worker->setState(SWServerWorker::State::Running); 423 424 auto* connection = SWServerToContextConnection::globalServerToContextConnection(); 425 ASSERT(connection); 426 connection->installServiceWorkerContext(worker->contextData()); 427 428 return true; 429 } 396 430 397 431 void SWServer::terminateWorker(SWServerWorker& worker) 398 432 { 433 terminateWorkerInternal(worker, Asynchronous); 434 } 435 436 void SWServer::syncTerminateWorker(SWServerWorker& worker) 437 { 438 terminateWorkerInternal(worker, Synchronous); 439 } 440 441 void SWServer::terminateWorkerInternal(SWServerWorker& worker, TerminationMode mode) 442 { 399 443 auto* connection = SWServerToContextConnection::connectionForIdentifier(worker.contextConnectionIdentifier()); 400 if (connection) 444 if (!connection) { 445 LOG_ERROR("Request to terminate a worker whose context connection does not exist"); 446 return; 447 } 448 449 ASSERT(m_runningOrTerminatingWorkers.get(worker.identifier()) == &worker); 450 ASSERT(!worker.isTerminating()); 451 452 worker.setState(SWServerWorker::State::Terminating); 453 454 switch (mode) { 455 case Asynchronous: 401 456 connection->terminateWorker(worker.identifier()); 402 else 403 LOG_ERROR("Request to terminate a worker whose context connection does not exist"); 457 break; 458 case Synchronous: 459 connection->syncTerminateWorker(worker.identifier()); 460 break; 461 }; 462 } 463 464 void SWServer::workerContextTerminated(SWServerWorker& worker) 465 { 466 ASSERT(worker.isTerminating()); 467 468 worker.setState(SWServerWorker::State::NotRunning); 469 470 // At this point if no registrations are referencing the worker then it will be destroyed, 471 // removing itself from the m_workersByID map. 472 auto result = m_runningOrTerminatingWorkers.take(worker.identifier()); 473 ASSERT_UNUSED(result, result && result->ptr() == &worker); 404 474 } 405 475 -
trunk/Source/WebCore/workers/service/server/SWServer.h
r225344 r225403 91 91 WEBCORE_EXPORT void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier); 92 92 WEBCORE_EXPORT void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier); 93 WEBCORE_EXPORT void syncTerminateWorker(ServiceWorkerIdentifier); 93 94 94 95 private: … … 109 110 WEBCORE_EXPORT void clear(const SecurityOrigin&); 110 111 111 112 112 SWServerRegistration* getRegistration(const ServiceWorkerRegistrationKey&); 113 113 void addRegistration(std::unique_ptr<SWServerRegistration>&&); … … 126 126 void updateWorker(Connection&, const ServiceWorkerJobDataIdentifier&, SWServerRegistration&, const URL&, const String& script, WorkerType); 127 127 void terminateWorker(SWServerWorker&); 128 void syncTerminateWorker(SWServerWorker&); 128 129 void fireInstallEvent(SWServerWorker&); 129 130 void fireActivateEvent(SWServerWorker&); 130 SWServerWorker* workerByID(ServiceWorkerIdentifier identifier) const { return m_workersByID.get(identifier); }131 WEBCORE_EXPORT SWServerWorker* workerByID(ServiceWorkerIdentifier) const; 131 132 132 133 Connection* getConnection(SWServerConnectionIdentifier identifier) { return m_connections.get(identifier); } … … 146 147 WEBCORE_EXPORT void unregisterServiceWorkerClient(const ClientOrigin&, ServiceWorkerClientIdentifier); 147 148 149 WEBCORE_EXPORT bool invokeRunServiceWorker(ServiceWorkerIdentifier); 150 148 151 private: 149 152 void registerConnection(Connection&); … … 166 169 void installContextData(const ServiceWorkerContextData&); 167 170 171 enum TerminationMode { 172 Synchronous, 173 Asynchronous, 174 }; 175 void terminateWorkerInternal(SWServerWorker&, TerminationMode); 176 168 177 HashMap<SWServerConnectionIdentifier, Connection*> m_connections; 169 178 HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations; … … 171 180 HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerJobQueue>> m_jobQueues; 172 181 173 HashMap<ServiceWorkerIdentifier, Ref<SWServerWorker>> m_ workersByID;182 HashMap<ServiceWorkerIdentifier, Ref<SWServerWorker>> m_runningOrTerminatingWorkers; 174 183 175 184 struct ClientInformation { -
trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h
r225347 r225403 49 49 virtual void fireActivateEvent(ServiceWorkerIdentifier) = 0; 50 50 virtual void terminateWorker(ServiceWorkerIdentifier) = 0; 51 virtual void syncTerminateWorker(ServiceWorkerIdentifier) = 0; 51 52 52 53 // Messages back from the SW host process -
trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp
r225298 r225403 61 61 } 62 62 63 ServiceWorkerContextData SWServerWorker::contextData() const 64 { 65 auto* registration = m_server.getRegistration(m_registrationKey); 66 ASSERT(registration); 67 68 return { std::nullopt, registration->data(), m_data.identifier, m_script, m_data.scriptURL, m_data.type }; 69 } 70 63 71 void SWServerWorker::terminate() 64 72 { -
trunk/Source/WebCore/workers/service/server/SWServerWorker.h
r225347 r225403 40 40 class SWServerRegistration; 41 41 enum class WorkerType; 42 struct ServiceWorkerContextData; 42 43 struct ServiceWorkerJobDataIdentifier; 43 44 … … 54 55 void terminate(); 55 56 56 SWServer& server(); 57 enum class State { 58 Running, 59 Terminating, 60 NotRunning, 61 }; 62 bool isRunning() const { return m_state == State::Running; } 63 bool isTerminating() const { return m_state == State::Terminating; } 64 void setState(State state) { m_state = state; } 65 66 SWServer& server() { return m_server; } 57 67 const ServiceWorkerRegistrationKey& registrationKey() const { return m_registrationKey; } 58 68 const URL& scriptURL() const { return m_data.scriptURL; } … … 78 88 79 89 const ServiceWorkerData& data() const { return m_data; } 90 ServiceWorkerContextData contextData() const; 80 91 81 92 private: … … 88 99 String m_script; 89 100 bool m_hasPendingEvents { false }; 101 State m_state { State::NotRunning }; 90 102 }; 91 103 -
trunk/Source/WebKit/ChangeLog
r225399 r225403 1 2017-12-01 Brady Eidson <beidson@apple.com> 2 3 Add Internals.terminateServiceWorker, and the ability to restart service workers for postMessage. 4 https://bugs.webkit.org/show_bug.cgi?id=180170 5 6 Reviewed by Chris Dumez. 7 8 * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: 9 (WebKit::WebSWServerConnection::startFetch): 10 (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): 11 * StorageProcess/ServiceWorker/WebSWServerConnection.h: 12 * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: 13 14 * StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp: 15 (WebKit::WebSWServerToContextConnection::syncTerminateWorker): 16 * StorageProcess/ServiceWorker/WebSWServerToContextConnection.h: 17 18 * StorageProcess/StorageToWebProcessConnection.cpp: 19 (WebKit::StorageToWebProcessConnection::didReceiveSyncMessage): 20 21 * WebProcess/Storage/WebSWClientConnection.cpp: 22 (WebKit::WebSWClientConnection::syncTerminateWorker): 23 * WebProcess/Storage/WebSWClientConnection.h: 24 25 * WebProcess/Storage/WebSWContextManagerConnection.cpp: 26 (WebKit::WebSWContextManagerConnection::terminateWorker): 27 (WebKit::WebSWContextManagerConnection::syncTerminateWorker): 28 * WebProcess/Storage/WebSWContextManagerConnection.h: 29 * WebProcess/Storage/WebSWContextManagerConnection.messages.in: 30 31 * WebProcess/Storage/WebToStorageProcessConnection.cpp: 32 (WebKit::WebToStorageProcessConnection::didReceiveSyncMessage): 33 * WebProcess/Storage/WebToStorageProcessConnection.h: 34 1 35 2017-12-01 Youenn Fablet <youenn@apple.com> 2 36 -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
r225251 r225403 119 119 void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options, const IPC::FormDataReference& formData) 120 120 { 121 // It's possible this specific worker cannot be re-run (e.g. its registration has been removed) 122 if (serviceWorkerIdentifier && !server().invokeRunServiceWorker(*serviceWorkerIdentifier)) 123 return; 124 125 // FIXME: If we don't have a ServiceWorkerIdentifier here then we need to create and run the appropriate Service Worker, 126 // but it's unclear that we have enough information here to do that. 127 121 128 sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch { identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options, formData }); 122 129 } … … 124 131 void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationServiceWorkerIdentifier, const IPC::DataReference& message, DocumentIdentifier sourceContextIdentifier, ServiceWorkerClientData&& sourceData) 125 132 { 133 // It's possible this specific worker cannot be re-run (e.g. its registration has been removed) 134 if (!server().invokeRunServiceWorker(destinationServiceWorkerIdentifier)) 135 return; 136 126 137 ServiceWorkerClientIdentifier sourceIdentifier { identifier(), sourceContextIdentifier }; 127 138 sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope { destinationServiceWorkerIdentifier, message, sourceIdentifier, WTFMove(sourceData) }); -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
r225251 r225403 55 55 void disconnectedFromWebProcess(); 56 56 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 57 void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&); 57 58 58 59 PAL::SessionID sessionID() const { return m_sessionID; } -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
r225251 r225403 41 41 RegisterServiceWorkerClient(struct WebCore::SecurityOriginData topOrigin, WebCore::DocumentIdentifier identifier, struct WebCore::ServiceWorkerClientData data) 42 42 UnregisterServiceWorkerClient(WebCore::DocumentIdentifier identifier) 43 44 SyncTerminateWorker(WebCore::ServiceWorkerIdentifier workerIdentifier) -> () 43 45 } 44 46 -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp
r224909 r225403 77 77 } 78 78 79 void WebSWServerToContextConnection::syncTerminateWorker(ServiceWorkerIdentifier serviceWorkerIdentifier) 80 { 81 sendSync(Messages::WebSWContextManagerConnection::SyncTerminateWorker(serviceWorkerIdentifier), Messages::WebSWContextManagerConnection::SyncTerminateWorker::Reply()); 82 } 83 79 84 } // namespace WebKit 80 85 -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.h
r224909 r225403 60 60 void fireActivateEvent(WebCore::ServiceWorkerIdentifier) final; 61 61 void terminateWorker(WebCore::ServiceWorkerIdentifier) final; 62 void syncTerminateWorker(WebCore::ServiceWorkerIdentifier) final; 62 63 63 64 Ref<IPC::Connection> m_ipcConnection; -
trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp
r225289 r225403 109 109 } 110 110 111 #if ENABLE(SERVICE_WORKER) 112 if (decoder.messageReceiverName() == Messages::WebSWServerConnection::messageReceiverName()) { 113 auto iterator = m_swConnections.find(makeObjectIdentifier<SWServerConnectionIdentifierType>(decoder.destinationID())); 114 if (iterator != m_swConnections.end()) 115 iterator->value->didReceiveSyncMessage(connection, decoder, replyEncoder); 116 return; 117 } 118 #endif 119 111 120 ASSERT_NOT_REACHED(); 112 121 } -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
r225399 r225403 191 191 } 192 192 193 void WebSWClientConnection::syncTerminateWorker(ServiceWorkerIdentifier identifier) 194 { 195 sendSync(Messages::WebSWServerConnection::SyncTerminateWorker(identifier), Messages::WebSWServerConnection::SyncTerminateWorker::Reply()); 196 } 197 193 198 } // namespace WebKit 194 199 -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
r225399 r225403 67 67 void connectionToServerLost(); 68 68 69 void syncTerminateWorker(WebCore::ServiceWorkerIdentifier) final; 70 69 71 private: 70 72 WebSWClientConnection(IPC::Connection&, PAL::SessionID); -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
r225298 r225403 167 167 void WebSWContextManagerConnection::terminateWorker(ServiceWorkerIdentifier identifier) 168 168 { 169 SWContextManager::singleton().terminateWorker(identifier); 169 SWContextManager::singleton().terminateWorker(identifier, nullptr); 170 } 171 172 void WebSWContextManagerConnection::syncTerminateWorker(ServiceWorkerIdentifier identifier, Ref<Messages::WebSWContextManagerConnection::SyncTerminateWorker::DelayedReply>&& reply) 173 { 174 SWContextManager::singleton().terminateWorker(identifier, [reply = WTFMove(reply)] { 175 reply->send(); 176 }); 170 177 } 171 178 -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
r225298 r225403 30 30 #include "Connection.h" 31 31 #include "MessageReceiver.h" 32 #include "WebSWContextManagerConnectionMessages.h" 32 33 #include <WebCore/SWContextManager.h> 33 34 #include <WebCore/ServiceWorkerTypes.h> … … 52 53 53 54 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 55 void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final; 54 56 55 57 private: … … 71 73 void fireActivateEvent(WebCore::ServiceWorkerIdentifier); 72 74 void terminateWorker(WebCore::ServiceWorkerIdentifier); 75 void syncTerminateWorker(WebCore::ServiceWorkerIdentifier, Ref<Messages::WebSWContextManagerConnection::SyncTerminateWorker::DelayedReply>&&); 73 76 74 77 Ref<IPC::Connection> m_connectionToStorageProcess; -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in
r225008 r225403 30 30 FireActivateEvent(WebCore::ServiceWorkerIdentifier identifier) 31 31 TerminateWorker(WebCore::ServiceWorkerIdentifier identifier) 32 SyncTerminateWorker(WebCore::ServiceWorkerIdentifier identifier) -> () Delayed 32 33 } 33 34 -
trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp
r225399 r225403 87 87 } 88 88 89 void WebToStorageProcessConnection::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) 90 { 91 #if ENABLE(SERVICE_WORKER) 92 if (decoder.messageReceiverName() == Messages::WebSWContextManagerConnection::messageReceiverName()) { 93 ASSERT(SWContextManager::singleton().connection()); 94 if (auto* contextManagerConnection = SWContextManager::singleton().connection()) 95 static_cast<WebSWContextManagerConnection&>(*contextManagerConnection).didReceiveSyncMessage(connection, decoder, replyEncoder); 96 return; 97 } 98 #endif 99 ASSERT_NOT_REACHED(); 100 } 101 89 102 void WebToStorageProcessConnection::didClose(IPC::Connection& connection) 90 103 { -
trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.h
r225399 r225403 63 63 // IPC::Connection::Client 64 64 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; 65 void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override; 65 66 void didClose(IPC::Connection&) override; 66 67 void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
Note: See TracChangeset
for help on using the changeset viewer.