12017-08-24 Brady Eidson <beidson@apple.com>
2
3 Introduce ServerWorkerRegistration task queues.
4 https://bugs.webkit.org/show_bug.cgi?id=175851
5
6 Reviewed by NOBODY (OOPS!).
7
8 Test: http/tests/workers/service/registration-task-queue-scheduling-1.html
9
10 This change introduces:
11 - A task thread/queue owned by each SWServer object.
12 - The SWServerRegistration object, which is the in-server representation of a
13 service worker registration scope.
14 - A registration job queue per SWServerRegistration object which actually runs the
15 jobs as tasks on the owning SWServer's thread.
16
17 With that infrastructure in place, it moves the "register" job to something that is
18 scheduled and rejected asynchronously, as opposed to synchronously rejected.
19
20 The test verifies that two different registration scopes (localhost and 127.0.0.1)
21 can both spam the SWServer with registration requests, but neither of their queues
22 starve the other.
23
24 The rest of this change is a lot of support and plumbing for making the above happen.
25
26 * CMakeLists.txt:
27 * WebCore.xcodeproj/project.pbxproj:
28
29 * dom/ExceptionData.cpp:
30 (WebCore::ExceptionData::isolatedCopy const):
31 * dom/ExceptionData.h:
32
33 * workers/service/ServiceWorkerContainer.cpp:
34 (WebCore::ServiceWorkerContainer::addRegistration):
35 (WebCore::ServiceWorkerContainer::connectionIdentifier):
36 * workers/service/ServiceWorkerContainer.h:
37
38 * workers/service/ServiceWorkerJob.cpp:
39 (WebCore::ServiceWorkerJob::ServiceWorkerJob):
40 (WebCore::ServiceWorkerJob::data const): Deleted.
41 * workers/service/ServiceWorkerJob.h:
42 (WebCore::ServiceWorkerJob::create):
43 (WebCore::ServiceWorkerJob::data const):
44 (WebCore::ServiceWorkerJob::createRegisterJob): Deleted.
45
46 * workers/service/ServiceWorkerJobClient.h:
47
48 * workers/service/ServiceWorkerJobData.cpp:
49 (WebCore::ServiceWorkerJobData::ServiceWorkerJobData):
50 (WebCore::ServiceWorkerJobData::registrationKey const):
51 (WebCore::ServiceWorkerJobData::isolatedCopy const):
52 * workers/service/ServiceWorkerJobData.h:
53 (WebCore::ServiceWorkerJobData::jobIdentifier const):
54 (WebCore::ServiceWorkerJobData::connectionIdentifier const):
55 (WebCore::ServiceWorkerJobData::encode const):
56 (WebCore::ServiceWorkerJobData::decode):
57
58 * workers/service/ServiceWorkerRegistrationKey.cpp:
59 (WebCore::ServiceWorkerRegistrationKey::emptyKey):
60 (WebCore::ServiceWorkerRegistrationKey::hash const):
61 (WebCore::ServiceWorkerRegistrationKey::operator== const):
62 * workers/service/ServiceWorkerRegistrationKey.h:
63 (WTF::ServiceWorkerRegistrationKeyHash::hash):
64 (WTF::ServiceWorkerRegistrationKeyHash::equal):
65 (WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::emptyValue):
66 (WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::constructDeletedValue):
67 (WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::isDeletedValue):
68
69 * workers/service/ServiceWorkerRegistrationOptions.cpp:
70 (WebCore::RegistrationOptions::isolatedCopy const):
71 * workers/service/ServiceWorkerRegistrationOptions.h:
72 (WebCore::RegistrationOptions::encode const):
73 (WebCore::RegistrationOptions::decode):
74
75 * workers/service/server/SWClientConnection.h:
76
77 * workers/service/server/SWServer.cpp:
78 (WebCore::SWServer::Connection::Connection):
79 (WebCore::SWServer::~SWServer):
80 (WebCore::SWServer::Connection::scheduleJobInServer):
81 (WebCore::SWServer::SWServer):
82 (WebCore::SWServer::scheduleJob):
83 (WebCore::SWServer::rejectJob):
84 (WebCore::SWServer::taskThreadEntryPoint):
85 (WebCore::SWServer::postTask):
86 (WebCore::SWServer::postTaskReply):
87 (WebCore::SWServer::handleTaskRepliesOnMainThread):
88 (WebCore::SWServer::registerConnection):
89 (WebCore::SWServer::unregisterConnection):
90 * workers/service/server/SWServer.h:
91 (WebCore::SWServer::Connection::identifier const):
92
93 * workers/service/server/SWServerRegistration.cpp: Added.
94 (WebCore::SWServerRegistration::SWServerRegistration):
95 (WebCore::SWServerRegistration::~SWServerRegistration):
96 (WebCore::SWServerRegistration::enqueueJob):
97 (WebCore::SWServerRegistration::startNextJob):
98 (WebCore::SWServerRegistration::performCurrentJob):
99 (WebCore::SWServerRegistration::rejectCurrentJob):
100 (WebCore::SWServerRegistration::finishCurrentJob):
101 * workers/service/server/SWServerRegistration.h:
102