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 "base/strings/string16.h"
8 #include "content/common/service_worker/service_worker_status_code.h"
9 #include "content/common/service_worker/service_worker_types.h"
10 #include "ipc/ipc_message_macros.h"
11 #include "ipc/ipc_param_traits.h"
12 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
13 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
16 #undef IPC_MESSAGE_EXPORT
17 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
19 #define IPC_MESSAGE_START ServiceWorkerMsgStart
21 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerError::ErrorType,
22 blink::WebServiceWorkerError::ErrorTypeLast)
24 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerEventResult,
25 blink::WebServiceWorkerEventResultLast)
27 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerState,
28 blink::WebServiceWorkerStateLast)
30 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerFetchRequest)
31 IPC_STRUCT_TRAITS_MEMBER(url)
32 IPC_STRUCT_TRAITS_MEMBER(method)
33 IPC_STRUCT_TRAITS_MEMBER(headers)
34 IPC_STRUCT_TRAITS_END()
36 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult,
37 content::SERVICE_WORKER_FETCH_EVENT_LAST)
39 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerResponse)
40 IPC_STRUCT_TRAITS_MEMBER(status_code)
41 IPC_STRUCT_TRAITS_MEMBER(status_text)
42 IPC_STRUCT_TRAITS_MEMBER(headers)
43 IPC_STRUCT_TRAITS_MEMBER(blob_uuid)
44 IPC_STRUCT_TRAITS_END()
46 IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo)
47 IPC_STRUCT_TRAITS_MEMBER(handle_id)
48 IPC_STRUCT_TRAITS_MEMBER(scope)
49 IPC_STRUCT_TRAITS_MEMBER(url)
50 IPC_STRUCT_TRAITS_MEMBER(state)
51 IPC_STRUCT_TRAITS_END()
53 //---------------------------------------------------------------------------
54 // Messages sent from the child process to the browser.
56 IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker,
59 int /* provider_id */,
61 GURL /* script_url */)
63 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker,
66 int /* provider_id */,
67 GURL /* scope (url pattern) */)
69 // Sends a 'message' event to a service worker (renderer->browser).
70 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_PostMessageToWorker,
72 base::string16 /* message */,
73 std::vector<int> /* sent_message_port_ids */)
75 // Informs the browser of a new ServiceWorkerProvider in the child process,
76 // |provider_id| is unique within its child process.
77 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderCreated,
78 int /* provider_id */)
80 // Informs the browser of a ServiceWorkerProvider being destroyed.
81 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderDestroyed,
82 int /* provider_id */)
84 // Increments and decrements the ServiceWorker object's reference
85 // counting in the browser side. The ServiceWorker object is created
86 // with ref-count==1 initially.
87 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount,
89 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount,
92 // Informs the browser that |provider_id| is associated
93 // with a service worker script running context and
94 // |version_id| identifies which ServcieWorkerVersion.
95 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_SetVersionId,
96 int /* provider_id */,
97 int64 /* version_id */)
99 // Informs the browser that event handling has finished.
100 // Routed to the target ServiceWorkerVersion.
101 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_InstallEventFinished,
102 int /* request_id */,
103 blink::WebServiceWorkerEventResult)
104 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_ActivateEventFinished,
105 int /* request_id */,
106 blink::WebServiceWorkerEventResult);
107 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_FetchEventFinished,
108 int /* request_id */,
109 content::ServiceWorkerFetchEventResult,
110 content::ServiceWorkerResponse)
111 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SyncEventFinished,
112 int /* request_id */)
113 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_PushEventFinished,
114 int /* request_id */)
116 // Asks the browser to retrieve documents controlled by the sender
118 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GetClientDocuments,
119 int /* request_id */)
121 // Sends a 'message' event to a client document (renderer->browser).
122 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_PostMessageToDocument,
124 base::string16 /* message */,
125 std::vector<int> /* sent_message_port_ids */)
127 //---------------------------------------------------------------------------
128 // Messages sent from the browser to the child process.
130 // NOTE: All ServiceWorkerMsg messages not sent via EmbeddedWorker must have
131 // a thread_id as their first field so that ServiceWorkerMessageFilter can
132 // extract it and dispatch the message to the correct ServiceWorkerDispatcher
133 // on the correct thread.
135 // Response to ServiceWorkerMsg_RegisterServiceWorker.
136 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerRegistered,
138 int /* request_id */,
139 content::ServiceWorkerObjectInfo)
141 // Response to ServiceWorkerMsg_UnregisterServiceWorker.
142 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_ServiceWorkerUnregistered,
144 int /* request_id */)
146 // Sent when any kind of registration error occurs during a
147 // RegisterServiceWorker / UnregisterServiceWorker handler above.
148 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError,
150 int /* request_id */,
151 blink::WebServiceWorkerError::ErrorType /* code */,
152 base::string16 /* message */)
154 // Informs the child process that the ServiceWorker's state has changed.
155 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged,
158 blink::WebServiceWorkerState)
160 // Tells the child process to set the waiting ServiceWorker for the given
162 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_SetWaitingServiceWorker,
164 int /* provider_id */,
165 content::ServiceWorkerObjectInfo)
167 // Tells the child process to set the current ServiceWorker for the given
169 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_SetCurrentServiceWorker,
171 int /* provider_id */,
172 content::ServiceWorkerObjectInfo)
174 // Sends a 'message' event to a client document (browser->renderer).
175 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_MessageToDocument,
177 int /* provider_id */,
178 base::string16 /* message */,
179 std::vector<int> /* sent_message_port_ids */,
180 std::vector<int> /* new_routing_ids */)
182 // Sent via EmbeddedWorker to dispatch events.
183 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_InstallEvent,
184 int /* request_id */,
185 int /* active_version_id */)
186 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent,
187 int /* request_id */)
188 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent,
189 int /* request_id */,
190 content::ServiceWorkerFetchRequest)
191 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_SyncEvent,
192 int /* request_id */)
193 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_PushEvent,
194 int /* request_id */,
195 std::string /* data */)
196 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_MessageToWorker,
197 base::string16 /* message */,
198 std::vector<int> /* sent_message_port_ids */,
199 std::vector<int> /* new_routing_ids */)
201 // Sent via EmbeddedWorker as a response of GetClientDocuments.
202 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClientDocuments,
203 int /* request_id */,
204 std::vector<int> /* client_ids */)