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(method)
43 IPC_STRUCT_TRAITS_MEMBER(headers)
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 */)
114 // Asks the browser to retrieve documents controlled by the sender
116 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GetClientDocuments,
117 int /* request_id */)
119 // Sends a 'message' event to a client document (renderer->browser).
120 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_PostMessageToDocument,
122 base::string16 /* message */,
123 std::vector<int> /* sent_message_port_ids */)
125 //---------------------------------------------------------------------------
126 // Messages sent from the browser to the child process.
128 // NOTE: All ServiceWorkerMsg messages not sent via EmbeddedWorker must have
129 // a thread_id as their first field so that ServiceWorkerMessageFilter can
130 // extract it and dispatch the message to the correct ServiceWorkerDispatcher
131 // on the correct thread.
133 // Response to ServiceWorkerMsg_RegisterServiceWorker.
134 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerRegistered,
136 int /* request_id */,
137 content::ServiceWorkerObjectInfo)
139 // Response to ServiceWorkerMsg_UnregisterServiceWorker.
140 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_ServiceWorkerUnregistered,
142 int /* request_id */)
144 // Sent when any kind of registration error occurs during a
145 // RegisterServiceWorker / UnregisterServiceWorker handler above.
146 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError,
148 int /* request_id */,
149 blink::WebServiceWorkerError::ErrorType /* code */,
150 base::string16 /* message */)
152 // Informs the child process that the ServiceWorker's state has changed.
153 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged,
156 blink::WebServiceWorkerState)
158 // Tells the child process to set the current ServiceWorker for the given
160 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_SetCurrentServiceWorker,
162 int /* provider_id */,
163 content::ServiceWorkerObjectInfo)
165 // Sends a 'message' event to a client document (browser->renderer).
166 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_MessageToDocument,
168 int /* provider_id */,
169 base::string16 /* message */,
170 std::vector<int> /* sent_message_port_ids */,
171 std::vector<int> /* new_routing_ids */)
173 // Sent via EmbeddedWorker to dispatch events.
174 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_InstallEvent,
175 int /* request_id */,
176 int /* active_version_id */)
177 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent,
178 int /* request_id */)
179 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent,
180 int /* request_id */,
181 content::ServiceWorkerFetchRequest)
182 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_SyncEvent,
183 int /* request_id */)
184 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_MessageToWorker,
185 base::string16 /* message */,
186 std::vector<int> /* sent_message_port_ids */,
187 std::vector<int> /* new_routing_ids */)
189 // Sent via EmbeddedWorker as a response of GetClientDocuments.
190 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClientDocuments,
191 int /* request_id */,
192 std::vector<int> /* client_ids */)