12017-08-30 Brady Eidson <beidson@apple.com>
2
3 Implement all of "Register" right up until where the script is fetched.
4 https://bugs.webkit.org/show_bug.cgi?id=176082
5
6 Reviewed by NOBODY (OOPS!).
7
8 Test: http/tests/workers/service/basic-register-exceptions.html
9
10 This patch implements every detail of the "Register" and "Update" algorithms right up to
11 where we would actually fetch the service worker script file.
12
13 It also includes miscellaneous refactoring and cleanup along the way.
14
15 * CMakeLists.txt:
16 * WebCore.xcodeproj/project.pbxproj:
17
18 * page/SecurityOrigin.cpp:
19 (WebCore::shouldTreatAsPotentiallyTrustworthy): Expose in the header for other files to use.
20 * page/SecurityOrigin.h:
21
22 * workers/service/ServiceWorkerContainer.cpp:
23 (WebCore::ServiceWorkerContainer::addRegistration): Add some more exception cases from the spec.
24 (WebCore::ServiceWorkerContainer::scheduleJob): Use the correct job identifier.
25 (WebCore::ServiceWorkerContainer::jobFailedWithException):
26 (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
27 (WebCore::ServiceWorkerContainer::jobDidFinish):
28 * workers/service/ServiceWorkerContainer.h:
29
30 * workers/service/ServiceWorkerJob.cpp:
31 (WebCore::ServiceWorkerJob::ServiceWorkerJob):
32 (WebCore::ServiceWorkerJob::failedWithException): Call through to the client to handle the failure.
33 (WebCore::ServiceWorkerJob::resolvedWithRegistration): Call through to the client to handle success.
34 * workers/service/ServiceWorkerJob.h:
35 (WebCore::ServiceWorkerJob::promise):
36 (WebCore::ServiceWorkerJob::identifier const): Deleted. Rely on the identifier from the JobData.
37
38 * workers/service/ServiceWorkerJobClient.h:
39
40 * workers/service/ServiceWorkerJobData.cpp:
41 (WebCore::ServiceWorkerJobData::ServiceWorkerJobData):
42 (WebCore::ServiceWorkerJobData::isolatedCopy const):
43 * workers/service/ServiceWorkerJobData.h:
44 (WebCore::ServiceWorkerJobData::identifier const):
45 (WebCore::ServiceWorkerJobData::encode const):
46 (WebCore::ServiceWorkerJobData::decode):
47 (WebCore::ServiceWorkerJobData::jobIdentifier const): Deleted.
48
49 * workers/service/ServiceWorkerRegistration.cpp:
50 (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration): Make this class an ActiveDOMObject
51 both because it *is* an active DOM object and because we need to get at the ScriptExecutionContext.
52 * workers/service/ServiceWorkerRegistration.h:
53
54 Add a class to encapsulate everything about a registration for encode/decode/crossthread:
55 * workers/service/ServiceWorkerRegistrationData.cpp:
56 (WebCore::ServiceWorkerRegistrationData::isolatedCopy const):
57 * workers/service/ServiceWorkerRegistrationData.h:
58 (WebCore::ServiceWorkerRegistrationData::encode const):
59 (WebCore::ServiceWorkerRegistrationData::decode):
60
61 * workers/service/ServiceWorkerRegistrationKey.cpp:
62 (WebCore::ServiceWorkerRegistrationKey::isolatedCopy const):
63 * workers/service/ServiceWorkerRegistrationKey.h:
64 (WebCore::ServiceWorkerRegistrationKey::encode const):
65 (WebCore::ServiceWorkerRegistrationKey::decode):
66
67 * workers/service/server/SWClientConnection.cpp:
68 (WebCore::SWClientConnection::scheduleJob):
69 (WebCore::SWClientConnection::jobResolvedInServer):
70 * workers/service/server/SWClientConnection.h:
71
72 * workers/service/server/SWServer.cpp:
73 (WebCore::SWServer::~SWServer):
74 (WebCore::SWServer::Connection::scheduleJobInServer):
75 (WebCore::SWServer::scheduleJob):
76 (WebCore::SWServer::rejectJob):
77 (WebCore::SWServer::resolveJob):
78 * workers/service/server/SWServer.h:
79
80 * workers/service/server/SWServerRegistration.cpp:
81 (WebCore::SWServerRegistration::SWServerRegistration):
82 (WebCore::SWServerRegistration::startNextJob):
83 (WebCore::SWServerRegistration::isEmpty):
84 (WebCore::SWServerRegistration::getNewestWorker): Implement "Get Newest Worker" algorithm.
85 (WebCore::SWServerRegistration::runRegisterJob): Implement the rest of the "Register" algorithm.
86 (WebCore::SWServerRegistration::runUpdateJob): Implement every part of "Update" up to where we would fetch.
87 (WebCore::SWServerRegistration::rejectWithExceptionOnMainThread):
88 (WebCore::SWServerRegistration::resolveWithRegistrationOnMainThread):
89 (WebCore::SWServerRegistration::resolveCurrentJob):
90 (WebCore::SWServerRegistration::data const):
91 (WebCore::SWServerRegistration::performCurrentJob): Deleted.
92 * workers/service/server/SWServerRegistration.h:
93 (WebCore::SWServerRegistration::identifier const):
94
95 Add a stub class to represent "active service workers" in the SWServer:
96 * workers/service/server/SWServerWorker.cpp:
97 (WebCore::SWServerWorker::SWServerWorker):
98 (WebCore::SWServerWorker::~SWServerWorker):
99 * workers/service/server/SWServerWorker.h:
100 (WebCore::SWServerWorker::scriptURL const):
101