1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Message definition file, included multiple times, hence no include guard.
10 #include "base/strings/string16.h"
11 #include "content/common/service_worker/service_worker_status_code.h"
12 #include "content/common/service_worker/service_worker_types.h"
13 #include "ipc/ipc_message_macros.h"
14 #include "ipc/ipc_param_traits.h"
15 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h"
16 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h"
17 #include "third_party/WebKit/public/platform/WebServiceWorkerCacheError.h"
18 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
19 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
22 #undef IPC_MESSAGE_EXPORT
23 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
25 #define IPC_MESSAGE_START ServiceWorkerMsgStart
27 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerError::ErrorType
,
28 blink::WebServiceWorkerError::ErrorTypeLast
)
30 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerEventResult
,
31 blink::WebServiceWorkerEventResultLast
)
33 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerState
,
34 blink::WebServiceWorkerStateLast
)
36 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerResponseType
,
37 blink::WebServiceWorkerResponseTypeLast
)
39 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerFetchRequest
)
40 IPC_STRUCT_TRAITS_MEMBER(mode
)
41 IPC_STRUCT_TRAITS_MEMBER(request_context_type
)
42 IPC_STRUCT_TRAITS_MEMBER(frame_type
)
43 IPC_STRUCT_TRAITS_MEMBER(url
)
44 IPC_STRUCT_TRAITS_MEMBER(method
)
45 IPC_STRUCT_TRAITS_MEMBER(headers
)
46 IPC_STRUCT_TRAITS_MEMBER(blob_uuid
)
47 IPC_STRUCT_TRAITS_MEMBER(blob_size
)
48 IPC_STRUCT_TRAITS_MEMBER(referrer
)
49 IPC_STRUCT_TRAITS_MEMBER(credentials_mode
)
50 IPC_STRUCT_TRAITS_MEMBER(is_reload
)
51 IPC_STRUCT_TRAITS_END()
53 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult
,
54 content::SERVICE_WORKER_FETCH_EVENT_LAST
)
56 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerResponse
)
57 IPC_STRUCT_TRAITS_MEMBER(url
)
58 IPC_STRUCT_TRAITS_MEMBER(status_code
)
59 IPC_STRUCT_TRAITS_MEMBER(status_text
)
60 IPC_STRUCT_TRAITS_MEMBER(response_type
)
61 IPC_STRUCT_TRAITS_MEMBER(headers
)
62 IPC_STRUCT_TRAITS_MEMBER(blob_uuid
)
63 IPC_STRUCT_TRAITS_MEMBER(blob_size
)
64 IPC_STRUCT_TRAITS_MEMBER(stream_url
)
65 IPC_STRUCT_TRAITS_END()
67 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerCacheQueryParams
)
68 IPC_STRUCT_TRAITS_MEMBER(ignore_search
)
69 IPC_STRUCT_TRAITS_MEMBER(ignore_method
)
70 IPC_STRUCT_TRAITS_MEMBER(ignore_vary
)
71 IPC_STRUCT_TRAITS_MEMBER(prefix_match
)
72 IPC_STRUCT_TRAITS_END()
74 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerCacheOperationType
,
75 content::SERVICE_WORKER_CACHE_OPERATION_TYPE_LAST
)
77 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerBatchOperation
)
78 IPC_STRUCT_TRAITS_MEMBER(operation_type
)
79 IPC_STRUCT_TRAITS_MEMBER(request
)
80 IPC_STRUCT_TRAITS_MEMBER(response
)
81 IPC_STRUCT_TRAITS_MEMBER(match_params
)
82 IPC_STRUCT_TRAITS_END()
84 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo
)
85 IPC_STRUCT_TRAITS_MEMBER(handle_id
)
86 IPC_STRUCT_TRAITS_MEMBER(scope
)
87 IPC_STRUCT_TRAITS_MEMBER(url
)
88 IPC_STRUCT_TRAITS_MEMBER(state
)
89 IPC_STRUCT_TRAITS_MEMBER(version_id
)
90 IPC_STRUCT_TRAITS_END()
92 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerRegistrationObjectInfo
)
93 IPC_STRUCT_TRAITS_MEMBER(handle_id
)
94 IPC_STRUCT_TRAITS_MEMBER(scope
)
95 IPC_STRUCT_TRAITS_MEMBER(registration_id
)
96 IPC_STRUCT_TRAITS_END()
98 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerVersionAttributes
)
99 IPC_STRUCT_TRAITS_MEMBER(installing
)
100 IPC_STRUCT_TRAITS_MEMBER(waiting
)
101 IPC_STRUCT_TRAITS_MEMBER(active
)
102 IPC_STRUCT_TRAITS_END()
104 IPC_ENUM_TRAITS_MAX_VALUE(
105 blink::WebServiceWorkerCacheError
,
106 blink::WebServiceWorkerCacheErrorLast
)
108 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebGeofencingEventType
,
109 blink::WebGeofencingEventTypeLast
)
111 //---------------------------------------------------------------------------
112 // Messages sent from the child process to the browser.
114 IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker
,
116 int /* request_id */,
117 int /* provider_id */,
119 GURL
/* script_url */)
121 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker
,
123 int /* request_id */,
124 int /* provider_id */,
125 GURL
/* scope (url pattern) */)
127 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_GetRegistration
,
129 int /* request_id */,
130 int /* provider_id */,
131 GURL
/* document_url */)
133 // Sends a 'message' event to a service worker (renderer->browser).
134 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_PostMessageToWorker
,
136 base::string16
/* message */,
137 std::vector
<int> /* sent_message_port_ids */)
139 // Informs the browser of a new ServiceWorkerProvider in the child process,
140 // |provider_id| is unique within its child process.
141 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderCreated
,
142 int /* provider_id */)
144 // Informs the browser of a ServiceWorkerProvider being destroyed.
145 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderDestroyed
,
146 int /* provider_id */)
148 // Increments and decrements the ServiceWorker object's reference
149 // counting in the browser side. The ServiceWorker object is created
150 // with ref-count==1 initially.
151 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount
,
153 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount
,
156 // Increments and decrements the ServiceWorkerRegistration object's reference
157 // counting in the browser side. The registration object is created with
158 // ref-count==1 initially.
159 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementRegistrationRefCount
,
160 int /* registration_handle_id */)
161 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementRegistrationRefCount
,
162 int /* registration_handle_id */)
164 // Tells the browser to terminate a service worker. Used in layout tests to
165 // verify behavior when a service worker isn't running.
166 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_TerminateWorker
,
169 // Informs the browser that |provider_id| is associated
170 // with a service worker script running context and
171 // |version_id| identifies which ServiceWorkerVersion.
172 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_SetVersionId
,
173 int /* provider_id */,
174 int64
/* version_id */)
176 // Informs the browser that event handling has finished.
177 // Routed to the target ServiceWorkerVersion.
178 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_InstallEventFinished
,
179 int /* request_id */,
180 blink::WebServiceWorkerEventResult
)
181 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_ActivateEventFinished
,
182 int /* request_id */,
183 blink::WebServiceWorkerEventResult
)
184 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_FetchEventFinished
,
185 int /* request_id */,
186 content::ServiceWorkerFetchEventResult
,
187 content::ServiceWorkerResponse
)
188 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SyncEventFinished
,
189 int /* request_id */)
190 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_PushEventFinished
,
191 int /* request_id */)
192 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GeofencingEventFinished
,
193 int /* request_id */)
195 // Asks the browser to retrieve documents controlled by the sender
197 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GetClientDocuments
,
198 int /* request_id */)
200 // Sends a 'message' event to a client document (renderer->browser).
201 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_PostMessageToDocument
,
203 base::string16
/* message */,
204 std::vector
<int> /* sent_message_port_ids */)
206 // CacheStorage operations in the browser.
207 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageHas
,
208 int /* request_id */,
209 base::string16
/* fetch_store_name */)
211 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageOpen
,
212 int /* request_id */,
213 base::string16
/* fetch_store_name */)
215 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageDelete
,
216 int /* request_id */,
217 base::string16
/* fetch_store_name */)
219 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_CacheStorageKeys
,
220 int /* request_id */)
222 // Cache operations in the browser.
223 IPC_MESSAGE_ROUTED4(ServiceWorkerHostMsg_CacheMatch
,
224 int /* request_id */,
226 content::ServiceWorkerFetchRequest
,
227 content::ServiceWorkerCacheQueryParams
)
229 IPC_MESSAGE_ROUTED4(ServiceWorkerHostMsg_CacheMatchAll
,
230 int /* request_id */,
232 content::ServiceWorkerFetchRequest
,
233 content::ServiceWorkerCacheQueryParams
)
235 IPC_MESSAGE_ROUTED4(ServiceWorkerHostMsg_CacheKeys
,
236 int /* request_id */,
238 content::ServiceWorkerFetchRequest
,
239 content::ServiceWorkerCacheQueryParams
)
241 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_CacheBatch
,
242 int /* request_id */,
244 std::vector
<content::ServiceWorkerBatchOperation
>)
246 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_CacheClosed
,
249 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_BlobDataHandled
,
250 std::string
/* uuid */)
252 //---------------------------------------------------------------------------
253 // Messages sent from the browser to the child process.
255 // NOTE: All ServiceWorkerMsg messages not sent via EmbeddedWorker must have
256 // a thread_id as their first field so that ServiceWorkerMessageFilter can
257 // extract it and dispatch the message to the correct ServiceWorkerDispatcher
258 // on the correct thread.
260 // Informs the child process that the given provider gets associated or
261 // disassociated with the registration.
262 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_AssociateRegistration
,
264 int /* provider_id */,
265 content::ServiceWorkerRegistrationObjectInfo
,
266 content::ServiceWorkerVersionAttributes
)
267 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DisassociateRegistration
,
269 int /* provider_id */)
271 // Response to ServiceWorkerHostMsg_RegisterServiceWorker.
272 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistered
,
274 int /* request_id */,
275 content::ServiceWorkerRegistrationObjectInfo
,
276 content::ServiceWorkerVersionAttributes
)
278 // Response to ServiceWorkerHostMsg_UnregisterServiceWorker.
279 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerUnregistered
,
281 int /* request_id */,
282 bool /* is_success */)
284 // Response to ServiceWorkerHostMsg_GetRegistration.
285 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistration
,
287 int /* request_id */,
288 content::ServiceWorkerRegistrationObjectInfo
,
289 content::ServiceWorkerVersionAttributes
)
291 // Sent when any kind of registration error occurs during a
292 // RegisterServiceWorker handler above.
293 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError
,
295 int /* request_id */,
296 blink::WebServiceWorkerError::ErrorType
/* code */,
297 base::string16
/* message */)
299 // Sent when any kind of registration error occurs during a
300 // UnregisterServiceWorker handler above.
301 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerUnregistrationError
,
303 int /* request_id */,
304 blink::WebServiceWorkerError::ErrorType
/* code */,
305 base::string16
/* message */)
307 // Sent when any kind of registration error occurs during a
308 // GetRegistration handler above.
309 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationError
,
311 int /* request_id */,
312 blink::WebServiceWorkerError::ErrorType
/* code */,
313 base::string16
/* message */)
315 // Informs the child process that the ServiceWorker's state has changed.
316 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged
,
319 blink::WebServiceWorkerState
)
321 // Tells the child process to set service workers for the given provider.
322 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_SetVersionAttributes
,
324 int /* provider_id */,
325 int /* registration_handle_id */,
326 int /* changed_mask */,
327 content::ServiceWorkerVersionAttributes
)
329 // Informs the child process that new ServiceWorker enters the installation
331 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_UpdateFound
,
333 content::ServiceWorkerRegistrationObjectInfo
)
335 // Tells the child process to set the controller ServiceWorker for the given
337 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_SetControllerServiceWorker
,
339 int /* provider_id */,
340 content::ServiceWorkerObjectInfo
)
342 // Sends a 'message' event to a client document (browser->renderer).
343 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_MessageToDocument
,
345 int /* provider_id */,
346 base::string16
/* message */,
347 std::vector
<int> /* sent_message_port_ids */,
348 std::vector
<int> /* new_routing_ids */)
350 // Sent via EmbeddedWorker to dispatch events.
351 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_InstallEvent
,
352 int /* request_id */,
353 int /* active_version_id */)
354 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent
,
355 int /* request_id */)
356 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent
,
357 int /* request_id */,
358 content::ServiceWorkerFetchRequest
)
359 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_SyncEvent
,
360 int /* request_id */)
361 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_PushEvent
,
362 int /* request_id */,
363 std::string
/* data */)
364 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_GeofencingEvent
,
365 int /* request_id */,
366 blink::WebGeofencingEventType
/* event_type */,
367 std::string
/* region_id */,
368 blink::WebCircularGeofencingRegion
/* region */)
369 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_MessageToWorker
,
370 base::string16
/* message */,
371 std::vector
<int> /* sent_message_port_ids */,
372 std::vector
<int> /* new_routing_ids */)
374 // Sent via EmbeddedWorker as a response of GetClientDocuments.
375 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClientDocuments
,
376 int /* request_id */,
377 std::vector
<int> /* client_ids */)
379 // Sent via EmbeddedWorker at successful completion of CacheStorage operations.
380 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_CacheStorageHasSuccess
,
381 int /* request_id */)
382 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageOpenSuccess
,
383 int /* request_id */,
384 int /* fetch_store_id */)
385 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_CacheStorageDeleteSuccess
,
386 int /* request_id */)
387 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageKeysSuccess
,
388 int /* request_id */,
389 std::vector
<base::string16
> /* keys */)
391 // Sent via EmbeddedWorker at erroneous completion of CacheStorage operations.
392 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageHasError
,
393 int /* request_id */,
394 blink::WebServiceWorkerCacheError
/* reason */)
395 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageOpenError
,
396 int /* request_id */,
397 blink::WebServiceWorkerCacheError
/* reason */)
398 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageDeleteError
,
399 int /* request_id */,
400 blink::WebServiceWorkerCacheError
/* reason */)
401 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageKeysError
,
402 int /* request_id */,
403 blink::WebServiceWorkerCacheError
/* reason */)
405 // Sent via EmbeddedWorker at successful completion of Cache operations.
406 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheMatchSuccess
,
407 int /* request_id */,
408 content::ServiceWorkerResponse
)
409 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheMatchAllSuccess
,
410 int /* request_id */,
411 std::vector
<content::ServiceWorkerResponse
>)
412 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheKeysSuccess
,
413 int /* request_id */,
414 std::vector
<content::ServiceWorkerFetchRequest
>)
415 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheBatchSuccess
,
416 int /* request_id */,
417 std::vector
<content::ServiceWorkerResponse
>)
419 // Sent via EmbeddedWorker at erroneous completion of CacheStorage operations.
420 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheMatchError
,
421 int /* request_id */,
422 blink::WebServiceWorkerCacheError
)
423 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheMatchAllError
,
424 int /* request_id */,
425 blink::WebServiceWorkerCacheError
)
426 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheKeysError
,
427 int /* request_id */,
428 blink::WebServiceWorkerCacheError
)
429 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheBatchError
,
430 int /* request_id */,
431 blink::WebServiceWorkerCacheError
)