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/WebServiceWorkerError.h"
22 #include "third_party/WebKit/public/platform/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(is_reload
)
63 IPC_STRUCT_TRAITS_END()
65 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult
,
66 content::SERVICE_WORKER_FETCH_EVENT_LAST
)
68 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerResponse
)
69 IPC_STRUCT_TRAITS_MEMBER(url
)
70 IPC_STRUCT_TRAITS_MEMBER(status_code
)
71 IPC_STRUCT_TRAITS_MEMBER(status_text
)
72 IPC_STRUCT_TRAITS_MEMBER(response_type
)
73 IPC_STRUCT_TRAITS_MEMBER(headers
)
74 IPC_STRUCT_TRAITS_MEMBER(blob_uuid
)
75 IPC_STRUCT_TRAITS_MEMBER(blob_size
)
76 IPC_STRUCT_TRAITS_MEMBER(stream_url
)
77 IPC_STRUCT_TRAITS_MEMBER(error
)
78 IPC_STRUCT_TRAITS_END()
80 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo
)
81 IPC_STRUCT_TRAITS_MEMBER(handle_id
)
82 IPC_STRUCT_TRAITS_MEMBER(url
)
83 IPC_STRUCT_TRAITS_MEMBER(state
)
84 IPC_STRUCT_TRAITS_MEMBER(version_id
)
85 IPC_STRUCT_TRAITS_END()
87 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerRegistrationObjectInfo
)
88 IPC_STRUCT_TRAITS_MEMBER(handle_id
)
89 IPC_STRUCT_TRAITS_MEMBER(scope
)
90 IPC_STRUCT_TRAITS_MEMBER(registration_id
)
91 IPC_STRUCT_TRAITS_END()
93 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerVersionAttributes
)
94 IPC_STRUCT_TRAITS_MEMBER(installing
)
95 IPC_STRUCT_TRAITS_MEMBER(waiting
)
96 IPC_STRUCT_TRAITS_MEMBER(active
)
97 IPC_STRUCT_TRAITS_END()
99 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerClientInfo
)
100 IPC_STRUCT_TRAITS_MEMBER(client_uuid
)
101 IPC_STRUCT_TRAITS_MEMBER(page_visibility_state
)
102 IPC_STRUCT_TRAITS_MEMBER(is_focused
)
103 IPC_STRUCT_TRAITS_MEMBER(url
)
104 IPC_STRUCT_TRAITS_MEMBER(frame_type
)
105 IPC_STRUCT_TRAITS_MEMBER(client_type
)
106 IPC_STRUCT_TRAITS_END()
108 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerClientQueryOptions
)
109 IPC_STRUCT_TRAITS_MEMBER(client_type
)
110 IPC_STRUCT_TRAITS_MEMBER(include_uncontrolled
)
111 IPC_STRUCT_TRAITS_END()
113 IPC_STRUCT_BEGIN(ServiceWorkerMsg_MessageToDocument_Params
)
114 IPC_STRUCT_MEMBER(int, thread_id
)
115 IPC_STRUCT_MEMBER(int, provider_id
)
116 IPC_STRUCT_MEMBER(content::ServiceWorkerObjectInfo
, service_worker_info
)
117 IPC_STRUCT_MEMBER(base::string16
, message
)
118 IPC_STRUCT_MEMBER(std::vector
<content::TransferredMessagePort
>, message_ports
)
119 IPC_STRUCT_MEMBER(std::vector
<int>, new_routing_ids
)
122 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebGeofencingEventType
,
123 blink::WebGeofencingEventTypeLast
)
125 IPC_STRUCT_TRAITS_BEGIN(content::NavigatorConnectClient
)
126 IPC_STRUCT_TRAITS_MEMBER(target_url
)
127 IPC_STRUCT_TRAITS_MEMBER(origin
)
128 IPC_STRUCT_TRAITS_MEMBER(message_port_id
)
129 IPC_STRUCT_TRAITS_END()
131 //---------------------------------------------------------------------------
132 // Messages sent from the child process to the browser.
134 IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker
,
136 int /* request_id */,
137 int /* provider_id */,
139 GURL
/* script_url */)
141 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_UpdateServiceWorker
,
142 int /* provider_id */,
143 int64
/* registration_id */)
145 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker
,
147 int /* request_id */,
148 int /* provider_id */,
149 int64
/* registration_id */)
151 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_GetRegistration
,
153 int /* request_id */,
154 int /* provider_id */,
155 GURL
/* document_url */)
157 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_GetRegistrations
,
159 int /* request_id */,
160 int /* provider_id */)
162 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_GetRegistrationForReady
,
164 int /* request_id */,
165 int /* provider_id */)
167 // Sends a 'message' event to a service worker (renderer->browser).
168 IPC_MESSAGE_CONTROL3(
169 ServiceWorkerHostMsg_PostMessageToWorker
,
171 base::string16
/* message */,
172 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */)
174 // Informs the browser of a new ServiceWorkerProvider in the child process,
175 // |provider_id| is unique within its child process. When this provider is
176 // created for a document, |route_id| is the frame ID of it. When this provider
177 // is created for a Shared Worker, |route_id| is the Shared Worker route ID.
178 // When this provider is created for a Service Worker, |route_id| is
179 // MSG_ROUTING_NONE. |provider_type| identifies whether this provider is for
180 // Service Worker controllees (documents and Shared Workers) or for controllers
181 // (Service Workers).
182 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_ProviderCreated
,
183 int /* provider_id */,
185 content::ServiceWorkerProviderType
/* provider_type */)
187 // Informs the browser of a ServiceWorkerProvider being destroyed.
188 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderDestroyed
,
189 int /* provider_id */)
191 // Increments and decrements the ServiceWorker object's reference
192 // counting in the browser side. The ServiceWorker object is created
193 // with ref-count==1 initially.
194 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount
,
196 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount
,
199 // Increments and decrements the ServiceWorkerRegistration object's reference
200 // counting in the browser side. The registration object is created with
201 // ref-count==1 initially.
202 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementRegistrationRefCount
,
203 int /* registration_handle_id */)
204 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementRegistrationRefCount
,
205 int /* registration_handle_id */)
207 // Tells the browser to terminate a service worker. Used in layout tests to
208 // verify behavior when a service worker isn't running.
209 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_TerminateWorker
,
212 // Informs the browser that |provider_id| is associated
213 // with a service worker script running context and
214 // |version_id| identifies which ServiceWorkerVersion.
215 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_SetVersionId
,
216 int /* provider_id */,
217 int64
/* version_id */)
219 // Informs the browser that event handling has finished.
220 // Routed to the target ServiceWorkerVersion.
221 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_InstallEventFinished
,
222 int /* request_id */,
223 blink::WebServiceWorkerEventResult
)
224 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_ActivateEventFinished
,
225 int /* request_id */,
226 blink::WebServiceWorkerEventResult
)
227 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_FetchEventFinished
,
228 int /* request_id */,
229 content::ServiceWorkerFetchEventResult
,
230 content::ServiceWorkerResponse
)
231 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_NotificationClickEventFinished
,
232 int /* request_id */)
233 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_PushEventFinished
,
234 int /* request_id */,
235 blink::WebServiceWorkerEventResult
)
236 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GeofencingEventFinished
,
237 int /* request_id */)
239 // Responds to a Ping from the browser.
240 // Routed to the target ServiceWorkerVersion.
241 IPC_MESSAGE_ROUTED0(ServiceWorkerHostMsg_Pong
)
243 // Asks the browser to retrieve clients of the sender ServiceWorker.
244 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_GetClients
,
245 int /* request_id */,
246 content::ServiceWorkerClientQueryOptions
)
248 // Sends a 'message' event to a client (renderer->browser).
250 ServiceWorkerHostMsg_PostMessageToClient
,
251 std::string
/* uuid */,
252 base::string16
/* message */,
253 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */)
255 // ServiceWorker -> Browser message to request that the ServiceWorkerStorage
256 // cache |data| associated with |url|.
257 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_SetCachedMetadata
,
259 std::vector
<char> /* data */)
261 // ServiceWorker -> Browser message to request that the ServiceWorkerStorage
262 // clear the cache associated with |url|.
263 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_ClearCachedMetadata
, GURL
/* url */)
265 // Ask the browser to open a tab/window (renderer->browser).
266 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_OpenWindow
,
267 int /* request_id */,
270 // Ask the browser to focus a client (renderer->browser).
271 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_FocusClient
,
272 int /* request_id */,
273 std::string
/* uuid */)
275 // Ask the browser to navigate a client (renderer->browser).
276 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_NavigateClient
,
277 int /* request_id */,
278 std::string
/* uuid */,
281 // Asks the browser to force this worker to become activated.
282 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SkipWaiting
,
283 int /* request_id */)
285 // Asks the browser to have this worker take control of pages that match
287 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_ClaimClients
,
288 int /* request_id */)
290 //---------------------------------------------------------------------------
291 // Messages sent from the browser to the child process.
293 // NOTE: All ServiceWorkerMsg messages not sent via EmbeddedWorker must have
294 // a thread_id as their first field so that ServiceWorkerMessageFilter can
295 // extract it and dispatch the message to the correct ServiceWorkerDispatcher
296 // on the correct thread.
298 // Informs the child process of the registration associated with the service
300 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_AssociateRegistrationWithServiceWorker
,
302 int /* provider_id */,
303 content::ServiceWorkerRegistrationObjectInfo
,
304 content::ServiceWorkerVersionAttributes
)
306 // Informs the child process that the given provider gets associated or
307 // disassociated with the registration.
308 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_AssociateRegistration
,
310 int /* provider_id */,
311 content::ServiceWorkerRegistrationObjectInfo
,
312 content::ServiceWorkerVersionAttributes
)
313 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DisassociateRegistration
,
315 int /* provider_id */)
317 // Response to ServiceWorkerHostMsg_RegisterServiceWorker.
318 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistered
,
320 int /* request_id */,
321 content::ServiceWorkerRegistrationObjectInfo
,
322 content::ServiceWorkerVersionAttributes
)
324 // Response to ServiceWorkerHostMsg_UnregisterServiceWorker.
325 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerUnregistered
,
327 int /* request_id */,
328 bool /* is_success */)
330 // Response to ServiceWorkerHostMsg_GetRegistration.
331 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistration
,
333 int /* request_id */,
334 content::ServiceWorkerRegistrationObjectInfo
,
335 content::ServiceWorkerVersionAttributes
)
337 // Response to ServiceWorkerHostMsg_GetRegistrations.
338 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistrations
,
340 int /* request_id */,
341 std::vector
<content::ServiceWorkerRegistrationObjectInfo
>,
342 std::vector
<content::ServiceWorkerVersionAttributes
>)
344 // Response to ServiceWorkerHostMsg_GetRegistrationForReady.
345 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistrationForReady
,
347 int /* request_id */,
348 content::ServiceWorkerRegistrationObjectInfo
,
349 content::ServiceWorkerVersionAttributes
)
351 // Sent when any kind of registration error occurs during a
352 // RegisterServiceWorker handler above.
353 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError
,
355 int /* request_id */,
356 blink::WebServiceWorkerError::ErrorType
/* code */,
357 base::string16
/* message */)
359 // Sent when any kind of registration error occurs during a
360 // UnregisterServiceWorker handler above.
361 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerUnregistrationError
,
363 int /* request_id */,
364 blink::WebServiceWorkerError::ErrorType
/* code */,
365 base::string16
/* message */)
367 // Sent when any kind of registration error occurs during a
368 // GetRegistration handler above.
369 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationError
,
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 // GetRegistrations handler above.
377 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationsError
,
379 int /* request_id */,
380 blink::WebServiceWorkerError::ErrorType
/* code */,
381 base::string16
/* message */)
383 // Informs the child process that the ServiceWorker's state has changed.
384 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged
,
387 blink::WebServiceWorkerState
)
389 // Tells the child process to set service workers for the given provider.
390 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_SetVersionAttributes
,
392 int /* provider_id */,
393 int /* registration_handle_id */,
394 int /* changed_mask */,
395 content::ServiceWorkerVersionAttributes
)
397 // Informs the child process that new ServiceWorker enters the installation
399 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_UpdateFound
,
401 int /* registration_handle_id */)
403 // Tells the child process to set the controller ServiceWorker for the given
405 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_SetControllerServiceWorker
,
407 int /* provider_id */,
408 content::ServiceWorkerObjectInfo
,
409 bool /* should_notify_controllerchange */)
411 // Sends a 'message' event to a client document (browser->renderer).
412 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_MessageToDocument
,
413 ServiceWorkerMsg_MessageToDocument_Params
)
415 // Sent via EmbeddedWorker to dispatch events.
416 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_InstallEvent
,
417 int /* request_id */)
418 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent
,
419 int /* request_id */)
420 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent
,
421 int /* request_id */,
422 content::ServiceWorkerFetchRequest
)
423 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_NotificationClickEvent
,
424 int /* request_id */,
425 int64_t /* persistent_notification_id */,
426 content::PlatformNotificationData
/* notification_data */)
427 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_PushEvent
,
428 int /* request_id */,
429 std::string
/* data */)
430 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_GeofencingEvent
,
431 int /* request_id */,
432 blink::WebGeofencingEventType
/* event_type */,
433 std::string
/* region_id */,
434 blink::WebCircularGeofencingRegion
/* region */)
435 IPC_MESSAGE_CONTROL3(
436 ServiceWorkerMsg_MessageToWorker
,
437 base::string16
/* message */,
438 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */,
439 std::vector
<int> /* new_routing_ids */)
440 IPC_MESSAGE_CONTROL4(
441 ServiceWorkerMsg_CrossOriginMessageToWorker
,
442 content::NavigatorConnectClient
/* client */,
443 base::string16
/* message */,
444 std::vector
<content::TransferredMessagePort
> /* sent_message_ports */,
445 std::vector
<int> /* new_routing_ids */)
446 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_DidSkipWaiting
,
447 int /* request_id */)
448 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_DidClaimClients
,
449 int /* request_id */)
450 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ClaimClientsError
,
451 int /* request_id */,
452 blink::WebServiceWorkerError::ErrorType
/* code */,
453 base::string16
/* message */)
455 // Sent via EmbeddedWorker to Ping the worker, expecting a Pong in response.
456 IPC_MESSAGE_CONTROL0(ServiceWorkerMsg_Ping
)
458 // Sent via EmbeddedWorker as a response of GetClients.
459 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClients
,
460 int /* request_id */,
461 std::vector
<content::ServiceWorkerClientInfo
>)
463 // Sent via EmbeddedWorker as a response of OpenWindow.
464 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_OpenWindowResponse
,
465 int /* request_id */,
466 content::ServiceWorkerClientInfo
/* client */)
468 // Sent via EmbeddedWorker as an error response of OpenWindow.
469 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_OpenWindowError
,
470 int /* request_id */,
471 std::string
/* message */ )
473 // Sent via EmbeddedWorker as a response of FocusClient.
474 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FocusClientResponse
,
475 int /* request_id */,
476 content::ServiceWorkerClientInfo
/* client */)
478 // Sent via EmbeddedWorker as a response of NavigateClient.
479 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_NavigateClientResponse
,
480 int /* request_id */,
481 content::ServiceWorkerClientInfo
/* client */)
483 // Sent via EmbeddedWorker as an error response of NavigateClient.
484 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_NavigateClientError
,
485 int /* request_id */,