Register Documents as ServiceWorker clients to the StorageProcess
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 01:50:03 +0000 (01:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 01:50:03 +0000 (01:50 +0000)
commitd850f95ca14be6088254bb021ac05d3c41b52575
tree4f1841a62b3addae599c2a8e9b059d929f544472
parentf652189120ee80320320005f2221d596d48af2aa
Register Documents as ServiceWorker clients to the StorageProcess
https://bugs.webkit.org/show_bug.cgi?id=180047

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

Source/WebCore:

No change of behavior.
These changes will be covered when implementing ServiceWorker Clients API.

Registering a document when being created by DocumentLoader.
In the future, we may restrict registration to only documents related to origins that have some ongoing service worker activity.
This would require to keep track of which documents are registered so that we unregister these ones.
This would also require to register existing documents when one of the document with the same origin starts registering a service worker.
Unregistering a document inside prepareForDestruction.

Storing all clients in SWServer as a HasMap keyed by ClientOrigin.
Processing will then iterate through the list of clients scoped by the client origin.

Adding a ClientOrigin class as a pair of top origin and frame origin since service workers will be related based on that information.

* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::prepareForDestruction):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::commitData):
* page/ClientOrigin.h: Added.
(WebCore::ClientOrigin::emptyKey):
(WebCore::ClientOrigin::hash const):
(WebCore::ClientOrigin::operator== const):
(WTF::ClientOriginKeyHash::hash):
(WTF::ClientOriginKeyHash::equal):
(WTF::HashTraits<WebCore::ClientOrigin>::emptyValue):
(WTF::HashTraits<WebCore::ClientOrigin>::constructDeletedValue):
(WTF::HashTraits<WebCore::ClientOrigin>::isDeletedValue):
* workers/service/ServiceWorkerClientIdentifier.h:
(WebCore::ServiceWorkerClientIdentifier::operator== const):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::registerServiceWorkerClient):
(WebCore::SWServer::unregisterServiceWorkerClient):
* workers/service/server/SWServer.h:

Source/WebKit:

Adding IPC to register/unregister clients to the storage process.
This will be used to enable service worker termination, and implementation of Clients API.

WebSWServerConnection keeps a hash map of all its related clients.
This allows unregistering these clients if the corresponding web process crashes.

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::~WebSWServerConnection):
(WebKit::WebSWServerConnection::registerServiceWorkerClient):
(WebKit::WebSWServerConnection::unregisterServiceWorkerClient):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* StorageProcess/ServiceWorker/WebSWServerToContextConnection.h:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::registerServiceWorkerClient):
(WebKit::WebSWClientConnection::unregisterServiceWorkerClient):
* WebProcess/Storage/WebSWClientConnection.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225251 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/page/ClientOrigin.h [new file with mode: 0644]
Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h
Source/WebCore/workers/service/server/SWClientConnection.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h