Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / content / common / service_worker / service_worker_messages.h
bloba54b39090fab6f84820e433a47ee4a3a7a4d8c5e
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.
7 #include <string>
8 #include <vector>
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"
23 #include "url/gurl.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::WebServiceWorkerClientType,
43 blink::WebServiceWorkerClientTypeLast)
45 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerProviderType,
46 content::SERVICE_WORKER_PROVIDER_TYPE_LAST)
48 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerFetchRequest)
49 IPC_STRUCT_TRAITS_MEMBER(mode)
50 IPC_STRUCT_TRAITS_MEMBER(request_context_type)
51 IPC_STRUCT_TRAITS_MEMBER(frame_type)
52 IPC_STRUCT_TRAITS_MEMBER(url)
53 IPC_STRUCT_TRAITS_MEMBER(method)
54 IPC_STRUCT_TRAITS_MEMBER(headers)
55 IPC_STRUCT_TRAITS_MEMBER(blob_uuid)
56 IPC_STRUCT_TRAITS_MEMBER(blob_size)
57 IPC_STRUCT_TRAITS_MEMBER(referrer)
58 IPC_STRUCT_TRAITS_MEMBER(credentials_mode)
59 IPC_STRUCT_TRAITS_MEMBER(is_reload)
60 IPC_STRUCT_TRAITS_END()
62 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult,
63 content::SERVICE_WORKER_FETCH_EVENT_LAST)
65 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerResponse)
66 IPC_STRUCT_TRAITS_MEMBER(url)
67 IPC_STRUCT_TRAITS_MEMBER(status_code)
68 IPC_STRUCT_TRAITS_MEMBER(status_text)
69 IPC_STRUCT_TRAITS_MEMBER(response_type)
70 IPC_STRUCT_TRAITS_MEMBER(headers)
71 IPC_STRUCT_TRAITS_MEMBER(blob_uuid)
72 IPC_STRUCT_TRAITS_MEMBER(blob_size)
73 IPC_STRUCT_TRAITS_MEMBER(stream_url)
74 IPC_STRUCT_TRAITS_END()
76 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo)
77 IPC_STRUCT_TRAITS_MEMBER(handle_id)
78 IPC_STRUCT_TRAITS_MEMBER(url)
79 IPC_STRUCT_TRAITS_MEMBER(state)
80 IPC_STRUCT_TRAITS_MEMBER(version_id)
81 IPC_STRUCT_TRAITS_END()
83 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerRegistrationObjectInfo)
84 IPC_STRUCT_TRAITS_MEMBER(handle_id)
85 IPC_STRUCT_TRAITS_MEMBER(scope)
86 IPC_STRUCT_TRAITS_MEMBER(registration_id)
87 IPC_STRUCT_TRAITS_END()
89 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerVersionAttributes)
90 IPC_STRUCT_TRAITS_MEMBER(installing)
91 IPC_STRUCT_TRAITS_MEMBER(waiting)
92 IPC_STRUCT_TRAITS_MEMBER(active)
93 IPC_STRUCT_TRAITS_END()
95 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerClientInfo)
96 IPC_STRUCT_TRAITS_MEMBER(client_uuid)
97 IPC_STRUCT_TRAITS_MEMBER(page_visibility_state)
98 IPC_STRUCT_TRAITS_MEMBER(is_focused)
99 IPC_STRUCT_TRAITS_MEMBER(url)
100 IPC_STRUCT_TRAITS_MEMBER(frame_type)
101 IPC_STRUCT_TRAITS_MEMBER(client_type)
102 IPC_STRUCT_TRAITS_END()
104 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerClientQueryOptions)
105 IPC_STRUCT_TRAITS_MEMBER(client_type)
106 IPC_STRUCT_TRAITS_MEMBER(include_uncontrolled)
107 IPC_STRUCT_TRAITS_END()
109 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebGeofencingEventType,
110 blink::WebGeofencingEventTypeLast)
112 //---------------------------------------------------------------------------
113 // Messages sent from the child process to the browser.
115 IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker,
116 int /* thread_id */,
117 int /* request_id */,
118 int /* provider_id */,
119 GURL /* scope */,
120 GURL /* script_url */)
122 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker,
123 int /* thread_id */,
124 int /* request_id */,
125 int /* provider_id */,
126 GURL /* scope (url pattern) */)
128 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_GetRegistration,
129 int /* thread_id */,
130 int /* request_id */,
131 int /* provider_id */,
132 GURL /* document_url */)
134 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_GetRegistrationForReady,
135 int /* thread_id */,
136 int /* request_id */,
137 int /* provider_id */)
139 // Sends a 'message' event to a service worker (renderer->browser).
140 IPC_MESSAGE_CONTROL3(
141 ServiceWorkerHostMsg_PostMessageToWorker,
142 int /* handle_id */,
143 base::string16 /* message */,
144 std::vector<content::TransferredMessagePort> /* sent_message_ports */)
146 // Informs the browser of a new ServiceWorkerProvider in the child process,
147 // |provider_id| is unique within its child process.
148 // |render_frame_id| identifies the frame associated with the provider, it will
149 // it will be MSG_ROUTING_NONE if the context is a worker instead of a document.
150 // |provider_type| identifies whether this provider is for ServiceWorker
151 // controllees (documents and SharedWorkers) or for controllers
152 // (ServiceWorkers).
153 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_ProviderCreated,
154 int /* provider_id */,
155 int /* render_frame_id */,
156 content::ServiceWorkerProviderType /* provider_type */)
158 // Informs the browser of a ServiceWorkerProvider being destroyed.
159 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderDestroyed,
160 int /* provider_id */)
162 // Increments and decrements the ServiceWorker object's reference
163 // counting in the browser side. The ServiceWorker object is created
164 // with ref-count==1 initially.
165 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount,
166 int /* handle_id */)
167 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount,
168 int /* handle_id */)
170 // Increments and decrements the ServiceWorkerRegistration object's reference
171 // counting in the browser side. The registration object is created with
172 // ref-count==1 initially.
173 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementRegistrationRefCount,
174 int /* registration_handle_id */)
175 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementRegistrationRefCount,
176 int /* registration_handle_id */)
178 // Tells the browser to terminate a service worker. Used in layout tests to
179 // verify behavior when a service worker isn't running.
180 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_TerminateWorker,
181 int /* handle_id */)
183 // Informs the browser that |provider_id| is associated
184 // with a service worker script running context and
185 // |version_id| identifies which ServiceWorkerVersion.
186 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_SetVersionId,
187 int /* provider_id */,
188 int64 /* version_id */)
190 // Informs the browser that event handling has finished.
191 // Routed to the target ServiceWorkerVersion.
192 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_InstallEventFinished,
193 int /* request_id */,
194 blink::WebServiceWorkerEventResult)
195 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_ActivateEventFinished,
196 int /* request_id */,
197 blink::WebServiceWorkerEventResult)
198 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_FetchEventFinished,
199 int /* request_id */,
200 content::ServiceWorkerFetchEventResult,
201 content::ServiceWorkerResponse)
202 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SyncEventFinished,
203 int /* request_id */)
204 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_NotificationClickEventFinished,
205 int /* request_id */)
206 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_PushEventFinished,
207 int /* request_id */,
208 blink::WebServiceWorkerEventResult)
209 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GeofencingEventFinished,
210 int /* request_id */)
211 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CrossOriginConnectEventFinished,
212 int /* request_id */,
213 bool /* accept_connection */)
215 // Responds to a Ping from the browser.
216 // Routed to the target ServiceWorkerVersion.
217 IPC_MESSAGE_ROUTED0(ServiceWorkerHostMsg_Pong)
219 // Asks the browser to retrieve clients of the sender ServiceWorker.
220 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_GetClients,
221 int /* request_id */,
222 content::ServiceWorkerClientQueryOptions)
224 // Sends a 'message' event to a client (renderer->browser).
225 IPC_MESSAGE_ROUTED3(
226 ServiceWorkerHostMsg_PostMessageToClient,
227 std::string /* uuid */,
228 base::string16 /* message */,
229 std::vector<content::TransferredMessagePort> /* sent_message_ports */)
231 // ServiceWorker -> Browser message to request that the ServiceWorkerStorage
232 // cache |data| associated with |url|.
233 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_SetCachedMetadata,
234 GURL /* url */,
235 std::vector<char> /* data */)
237 // ServiceWorker -> Browser message to request that the ServiceWorkerStorage
238 // clear the cache associated with |url|.
239 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_ClearCachedMetadata, GURL /* url */)
241 // Ask the browser to open a tab/window (renderer->browser).
242 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_OpenWindow,
243 int /* request_id */,
244 GURL /* url */)
246 // Ask the browser to focus a client (renderer->browser).
247 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_FocusClient,
248 int /* request_id */,
249 std::string /* uuid */)
251 // Asks the browser to force this worker to become activated.
252 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SkipWaiting,
253 int /* request_id */)
255 // Asks the browser to have this worker take control of pages that match
256 // its scope.
257 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_ClaimClients,
258 int /* request_id */)
260 // Asks the browser to stash a message port, giving it a name.
261 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_StashMessagePort,
262 int /* message_port_id */,
263 base::string16 /* name */)
265 //---------------------------------------------------------------------------
266 // Messages sent from the browser to the child process.
268 // NOTE: All ServiceWorkerMsg messages not sent via EmbeddedWorker must have
269 // a thread_id as their first field so that ServiceWorkerMessageFilter can
270 // extract it and dispatch the message to the correct ServiceWorkerDispatcher
271 // on the correct thread.
273 // Informs the child process of the registration associated with the service
274 // worker.
275 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_AssociateRegistrationWithServiceWorker,
276 int /* thread_id*/,
277 int /* provider_id */,
278 content::ServiceWorkerRegistrationObjectInfo,
279 content::ServiceWorkerVersionAttributes)
281 // Informs the child process that the given provider gets associated or
282 // disassociated with the registration.
283 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_AssociateRegistration,
284 int /* thread_id */,
285 int /* provider_id */,
286 content::ServiceWorkerRegistrationObjectInfo,
287 content::ServiceWorkerVersionAttributes)
288 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DisassociateRegistration,
289 int /* thread_id */,
290 int /* provider_id */)
292 // Response to ServiceWorkerHostMsg_RegisterServiceWorker.
293 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistered,
294 int /* thread_id */,
295 int /* request_id */,
296 content::ServiceWorkerRegistrationObjectInfo,
297 content::ServiceWorkerVersionAttributes)
299 // Response to ServiceWorkerHostMsg_UnregisterServiceWorker.
300 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerUnregistered,
301 int /* thread_id */,
302 int /* request_id */,
303 bool /* is_success */)
305 // Response to ServiceWorkerHostMsg_GetRegistration.
306 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistration,
307 int /* thread_id */,
308 int /* request_id */,
309 content::ServiceWorkerRegistrationObjectInfo,
310 content::ServiceWorkerVersionAttributes)
312 // Response to ServiceWorkerHostMsg_GetRegistrationForReady.
313 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistrationForReady,
314 int /* thread_id */,
315 int /* request_id */,
316 content::ServiceWorkerRegistrationObjectInfo,
317 content::ServiceWorkerVersionAttributes)
319 // Sent when any kind of registration error occurs during a
320 // RegisterServiceWorker handler above.
321 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError,
322 int /* thread_id */,
323 int /* request_id */,
324 blink::WebServiceWorkerError::ErrorType /* code */,
325 base::string16 /* message */)
327 // Sent when any kind of registration error occurs during a
328 // UnregisterServiceWorker handler above.
329 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerUnregistrationError,
330 int /* thread_id */,
331 int /* request_id */,
332 blink::WebServiceWorkerError::ErrorType /* code */,
333 base::string16 /* message */)
335 // Sent when any kind of registration error occurs during a
336 // GetRegistration handler above.
337 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationError,
338 int /* thread_id */,
339 int /* request_id */,
340 blink::WebServiceWorkerError::ErrorType /* code */,
341 base::string16 /* message */)
343 // Informs the child process that the ServiceWorker's state has changed.
344 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged,
345 int /* thread_id */,
346 int /* handle_id */,
347 blink::WebServiceWorkerState)
349 // Tells the child process to set service workers for the given provider.
350 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_SetVersionAttributes,
351 int /* thread_id */,
352 int /* provider_id */,
353 int /* registration_handle_id */,
354 int /* changed_mask */,
355 content::ServiceWorkerVersionAttributes)
357 // Informs the child process that new ServiceWorker enters the installation
358 // phase.
359 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_UpdateFound,
360 int /* thread_id */,
361 int /* registration_handle_id */)
363 // Tells the child process to set the controller ServiceWorker for the given
364 // provider.
365 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_SetControllerServiceWorker,
366 int /* thread_id */,
367 int /* provider_id */,
368 content::ServiceWorkerObjectInfo,
369 bool /* should_notify_controllerchange */)
371 // Sends a 'message' event to a client document (browser->renderer).
372 IPC_MESSAGE_CONTROL5(
373 ServiceWorkerMsg_MessageToDocument,
374 int /* thread_id */,
375 int /* provider_id */,
376 base::string16 /* message */,
377 std::vector<content::TransferredMessagePort> /* sent_message_ports */,
378 std::vector<int> /* new_routing_ids */)
380 // Sent via EmbeddedWorker to dispatch events.
381 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_InstallEvent,
382 int /* request_id */)
383 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent,
384 int /* request_id */)
385 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent,
386 int /* request_id */,
387 content::ServiceWorkerFetchRequest)
388 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_SyncEvent,
389 int /* request_id */)
390 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_NotificationClickEvent,
391 int /* request_id */,
392 int64_t /* persistent_notification_id */,
393 content::PlatformNotificationData /* notification_data */)
394 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_PushEvent,
395 int /* request_id */,
396 std::string /* data */)
397 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_GeofencingEvent,
398 int /* request_id */,
399 blink::WebGeofencingEventType /* event_type */,
400 std::string /* region_id */,
401 blink::WebCircularGeofencingRegion /* region */)
402 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CrossOriginConnectEvent,
403 int /* request_id */,
404 content::NavigatorConnectClient /* client */)
405 IPC_MESSAGE_CONTROL3(
406 ServiceWorkerMsg_MessageToWorker,
407 base::string16 /* message */,
408 std::vector<content::TransferredMessagePort> /* sent_message_ports */,
409 std::vector<int> /* new_routing_ids */)
410 IPC_MESSAGE_CONTROL4(
411 ServiceWorkerMsg_CrossOriginMessageToWorker,
412 content::NavigatorConnectClient /* client */,
413 base::string16 /* message */,
414 std::vector<content::TransferredMessagePort> /* sent_message_ports */,
415 std::vector<int> /* new_routing_ids */)
416 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_DidSkipWaiting,
417 int /* request_id */)
418 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_DidClaimClients,
419 int /* request_id */)
420 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ClaimClientsError,
421 int /* request_id */,
422 blink::WebServiceWorkerError::ErrorType /* code */,
423 base::string16 /* message */)
425 // Sent via EmbeddedWorker to Ping the worker, expecting a Pong in response.
426 IPC_MESSAGE_CONTROL0(ServiceWorkerMsg_Ping)
428 // Sent via EmbeddedWorker as a response of GetClients.
429 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClients,
430 int /* request_id */,
431 std::vector<content::ServiceWorkerClientInfo>)
433 // Sent via EmbeddedWorker as a response of OpenWindow.
434 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_OpenWindowResponse,
435 int /* request_id */,
436 content::ServiceWorkerClientInfo /* client */)
438 // Sent via EmbeddedWorker as an error response of OpenWindow.
439 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_OpenWindowError,
440 int /* request_id */,
441 std::string /* message */ )
443 // Sent via EmbeddedWorker as a response of FocusClient.
444 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FocusClientResponse,
445 int /* request_id */,
446 content::ServiceWorkerClientInfo /* client */)
448 // Sent via EmbeddedWorker to transfer a stashed message port to the worker.
449 IPC_MESSAGE_CONTROL3(
450 ServiceWorkerMsg_SendStashedMessagePorts,
451 std::vector<content::TransferredMessagePort> /* stashed_message_ports */,
452 std::vector<int> /* new_routing_ids */,
453 std::vector<base::string16> /* port_names */)