Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / common / service_worker / service_worker_messages.h
blob1362f0952c58bab981f37ac96ede5b0e1463d898
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_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/WebServiceWorkerCacheError.h"
16 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
17 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
18 #include "url/gurl.h"
20 #undef IPC_MESSAGE_EXPORT
21 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
23 #define IPC_MESSAGE_START ServiceWorkerMsgStart
25 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerError::ErrorType,
26 blink::WebServiceWorkerError::ErrorTypeLast)
28 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerEventResult,
29 blink::WebServiceWorkerEventResultLast)
31 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerState,
32 blink::WebServiceWorkerStateLast)
34 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerFetchRequest)
35 IPC_STRUCT_TRAITS_MEMBER(url)
36 IPC_STRUCT_TRAITS_MEMBER(method)
37 IPC_STRUCT_TRAITS_MEMBER(headers)
38 IPC_STRUCT_TRAITS_MEMBER(blob_uuid)
39 IPC_STRUCT_TRAITS_MEMBER(blob_size)
40 IPC_STRUCT_TRAITS_MEMBER(referrer)
41 IPC_STRUCT_TRAITS_MEMBER(is_reload)
42 IPC_STRUCT_TRAITS_END()
44 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult,
45 content::SERVICE_WORKER_FETCH_EVENT_LAST)
47 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerResponse)
48 IPC_STRUCT_TRAITS_MEMBER(url)
49 IPC_STRUCT_TRAITS_MEMBER(status_code)
50 IPC_STRUCT_TRAITS_MEMBER(status_text)
51 IPC_STRUCT_TRAITS_MEMBER(headers)
52 IPC_STRUCT_TRAITS_MEMBER(blob_uuid)
53 IPC_STRUCT_TRAITS_END()
55 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo)
56 IPC_STRUCT_TRAITS_MEMBER(handle_id)
57 IPC_STRUCT_TRAITS_MEMBER(scope)
58 IPC_STRUCT_TRAITS_MEMBER(url)
59 IPC_STRUCT_TRAITS_MEMBER(state)
60 IPC_STRUCT_TRAITS_END()
62 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerRegistrationObjectInfo)
63 IPC_STRUCT_TRAITS_MEMBER(handle_id)
64 IPC_STRUCT_TRAITS_MEMBER(scope)
65 IPC_STRUCT_TRAITS_END()
67 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerVersionAttributes)
68 IPC_STRUCT_TRAITS_MEMBER(installing)
69 IPC_STRUCT_TRAITS_MEMBER(waiting)
70 IPC_STRUCT_TRAITS_MEMBER(active)
71 IPC_STRUCT_TRAITS_END()
73 IPC_ENUM_TRAITS_MAX_VALUE(
74 blink::WebServiceWorkerCacheError,
75 blink::WebServiceWorkerCacheErrorLast)
77 //---------------------------------------------------------------------------
78 // Messages sent from the child process to the browser.
80 IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker,
81 int /* thread_id */,
82 int /* request_id */,
83 int /* provider_id */,
84 GURL /* scope */,
85 GURL /* script_url */)
87 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker,
88 int /* thread_id */,
89 int /* request_id */,
90 int /* provider_id */,
91 GURL /* scope (url pattern) */)
93 // Sends a 'message' event to a service worker (renderer->browser).
94 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_PostMessageToWorker,
95 int /* handle_id */,
96 base::string16 /* message */,
97 std::vector<int> /* sent_message_port_ids */)
99 // Informs the browser of a new ServiceWorkerProvider in the child process,
100 // |provider_id| is unique within its child process.
101 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderCreated,
102 int /* provider_id */)
104 // Informs the browser of a ServiceWorkerProvider being destroyed.
105 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderDestroyed,
106 int /* provider_id */)
108 // Increments and decrements the ServiceWorker object's reference
109 // counting in the browser side. The ServiceWorker object is created
110 // with ref-count==1 initially.
111 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount,
112 int /* handle_id */)
113 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount,
114 int /* handle_id */)
116 // Increments and decrements the ServiceWorkerRegistration object's reference
117 // counting in the browser side. The registration object is created with
118 // ref-count==1 initially.
119 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementRegistrationRefCount,
120 int /* registration_handle_id */)
121 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementRegistrationRefCount,
122 int /* registration_handle_id */)
124 // Informs the browser that |provider_id| is associated
125 // with a service worker script running context and
126 // |version_id| identifies which ServiceWorkerVersion.
127 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_SetVersionId,
128 int /* provider_id */,
129 int64 /* version_id */)
131 // Informs the browser that event handling has finished.
132 // Routed to the target ServiceWorkerVersion.
133 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_InstallEventFinished,
134 int /* request_id */,
135 blink::WebServiceWorkerEventResult)
136 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_ActivateEventFinished,
137 int /* request_id */,
138 blink::WebServiceWorkerEventResult)
139 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_FetchEventFinished,
140 int /* request_id */,
141 content::ServiceWorkerFetchEventResult,
142 content::ServiceWorkerResponse)
143 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SyncEventFinished,
144 int /* request_id */)
145 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_PushEventFinished,
146 int /* request_id */)
148 // Asks the browser to retrieve documents controlled by the sender
149 // ServiceWorker.
150 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GetClientDocuments,
151 int /* request_id */)
153 // Sends a 'message' event to a client document (renderer->browser).
154 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_PostMessageToDocument,
155 int /* client_id */,
156 base::string16 /* message */,
157 std::vector<int> /* sent_message_port_ids */)
159 // CacheStorage operations in the browser.
160 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageGet,
161 int /* request_id */,
162 base::string16 /* fetch_store_name */)
164 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageHas,
165 int /* request_id */,
166 base::string16 /* fetch_store_name */)
168 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageCreate,
169 int /* request_id */,
170 base::string16 /* fetch_store_name */)
172 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageDelete,
173 int /* request_id */,
174 base::string16 /* fetch_store_name */)
176 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_CacheStorageKeys,
177 int /* request_id */)
179 //---------------------------------------------------------------------------
180 // Messages sent from the browser to the child process.
182 // NOTE: All ServiceWorkerMsg messages not sent via EmbeddedWorker must have
183 // a thread_id as their first field so that ServiceWorkerMessageFilter can
184 // extract it and dispatch the message to the correct ServiceWorkerDispatcher
185 // on the correct thread.
187 // Response to ServiceWorkerMsg_RegisterServiceWorker.
188 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerRegistered,
189 int /* thread_id */,
190 int /* request_id */,
191 content::ServiceWorkerRegistrationObjectInfo)
193 // Response to ServiceWorkerMsg_UnregisterServiceWorker.
194 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_ServiceWorkerUnregistered,
195 int /* thread_id */,
196 int /* request_id */)
198 // Sent when any kind of registration error occurs during a
199 // RegisterServiceWorker / UnregisterServiceWorker handler above.
200 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError,
201 int /* thread_id */,
202 int /* request_id */,
203 blink::WebServiceWorkerError::ErrorType /* code */,
204 base::string16 /* message */)
206 // Informs the child process that the ServiceWorker's state has changed.
207 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged,
208 int /* thread_id */,
209 int /* handle_id */,
210 blink::WebServiceWorkerState)
212 // Tells the child process to set service workers for the given provider.
213 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_SetVersionAttributes,
214 int /* thread_id */,
215 int /* provider_id */,
216 int /* registration_handle_id */,
217 int /* changed_mask */,
218 content::ServiceWorkerVersionAttributes)
220 // Tells the child process to set the controller ServiceWorker for the given
221 // provider.
222 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_SetControllerServiceWorker,
223 int /* thread_id */,
224 int /* provider_id */,
225 content::ServiceWorkerObjectInfo)
227 // Sends a 'message' event to a client document (browser->renderer).
228 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_MessageToDocument,
229 int /* thread_id */,
230 int /* provider_id */,
231 base::string16 /* message */,
232 std::vector<int> /* sent_message_port_ids */,
233 std::vector<int> /* new_routing_ids */)
235 // Sent via EmbeddedWorker to dispatch events.
236 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_InstallEvent,
237 int /* request_id */,
238 int /* active_version_id */)
239 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent,
240 int /* request_id */)
241 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent,
242 int /* request_id */,
243 content::ServiceWorkerFetchRequest)
244 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_SyncEvent,
245 int /* request_id */)
246 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_PushEvent,
247 int /* request_id */,
248 std::string /* data */)
249 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_MessageToWorker,
250 base::string16 /* message */,
251 std::vector<int> /* sent_message_port_ids */,
252 std::vector<int> /* new_routing_ids */)
254 // Sent via EmbeddedWorker as a response of GetClientDocuments.
255 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClientDocuments,
256 int /* request_id */,
257 std::vector<int> /* client_ids */)
259 // Sent via EmbeddedWorker at successful completion of CacheStorage operations.
260 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageGetSuccess,
261 int /* request_id */,
262 int /* fetch_store_id */)
263 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_CacheStorageHasSuccess,
264 int /* request_id */)
265 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageCreateSuccess,
266 int /* request_id */,
267 int /* fetch_store_id */)
268 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_CacheStorageDeleteSuccess,
269 int /* request_id */)
270 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageKeysSuccess,
271 int /* request_id */,
272 std::vector<base::string16> /* keys */)
274 // Sent via EmbeddedWorker at erroneous completion of CacheStorage operations.
275 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageGetError,
276 int /* request_id */,
277 blink::WebServiceWorkerCacheError /* reason */)
278 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageHasError,
279 int /* request_id */,
280 blink::WebServiceWorkerCacheError /* reason */)
281 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageCreateError,
282 int /* request_id */,
283 blink::WebServiceWorkerCacheError /* reason */)
284 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageDeleteError,
285 int /* request_id */,
286 blink::WebServiceWorkerCacheError /* reason */)
287 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageKeysError,
288 int /* request_id */,
289 blink::WebServiceWorkerCacheError /* reason */)