Introduce ServerWorkerRegistration task queues.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Aug 2017 18:57:44 +0000 (18:57 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Aug 2017 18:57:44 +0000 (18:57 +0000)
commit300ba6b434b0c8571789d6c58084df7bdebce24f
tree324f4a5ca6067b9f4e30b62fb6dc245251c24f76
parentcabd9d32dd2256439671d5eda43ed91972c75404
Introduce ServerWorkerRegistration task queues.
https://bugs.webkit.org/show_bug.cgi?id=175851

Reviewed by Andy Estes.

Source/WebCore:

Test: http/tests/workers/service/registration-task-queue-scheduling-1.html

This change introduces:
- A task thread/queue owned by each SWServer object.
- The SWServerRegistration object, which is the in-server representation of a
  service worker registration scope.
- A registration job queue per SWServerRegistration object which actually runs the
  jobs as tasks on the owning SWServer's thread.

With that infrastructure in place, it moves the "register" job to something that is
scheduled and rejected asynchronously, as opposed to synchronously rejected.

The test verifies that two different registration scopes (localhost and 127.0.0.1)
can both spam the SWServer with registration requests, but neither of their queues
starve the other.

The rest of this change is a lot of support and plumbing for making the above happen.

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

* dom/ExceptionData.cpp:
(WebCore::ExceptionData::isolatedCopy const):
* dom/ExceptionData.h:

* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::connectionIdentifier):
* workers/service/ServiceWorkerContainer.h:

* workers/service/ServiceWorkerJob.cpp:
(WebCore::ServiceWorkerJob::ServiceWorkerJob):
(WebCore::ServiceWorkerJob::data const): Deleted.
* workers/service/ServiceWorkerJob.h:
(WebCore::ServiceWorkerJob::create):
(WebCore::ServiceWorkerJob::data const):
(WebCore::ServiceWorkerJob::createRegisterJob): Deleted.

* workers/service/ServiceWorkerJobClient.h:

* workers/service/ServiceWorkerJobData.cpp:
(WebCore::ServiceWorkerJobData::ServiceWorkerJobData):
(WebCore::ServiceWorkerJobData::registrationKey const):
(WebCore::ServiceWorkerJobData::isolatedCopy const):
* workers/service/ServiceWorkerJobData.h:
(WebCore::ServiceWorkerJobData::jobIdentifier const):
(WebCore::ServiceWorkerJobData::connectionIdentifier const):
(WebCore::ServiceWorkerJobData::encode const):
(WebCore::ServiceWorkerJobData::decode):

* workers/service/ServiceWorkerRegistrationKey.cpp:
(WebCore::ServiceWorkerRegistrationKey::emptyKey):
(WebCore::ServiceWorkerRegistrationKey::hash const):
(WebCore::ServiceWorkerRegistrationKey::operator== const):
* workers/service/ServiceWorkerRegistrationKey.h:
(WTF::ServiceWorkerRegistrationKeyHash::hash):
(WTF::ServiceWorkerRegistrationKeyHash::equal):
(WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::emptyValue):
(WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::constructDeletedValue):
(WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::isDeletedValue):

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

* workers/service/server/SWClientConnection.h:

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::Connection::Connection):
(WebCore::SWServer::~SWServer):
(WebCore::SWServer::Connection::scheduleJobInServer):
(WebCore::SWServer::SWServer):
(WebCore::SWServer::scheduleJob):
(WebCore::SWServer::rejectJob):
(WebCore::SWServer::taskThreadEntryPoint):
(WebCore::SWServer::postTask):
(WebCore::SWServer::postTaskReply):
(WebCore::SWServer::handleTaskRepliesOnMainThread):
(WebCore::SWServer::registerConnection):
(WebCore::SWServer::unregisterConnection):
* workers/service/server/SWServer.h:
(WebCore::SWServer::Connection::identifier const):

* workers/service/server/SWServerRegistration.cpp: Added.
(WebCore::SWServerRegistration::SWServerRegistration):
(WebCore::SWServerRegistration::~SWServerRegistration):
(WebCore::SWServerRegistration::enqueueJob):
(WebCore::SWServerRegistration::startNextJob):
(WebCore::SWServerRegistration::performCurrentJob):
(WebCore::SWServerRegistration::rejectCurrentJob):
(WebCore::SWServerRegistration::finishCurrentJob):
* workers/service/server/SWServerRegistration.h:

Source/WebKit:

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::WebSWServerConnection):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
(WebKit::WebSWServerConnection::identifier const): Deleted.

* WebProcess/Storage/WebSWClientConnection.h:
(WebKit::WebSWClientConnection::identifier const): Deleted.

LayoutTests:

* http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt: Added.
* http/tests/workers/service/registration-task-queue-scheduling-1.html: Added.
* http/tests/workers/service/resources/registration-task-queue-scheduling-1-second-window.html: Added.
* http/tests/workers/service/resources/registration-task-queue-scheduling-1.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221198 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/registration-task-queue-scheduling-1.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1-second-window.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/ExceptionData.cpp [moved from Source/WebCore/workers/service/ServiceWorkerRegistrationParameters.cpp with 87% similarity]
Source/WebCore/dom/ExceptionData.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.h
Source/WebCore/workers/service/ServiceWorkerJob.cpp
Source/WebCore/workers/service/ServiceWorkerJob.h
Source/WebCore/workers/service/ServiceWorkerJobClient.h
Source/WebCore/workers/service/ServiceWorkerJobData.cpp [new file with mode: 0644]
Source/WebCore/workers/service/ServiceWorkerJobData.h
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp [new file with mode: 0644]
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h [new file with mode: 0644]
Source/WebCore/workers/service/ServiceWorkerRegistrationOptions.cpp [moved from Source/WebCore/workers/service/ServiceWorkerRegistrationParameters.h with 84% similarity]
Source/WebCore/workers/service/ServiceWorkerRegistrationOptions.h
Source/WebCore/workers/service/server/SWClientConnection.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerRegistration.cpp [new file with mode: 0644]
Source/WebCore/workers/service/server/SWServerRegistration.h [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h