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_client_info.h"
12 #include "content/common/service_worker/service_worker_status_code.h"
13 #include "content/common/service_worker/service_worker_types.h"
14 #include "content/public/common/message_port_types.h"
15 #include "content/public/common/navigator_connect_client.h"
16 #include "content/public/common/platform_notification_data.h"
17 #include "ipc/ipc_message_macros.h"
18 #include "ipc/ipc_param_traits.h"
19 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h"
20 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h"
21 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h"
22 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerEventResult.h"
25 #undef IPC_MESSAGE_EXPORT
26 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
28 #define IPC_MESSAGE_START ServiceWorkerMsgStart
30 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerError::ErrorType
,
31 blink::WebServiceWorkerError::ErrorTypeLast
)
33 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerEventResult
,
34 blink::WebServiceWorkerEventResultLast
)
36 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerState
,
37 blink::WebServiceWorkerStateLast
)
39 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerResponseType
,
40 blink::WebServiceWorkerResponseTypeLast
)
42 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerResponseError
,
43 blink::WebServiceWorkerResponseErrorLast
)
45 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerClientType
,
46 blink::WebServiceWorkerClientTypeLast
)
48 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerProviderType
,
49 content::SERVICE_WORKER_PROVIDER_TYPE_LAST
)
51 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerFetchRequest
)
52 IPC_STRUCT_TRAITS_MEMBER(mode
)
53 IPC_STRUCT_TRAITS_MEMBER(request_context_type
)
54 IPC_STRUCT_TRAITS_MEMBER(frame_type
)
55 IPC_STRUCT_TRAITS_MEMBER(url
)
56 IPC_STRUCT_TRAITS_MEMBER(method
)
57 IPC_STRUCT_TRAITS_MEMBER(headers
)
58 IPC_STRUCT_TRAITS_MEMBER(blob_uuid
)
59 IPC_STRUCT_TRAITS_MEMBER(blob_size
)
60 IPC_STRUCT_TRAITS_MEMBER(referrer
)
61 IPC_STRUCT_TRAITS_MEMBER(credentials_mode
)
62 IPC_STRUCT_TRAITS_MEMBER(redirect_mode
)
63 IPC_STRUCT_TRAITS_MEMBER(is_reload
)
64 IPC_STRUCT_TRAITS_END()
66 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult
,
67 content::SERVICE_WORKER_FETCH_EVENT_LAST
)
69 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerResponse
)
70 IPC_STRUCT_TRAITS_MEMBER(url
)
71 IPC_STRUCT_TRAITS_MEMBER(status_code
)
72 IPC_STRUCT_TRAITS_MEMBER(status_text
)
73 IPC_STRUCT_TRAITS_MEMBER(response_type
)
74 IPC_STRUCT_TRAITS_MEMBER(headers
)
75 IPC_STRUCT_TRAITS_MEMBER(blob_uuid
)
76 IPC_STRUCT_TRAITS_MEMBER(blob_size
)
77 IPC_STRUCT_TRAITS_MEMBER(stream_url
)
78 IPC_STRUCT_TRAITS_MEMBER(error
)
79 IPC_STRUCT_TRAITS_END()
81 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo
)
82 IPC_STRUCT_TRAITS_MEMBER(handle_id
)
83 IPC_STRUCT_TRAITS_MEMBER(url
)
84 IPC_STRUCT_TRAITS_MEMBER(state
)
85 IPC_STRUCT_TRAITS_MEMBER(version_id
)
86 IPC_STRUCT_TRAITS_END()
88 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerRegistrationObjectInfo
)
89 IPC_STRUCT_TRAITS_MEMBER(handle_id
)
90 IPC_STRUCT_TRAITS_MEMBER(scope
)
91 IPC_STRUCT_TRAITS_MEMBER(registration_id
)
92 IPC_STRUCT_TRAITS_END()
94 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerVersionAttributes
)
95 IPC_STRUCT_TRAITS_MEMBER(installing
)
96 IPC_STRUCT_TRAITS_MEMBER(waiting
)
97 IPC_STRUCT_TRAITS_MEMBER(active
)
98 IPC_STRUCT_TRAITS_END()
100 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerClientInfo
)
101 IPC_STRUCT_TRAITS_MEMBER(client_uuid
)
102 IPC_STRUCT_TRAITS_MEMBER(page_visibility_state
)
103 IPC_STRUCT_TRAITS_MEMBER(is_focused
)
104 IPC_STRUCT_TRAITS_MEMBER(url
)
105 IPC_STRUCT_TRAITS_MEMBER(frame_type
)
106 IPC_STRUCT_TRAITS_MEMBER(client_type
)
107 IPC_STRUCT_TRAITS_END()
109 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerClientQueryOptions
)
110 IPC_STRUCT_TRAITS_MEMBER(client_type
)
111 IPC_STRUCT_TRAITS_MEMBER(include_uncontrolled
)
112 IPC_STRUCT_TRAITS_END()
114 IPC_STRUCT_BEGIN(ServiceWorkerMsg_MessageToDocument_Params
)
115 IPC_STRUCT_MEMBER(int, thread_id
)
116 IPC_STRUCT_MEMBER(int, provider_id
)
117 IPC_STRUCT_MEMBER(content::ServiceWorkerObjectInfo
, service_worker_info
)
118 IPC_STRUCT_MEMBER(base::string16
, message
)
119 IPC_STRUCT_MEMBER(std::vector
<content::TransferredMessagePort
>, message_ports
)
120 IPC_STRUCT_MEMBER(std::vector
<int>, new_routing_ids
)
123 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebGeofencingEventType
,
124 blink::WebGeofencingEventTypeLast
)
126 IPC_STRUCT_TRAITS_BEGIN(content::NavigatorConnectClient
)
127 IPC_STRUCT_TRAITS_MEMBER(target_url
)
128 IPC_STRUCT_TRAITS_MEMBER(origin
)
129 IPC_STRUCT_TRAITS_MEMBER(message_port_id
)
130 IPC_STRUCT_TRAITS_END()
132 //---------------------------------------------------------------------------
133 // Messages sent from the child process to the browser.
135 IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker
,
137 int /* request_id */,
138 int /* provider_id */,
140 GURL
/* script_url */)
142 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UpdateServiceWorker
,
144 int /* request_id */,
145 int /* provider_id */,
146 int64
/* registration_id */)
148 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker
,
150 int /* request_id */,
151 int /* provider_id */,
152 int64
/* registration_id */)
154 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_GetRegistration
,
156 int /* request_id */,
157 int /* provider_id */,
158 GURL
/* document_url */)
160 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_GetRegistrations
,
162 int /* request_id */,
163 int /* provider_id */)
165 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_GetRegistrationForReady
,
167 int /* request_id */,
168 int /* provider_id */)
170 // Sends a 'message' event to a service worker (renderer->browser).
171 IPC_MESSAGE_CONTROL3(
172 ServiceWorkerHostMsg_PostMessageToWorker
,
174 base::string16
/* message */,
175 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */)
177 // Informs the browser of a new ServiceWorkerProvider in the child process,
178 // |provider_id| is unique within its child process. When this provider is
179 // created for a document, |route_id| is the frame ID of it. When this provider
180 // is created for a Shared Worker, |route_id| is the Shared Worker route ID.
181 // When this provider is created for a Service Worker, |route_id| is
182 // MSG_ROUTING_NONE. |provider_type| identifies whether this provider is for
183 // Service Worker controllees (documents and Shared Workers) or for controllers
184 // (Service Workers).
185 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_ProviderCreated
,
186 int /* provider_id */,
188 content::ServiceWorkerProviderType
/* provider_type */)
190 // Informs the browser of a ServiceWorkerProvider being destroyed.
191 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderDestroyed
,
192 int /* provider_id */)
194 // Increments and decrements the ServiceWorker object's reference
195 // counting in the browser side. The ServiceWorker object is created
196 // with ref-count==1 initially.
197 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount
,
199 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount
,
202 // Increments and decrements the ServiceWorkerRegistration object's reference
203 // counting in the browser side. The registration object is created with
204 // ref-count==1 initially.
205 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementRegistrationRefCount
,
206 int /* registration_handle_id */)
207 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementRegistrationRefCount
,
208 int /* registration_handle_id */)
210 // Tells the browser to terminate a service worker. Used in layout tests to
211 // verify behavior when a service worker isn't running.
212 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_TerminateWorker
,
215 // Informs the browser that |provider_id| is associated
216 // with a service worker script running context and
217 // |version_id| identifies which ServiceWorkerVersion.
218 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_SetVersionId
,
219 int /* provider_id */,
220 int64
/* version_id */)
222 // Informs the browser that event handling has finished.
223 // Routed to the target ServiceWorkerVersion.
224 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_InstallEventFinished
,
225 int /* request_id */,
226 blink::WebServiceWorkerEventResult
)
227 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_ActivateEventFinished
,
228 int /* request_id */,
229 blink::WebServiceWorkerEventResult
)
230 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_FetchEventFinished
,
231 int /* request_id */,
232 content::ServiceWorkerFetchEventResult
,
233 content::ServiceWorkerResponse
)
234 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_NotificationClickEventFinished
,
235 int /* request_id */)
236 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_PushEventFinished
,
237 int /* request_id */,
238 blink::WebServiceWorkerEventResult
)
239 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GeofencingEventFinished
,
240 int /* request_id */)
242 // Responds to a Ping from the browser.
243 // Routed to the target ServiceWorkerVersion.
244 IPC_MESSAGE_ROUTED0(ServiceWorkerHostMsg_Pong
)
246 // Asks the browser to retrieve clients of the sender ServiceWorker.
247 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_GetClients
,
248 int /* request_id */,
249 content::ServiceWorkerClientQueryOptions
)
251 // Sends a 'message' event to a client (renderer->browser).
253 ServiceWorkerHostMsg_PostMessageToClient
,
254 std::string
/* uuid */,
255 base::string16
/* message */,
256 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */)
258 // ServiceWorker -> Browser message to request that the ServiceWorkerStorage
259 // cache |data| associated with |url|.
260 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_SetCachedMetadata
,
262 std::vector
<char> /* data */)
264 // ServiceWorker -> Browser message to request that the ServiceWorkerStorage
265 // clear the cache associated with |url|.
266 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_ClearCachedMetadata
, GURL
/* url */)
268 // Ask the browser to open a tab/window (renderer->browser).
269 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_OpenWindow
,
270 int /* request_id */,
273 // Ask the browser to focus a client (renderer->browser).
274 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_FocusClient
,
275 int /* request_id */,
276 std::string
/* uuid */)
278 // Ask the browser to navigate a client (renderer->browser).
279 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_NavigateClient
,
280 int /* request_id */,
281 std::string
/* uuid */,
284 // Asks the browser to force this worker to become activated.
285 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SkipWaiting
,
286 int /* request_id */)
288 // Asks the browser to have this worker take control of pages that match
290 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_ClaimClients
,
291 int /* request_id */)
293 //---------------------------------------------------------------------------
294 // Messages sent from the browser to the child process.
296 // NOTE: All ServiceWorkerMsg messages not sent via EmbeddedWorker must have
297 // a thread_id as their first field so that ServiceWorkerMessageFilter can
298 // extract it and dispatch the message to the correct ServiceWorkerDispatcher
299 // on the correct thread.
301 // Informs the child process of the registration associated with the service
303 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_AssociateRegistrationWithServiceWorker
,
305 int /* provider_id */,
306 content::ServiceWorkerRegistrationObjectInfo
,
307 content::ServiceWorkerVersionAttributes
)
309 // Informs the child process that the given provider gets associated or
310 // disassociated with the registration.
311 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_AssociateRegistration
,
313 int /* provider_id */,
314 content::ServiceWorkerRegistrationObjectInfo
,
315 content::ServiceWorkerVersionAttributes
)
316 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DisassociateRegistration
,
318 int /* provider_id */)
320 // Response to ServiceWorkerHostMsg_RegisterServiceWorker.
321 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistered
,
323 int /* request_id */,
324 content::ServiceWorkerRegistrationObjectInfo
,
325 content::ServiceWorkerVersionAttributes
)
327 // Response to ServiceWorkerHostMsg_UpdateServiceWorker.
328 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_ServiceWorkerUpdated
,
330 int /* request_id */)
332 // Response to ServiceWorkerHostMsg_UnregisterServiceWorker.
333 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerUnregistered
,
335 int /* request_id */,
336 bool /* is_success */)
338 // Response to ServiceWorkerHostMsg_GetRegistration.
339 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistration
,
341 int /* request_id */,
342 content::ServiceWorkerRegistrationObjectInfo
,
343 content::ServiceWorkerVersionAttributes
)
345 // Response to ServiceWorkerHostMsg_GetRegistrations.
346 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistrations
,
348 int /* request_id */,
349 std::vector
<content::ServiceWorkerRegistrationObjectInfo
>,
350 std::vector
<content::ServiceWorkerVersionAttributes
>)
352 // Response to ServiceWorkerHostMsg_GetRegistrationForReady.
353 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistrationForReady
,
355 int /* request_id */,
356 content::ServiceWorkerRegistrationObjectInfo
,
357 content::ServiceWorkerVersionAttributes
)
359 // Sent when any kind of registration error occurs during a
360 // RegisterServiceWorker handler above.
361 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError
,
363 int /* request_id */,
364 blink::WebServiceWorkerError::ErrorType
/* code */,
365 base::string16
/* message */)
367 // Sent when any kind of update error occurs during a
368 // UpdateServiceWorker handler above.
369 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerUpdateError
,
371 int /* request_id */,
372 blink::WebServiceWorkerError::ErrorType
/* code */,
373 base::string16
/* message */)
375 // Sent when any kind of registration error occurs during a
376 // UnregisterServiceWorker handler above.
377 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerUnregistrationError
,
379 int /* request_id */,
380 blink::WebServiceWorkerError::ErrorType
/* code */,
381 base::string16
/* message */)
383 // Sent when any kind of registration error occurs during a
384 // GetRegistration handler above.
385 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationError
,
387 int /* request_id */,
388 blink::WebServiceWorkerError::ErrorType
/* code */,
389 base::string16
/* message */)
391 // Sent when any kind of registration error occurs during a
392 // GetRegistrations handler above.
393 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationsError
,
395 int /* request_id */,
396 blink::WebServiceWorkerError::ErrorType
/* code */,
397 base::string16
/* message */)
399 // Informs the child process that the ServiceWorker's state has changed.
400 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged
,
403 blink::WebServiceWorkerState
)
405 // Tells the child process to set service workers for the given provider.
406 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_SetVersionAttributes
,
408 int /* provider_id */,
409 int /* registration_handle_id */,
410 int /* changed_mask */,
411 content::ServiceWorkerVersionAttributes
)
413 // Informs the child process that new ServiceWorker enters the installation
415 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_UpdateFound
,
417 int /* registration_handle_id */)
419 // Tells the child process to set the controller ServiceWorker for the given
421 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_SetControllerServiceWorker
,
423 int /* provider_id */,
424 content::ServiceWorkerObjectInfo
,
425 bool /* should_notify_controllerchange */)
427 // Sends a 'message' event to a client document (browser->renderer).
428 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_MessageToDocument
,
429 ServiceWorkerMsg_MessageToDocument_Params
)
431 // Sent via EmbeddedWorker to dispatch events.
432 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_InstallEvent
,
433 int /* request_id */)
434 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent
,
435 int /* request_id */)
436 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent
,
437 int /* request_id */,
438 content::ServiceWorkerFetchRequest
)
439 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_NotificationClickEvent
,
440 int /* request_id */,
441 int64_t /* persistent_notification_id */,
442 content::PlatformNotificationData
/* notification_data */,
443 int /* action_index */)
444 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_PushEvent
,
445 int /* request_id */,
446 std::string
/* data */)
447 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_GeofencingEvent
,
448 int /* request_id */,
449 blink::WebGeofencingEventType
/* event_type */,
450 std::string
/* region_id */,
451 blink::WebCircularGeofencingRegion
/* region */)
452 IPC_MESSAGE_CONTROL3(
453 ServiceWorkerMsg_MessageToWorker
,
454 base::string16
/* message */,
455 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */,
456 std::vector
<int> /* new_routing_ids */)
457 IPC_MESSAGE_CONTROL4(
458 ServiceWorkerMsg_CrossOriginMessageToWorker
,
459 content::NavigatorConnectClient
/* client */,
460 base::string16
/* message */,
461 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */,
462 std::vector
<int> /* new_routing_ids */)
463 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_DidSkipWaiting
,
464 int /* request_id */)
465 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_DidClaimClients
,
466 int /* request_id */)
467 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ClaimClientsError
,
468 int /* request_id */,
469 blink::WebServiceWorkerError::ErrorType
/* code */,
470 base::string16
/* message */)
472 // Sent via EmbeddedWorker to Ping the worker, expecting a Pong in response.
473 IPC_MESSAGE_CONTROL0(ServiceWorkerMsg_Ping
)
475 // Sent via EmbeddedWorker as a response of GetClients.
476 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClients
,
477 int /* request_id */,
478 std::vector
<content::ServiceWorkerClientInfo
>)
480 // Sent via EmbeddedWorker as a response of OpenWindow.
481 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_OpenWindowResponse
,
482 int /* request_id */,
483 content::ServiceWorkerClientInfo
/* client */)
485 // Sent via EmbeddedWorker as an error response of OpenWindow.
486 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_OpenWindowError
,
487 int /* request_id */,
488 std::string
/* message */ )
490 // Sent via EmbeddedWorker as a response of FocusClient.
491 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FocusClientResponse
,
492 int /* request_id */,
493 content::ServiceWorkerClientInfo
/* client */)
495 // Sent via EmbeddedWorker as a response of NavigateClient.
496 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_NavigateClientResponse
,
497 int /* request_id */,
498 content::ServiceWorkerClientInfo
/* client */)
500 // Sent via EmbeddedWorker as an error response of NavigateClient.
501 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_NavigateClientError
,
502 int /* request_id */,