1 | /* |
2 | * Copyright (C) 2010-2018 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 | * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR |
17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
21 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
22 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ |
24 | |
25 | #pragma once |
26 | |
27 | #if ENABLE(SERVICE_WORKER) |
28 | |
29 | #include "ArgumentCoders.h" |
30 | #include "Connection.h" |
31 | #include <WebCore/ServiceWorkerIdentifier.h> |
32 | #include <WebCore/ServiceWorkerJobDataIdentifier.h> |
33 | #include <wtf/Forward.h> |
34 | #include <wtf/Optional.h> |
35 | #include <wtf/ThreadSafeRefCounted.h> |
36 | #include <wtf/text/WTFString.h> |
37 | |
38 | namespace WebCore { |
39 | struct ServiceWorkerClientIdentifier; |
40 | struct ServiceWorkerClientQueryOptions; |
41 | } |
42 | |
43 | namespace Messages { |
44 | namespace WebSWServerToContextConnection { |
45 | |
46 | static inline IPC::StringReference messageReceiverName() |
47 | { |
48 | return IPC::StringReference("WebSWServerToContextConnection" ); |
49 | } |
50 | |
51 | class ScriptContextFailedToStart { |
52 | public: |
53 | typedef std::tuple<const Optional<WebCore::ServiceWorkerJobDataIdentifier>&, const WebCore::ServiceWorkerIdentifier&, const String&> Arguments; |
54 | |
55 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
56 | static IPC::StringReference name() { return IPC::StringReference("ScriptContextFailedToStart" ); } |
57 | static const bool isSync = false; |
58 | |
59 | ScriptContextFailedToStart(const Optional<WebCore::ServiceWorkerJobDataIdentifier>& jobDataIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier, const String& message) |
60 | : m_arguments(jobDataIdentifier, serviceWorkerIdentifier, message) |
61 | { |
62 | } |
63 | |
64 | const Arguments& arguments() const |
65 | { |
66 | return m_arguments; |
67 | } |
68 | |
69 | private: |
70 | Arguments m_arguments; |
71 | }; |
72 | |
73 | class ScriptContextStarted { |
74 | public: |
75 | typedef std::tuple<const Optional<WebCore::ServiceWorkerJobDataIdentifier>&, const WebCore::ServiceWorkerIdentifier&> Arguments; |
76 | |
77 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
78 | static IPC::StringReference name() { return IPC::StringReference("ScriptContextStarted" ); } |
79 | static const bool isSync = false; |
80 | |
81 | ScriptContextStarted(const Optional<WebCore::ServiceWorkerJobDataIdentifier>& jobDataIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier) |
82 | : m_arguments(jobDataIdentifier, serviceWorkerIdentifier) |
83 | { |
84 | } |
85 | |
86 | const Arguments& arguments() const |
87 | { |
88 | return m_arguments; |
89 | } |
90 | |
91 | private: |
92 | Arguments m_arguments; |
93 | }; |
94 | |
95 | class DidFinishInstall { |
96 | public: |
97 | typedef std::tuple<const Optional<WebCore::ServiceWorkerJobDataIdentifier>&, const WebCore::ServiceWorkerIdentifier&, bool> Arguments; |
98 | |
99 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
100 | static IPC::StringReference name() { return IPC::StringReference("DidFinishInstall" ); } |
101 | static const bool isSync = false; |
102 | |
103 | DidFinishInstall(const Optional<WebCore::ServiceWorkerJobDataIdentifier>& jobDataIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier, bool wasSuccessful) |
104 | : m_arguments(jobDataIdentifier, serviceWorkerIdentifier, wasSuccessful) |
105 | { |
106 | } |
107 | |
108 | const Arguments& arguments() const |
109 | { |
110 | return m_arguments; |
111 | } |
112 | |
113 | private: |
114 | Arguments m_arguments; |
115 | }; |
116 | |
117 | class DidFinishActivation { |
118 | public: |
119 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&> Arguments; |
120 | |
121 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
122 | static IPC::StringReference name() { return IPC::StringReference("DidFinishActivation" ); } |
123 | static const bool isSync = false; |
124 | |
125 | explicit DidFinishActivation(const WebCore::ServiceWorkerIdentifier& identifier) |
126 | : m_arguments(identifier) |
127 | { |
128 | } |
129 | |
130 | const Arguments& arguments() const |
131 | { |
132 | return m_arguments; |
133 | } |
134 | |
135 | private: |
136 | Arguments m_arguments; |
137 | }; |
138 | |
139 | class SetServiceWorkerHasPendingEvents { |
140 | public: |
141 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&, bool> Arguments; |
142 | |
143 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
144 | static IPC::StringReference name() { return IPC::StringReference("SetServiceWorkerHasPendingEvents" ); } |
145 | static const bool isSync = false; |
146 | |
147 | SetServiceWorkerHasPendingEvents(const WebCore::ServiceWorkerIdentifier& identifier, bool hasPendingEvents) |
148 | : m_arguments(identifier, hasPendingEvents) |
149 | { |
150 | } |
151 | |
152 | const Arguments& arguments() const |
153 | { |
154 | return m_arguments; |
155 | } |
156 | |
157 | private: |
158 | Arguments m_arguments; |
159 | }; |
160 | |
161 | class SkipWaiting { |
162 | public: |
163 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&, uint64_t> Arguments; |
164 | |
165 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
166 | static IPC::StringReference name() { return IPC::StringReference("SkipWaiting" ); } |
167 | static const bool isSync = false; |
168 | |
169 | SkipWaiting(const WebCore::ServiceWorkerIdentifier& identifier, uint64_t callbackID) |
170 | : m_arguments(identifier, callbackID) |
171 | { |
172 | } |
173 | |
174 | const Arguments& arguments() const |
175 | { |
176 | return m_arguments; |
177 | } |
178 | |
179 | private: |
180 | Arguments m_arguments; |
181 | }; |
182 | |
183 | class WorkerTerminated { |
184 | public: |
185 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&> Arguments; |
186 | |
187 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
188 | static IPC::StringReference name() { return IPC::StringReference("WorkerTerminated" ); } |
189 | static const bool isSync = false; |
190 | |
191 | explicit WorkerTerminated(const WebCore::ServiceWorkerIdentifier& identifier) |
192 | : m_arguments(identifier) |
193 | { |
194 | } |
195 | |
196 | const Arguments& arguments() const |
197 | { |
198 | return m_arguments; |
199 | } |
200 | |
201 | private: |
202 | Arguments m_arguments; |
203 | }; |
204 | |
205 | class FindClientByIdentifier { |
206 | public: |
207 | typedef std::tuple<uint64_t, const WebCore::ServiceWorkerIdentifier&, const WebCore::ServiceWorkerClientIdentifier&> Arguments; |
208 | |
209 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
210 | static IPC::StringReference name() { return IPC::StringReference("FindClientByIdentifier" ); } |
211 | static const bool isSync = false; |
212 | |
213 | FindClientByIdentifier(uint64_t requestIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier, const WebCore::ServiceWorkerClientIdentifier& clientIdentifier) |
214 | : m_arguments(requestIdentifier, serviceWorkerIdentifier, clientIdentifier) |
215 | { |
216 | } |
217 | |
218 | const Arguments& arguments() const |
219 | { |
220 | return m_arguments; |
221 | } |
222 | |
223 | private: |
224 | Arguments m_arguments; |
225 | }; |
226 | |
227 | class MatchAll { |
228 | public: |
229 | typedef std::tuple<uint64_t, const WebCore::ServiceWorkerIdentifier&, const WebCore::ServiceWorkerClientQueryOptions&> Arguments; |
230 | |
231 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
232 | static IPC::StringReference name() { return IPC::StringReference("MatchAll" ); } |
233 | static const bool isSync = false; |
234 | |
235 | MatchAll(uint64_t matchAllRequestIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier, const WebCore::ServiceWorkerClientQueryOptions& options) |
236 | : m_arguments(matchAllRequestIdentifier, serviceWorkerIdentifier, options) |
237 | { |
238 | } |
239 | |
240 | const Arguments& arguments() const |
241 | { |
242 | return m_arguments; |
243 | } |
244 | |
245 | private: |
246 | Arguments m_arguments; |
247 | }; |
248 | |
249 | class Claim { |
250 | public: |
251 | typedef std::tuple<uint64_t, const WebCore::ServiceWorkerIdentifier&> Arguments; |
252 | |
253 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
254 | static IPC::StringReference name() { return IPC::StringReference("Claim" ); } |
255 | static const bool isSync = false; |
256 | |
257 | Claim(uint64_t claimRequestIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier) |
258 | : m_arguments(claimRequestIdentifier, serviceWorkerIdentifier) |
259 | { |
260 | } |
261 | |
262 | const Arguments& arguments() const |
263 | { |
264 | return m_arguments; |
265 | } |
266 | |
267 | private: |
268 | Arguments m_arguments; |
269 | }; |
270 | |
271 | class SetScriptResource { |
272 | public: |
273 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&, const URL&, const String&, const URL&, const String&> Arguments; |
274 | |
275 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
276 | static IPC::StringReference name() { return IPC::StringReference("SetScriptResource" ); } |
277 | static const bool isSync = false; |
278 | |
279 | SetScriptResource(const WebCore::ServiceWorkerIdentifier& identifier, const URL& scriptURL, const String& script, const URL& responseURL, const String& mimeType) |
280 | : m_arguments(identifier, scriptURL, script, responseURL, mimeType) |
281 | { |
282 | } |
283 | |
284 | const Arguments& arguments() const |
285 | { |
286 | return m_arguments; |
287 | } |
288 | |
289 | private: |
290 | Arguments m_arguments; |
291 | }; |
292 | |
293 | } // namespace WebSWServerToContextConnection |
294 | } // namespace Messages |
295 | |
296 | #endif // ENABLE(SERVICE_WORKER) |
297 | |