Massive "Server-process-to-context-process" connection overhaul.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Nov 2017 03:58:01 +0000 (03:58 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Nov 2017 03:58:01 +0000 (03:58 +0000)
commit8ab31ed904d83ad11fe100d714ac0211354ed5bd
tree9841644db045fba75e2b0c9f07e64ef92b9abd65
parentdc34b100cc1d21759821b192e419e7ac9c6a3c52
Massive "Server-process-to-context-process" connection overhaul.
https://bugs.webkit.org/show_bug.cgi?id=179554

Reviewed by Chris Dumez.

Source/WebCore:

No new tests (Refactor, no behavior change).

Having the SWServer::Connection object be overloaded to mean both client->server and server->context
was the wrong design and was starting to crumble under its own weight.

So this patch introduces a SWServerToContextConnection to manage the StorageProcess-side of connections
to context processes.

Any message that is specifically about the connection between the StorageProcess and context process
should use this connection going forward.

Right now there is only one context process, but this design keeps us ready for that to change.

This patch also gets rid of a lot of "server connection identifier" integers being passed amongst processes
that were actually pointless.

This patch is also a prerequisite for many things that are coming up soon, such as termination.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

* workers/service/ServiceWorkerContextData.cpp:
(WebCore::ServiceWorkerContextData::isolatedCopy const):
* workers/service/ServiceWorkerContextData.h:
(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):

* workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::ServiceWorkerGlobalScope):
* workers/service/ServiceWorkerGlobalScope.h:
(WebCore::ServiceWorkerGlobalScope::serverConnectionIdentifier const): Deleted.

* workers/service/ServiceWorkerTypes.h:

* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
(WebCore::ServiceWorkerThread::createWorkerGlobalScope):
* workers/service/context/ServiceWorkerThread.h:
(WebCore::ServiceWorkerThread::serverConnectionIdentifier const): Deleted.

* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
(WebCore::ServiceWorkerThreadProxy::create): Deleted.
* workers/service/context/ServiceWorkerThreadProxy.h:

* workers/service/server/SWServer.cpp:
(WebCore::generateServiceWorkerIdentifier):
(WebCore::SWServer::~SWServer):
(WebCore::SWServer::SWServer):
(WebCore::SWServer::scriptContextFailedToStart):
(WebCore::SWServer::scriptContextStarted):
(WebCore::SWServer::didFinishInstall):
(WebCore::SWServer::didFinishActivation):
(WebCore::SWServer::didResolveRegistrationPromise):
(WebCore::SWServer::updateWorker):
(WebCore::SWServer::serverToContextConnectionCreated):
(WebCore::SWServer::installContextData):
(WebCore::SWServer::fireInstallEvent):
(WebCore::SWServer::fireActivateEvent):
(WebCore::SWServer::Connection::didFinishInstall): Deleted.
(WebCore::SWServer::Connection::didFinishActivation): Deleted.
(WebCore::SWServer::Connection::setServiceWorkerHasPendingEvents): Deleted.
(WebCore::SWServer::Connection::scriptContextFailedToStart): Deleted.
(WebCore::SWServer::Connection::scriptContextStarted): Deleted.
(WebCore::SWServer::setServiceWorkerHasPendingEvents): Deleted.
* workers/service/server/SWServer.h:

* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptContextFailedToStart):
(WebCore::SWServerJobQueue::scriptContextStarted):
(WebCore::SWServerJobQueue::install):
(WebCore::SWServerJobQueue::didResolveRegistrationPromise):
(WebCore::SWServerJobQueue::didFinishInstall):
(WebCore::SWServerJobQueue::tryActivate):
(WebCore::SWServerJobQueue::activate):
* workers/service/server/SWServerJobQueue.h:

* workers/service/server/SWServerRegistration.cpp:
(WebCore::generateServiceWorkerRegistrationIdentifier):

* workers/service/server/SWServerToContextConnection.cpp: Added.
(WebCore::generateServerToContextConnectionIdentifier):
(WebCore::SWServerToContextConnection::SWServerToContextConnection):
(WebCore::SWServerToContextConnection::~SWServerToContextConnection):
(WebCore::SWServerToContextConnection::connectionForIdentifier):
(WebCore::SWServerToContextConnection::globalServerToContextConnection):
(WebCore::SWServerToContextConnection::scriptContextFailedToStart):
(WebCore::SWServerToContextConnection::scriptContextStarted):
(WebCore::SWServerToContextConnection::didFinishInstall):
(WebCore::SWServerToContextConnection::didFinishActivation):
(WebCore::SWServerToContextConnection::setServiceWorkerHasPendingEvents):
* workers/service/server/SWServerToContextConnection.h: Copied from Source/WebCore/workers/service/server/SWServerWorker.h.
(WebCore::SWServerToContextConnection::identifier const):

* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::existingWorkerForIdentifier):
(WebCore::SWServerWorker::SWServerWorker):
(WebCore::SWServerWorker::~SWServerWorker):
(WebCore::SWServerWorker::scriptContextFailedToStart):
(WebCore::SWServerWorker::scriptContextStarted):
(WebCore::SWServerWorker::didFinishInstall):
(WebCore::SWServerWorker::didFinishActivation):
* workers/service/server/SWServerWorker.h:
(WebCore::SWServerWorker::create):
(WebCore::SWServerWorker::registrationKey const):
(WebCore::SWServerWorker::contextConnectionIdentifier const):

Source/WebKit:

* DerivedSources.make:
* WebKit.xcodeproj/project.pbxproj:

* Shared/WebCoreArgumentCoders.h:

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::sendToContextProcess):
(WebKit::WebSWServerConnection::installServiceWorkerContext): Deleted.
(WebKit::WebSWServerConnection::fireInstallEvent): Deleted.
(WebKit::WebSWServerConnection::fireActivateEvent): Deleted.
(WebKit::WebSWServerConnection::setContextConnection): Deleted.
* StorageProcess/ServiceWorker/WebSWServerConnection.h:

* StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp: Copied from Source/WebCore/workers/service/server/SWServerWorker.cpp.
(WebKit::WebSWServerToContextConnection::WebSWServerToContextConnection):
(WebKit::WebSWServerToContextConnection::messageSenderConnection):
(WebKit::WebSWServerToContextConnection::messageSenderDestinationID):
(WebKit::WebSWServerToContextConnection::connectionClosed):
(WebKit::WebSWServerToContextConnection::installServiceWorkerContext):
(WebKit::WebSWServerToContextConnection::fireInstallEvent):
(WebKit::WebSWServerToContextConnection::fireActivateEvent):
* StorageProcess/ServiceWorker/WebSWServerToContextConnection.h: Copied from Source/WebCore/workers/service/ServiceWorkerTypes.h.
(WebKit::WebSWServerToContextConnection::create):
(WebKit::WebSWServerToContextConnection::ipcConnection const):
* StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in: Copied from Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in.

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::didClose):
(WebKit::StorageProcess::didReceiveMessage):
(WebKit::StorageProcess::globalServerToContextConnection):
(WebKit::StorageProcess::createServerToContextConnection):
(WebKit::StorageProcess::didGetWorkerContextProcessConnection):
(WebKit::StorageProcess::workerContextProcessConnection): Deleted.
(WebKit::StorageProcess::createWorkerContextProcessConnection): Deleted.
(WebKit::StorageProcess::serviceWorkerContextFailedToStart): Deleted.
(WebKit::StorageProcess::serviceWorkerContextStarted): Deleted.
(WebKit::StorageProcess::didFinishServiceWorkerInstall): Deleted.
(WebKit::StorageProcess::didFinishServiceWorkerActivation): Deleted.
(WebKit::StorageProcess::setServiceWorkerHasPendingEvents): Deleted.
* StorageProcess/StorageProcess.h:
* StorageProcess/StorageProcess.messages.in:

* StorageProcess/StorageToWebProcessConnection.cpp:
(WebKit::StorageToWebProcessConnection::didReceiveMessage):
(WebKit::StorageToWebProcessConnection::establishSWServerConnection):
(WebKit::StorageToWebProcessConnection::workerContextProcessConnectionCreated):

* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
(WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage):
(WebKit::WebSWContextManagerConnection::fireInstallEvent):
(WebKit::WebSWContextManagerConnection::fireActivateEvent):
(WebKit::WebSWContextManagerConnection::didFinishInstall):
(WebKit::WebSWContextManagerConnection::didFinishActivation):
(WebKit::WebSWContextManagerConnection::setServiceWorkerHasPendingEvents):
* WebProcess/Storage/WebSWContextManagerConnection.h:
* WebProcess/Storage/WebSWContextManagerConnection.messages.in:

Source/WTF:

* wtf/ObjectIdentifier.h:
(WTF::generateObjectIdentifier):
(WTF::makeObjectIdentifier): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224801 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/ObjectIdentifier.h
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/workers/service/ServiceWorkerContextData.cpp
Source/WebCore/workers/service/ServiceWorkerContextData.h
Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp
Source/WebCore/workers/service/ServiceWorkerGlobalScope.h
Source/WebCore/workers/service/ServiceWorkerTypes.h
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/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerJobQueue.cpp
Source/WebCore/workers/service/server/SWServerJobQueue.h
Source/WebCore/workers/service/server/SWServerRegistration.cpp
Source/WebCore/workers/service/server/SWServerToContextConnection.cpp [new file with mode: 0644]
Source/WebCore/workers/service/server/SWServerToContextConnection.h [new file with mode: 0644]
Source/WebCore/workers/service/server/SWServerWorker.cpp
Source/WebCore/workers/service/server/SWServerWorker.h
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources.make
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp [new file with mode: 0644]
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.h [new file with mode: 0644]
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in [new file with mode: 0644]
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/StorageProcess/StorageProcess.h
Source/WebKit/StorageProcess/StorageProcess.messages.in
Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in