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_PostMessage
,
71 int64
/* version_id */,
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 // Informs the browser of a ServiceWorker object being destroyed.
85 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ServiceWorkerObjectDestroyed
,
88 // Informs the browser that |provider_id| is associated
89 // with a service worker script running context and
90 // |version_id| identifies which ServcieWorkerVersion.
91 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_SetVersionId
,
92 int /* provider_id */,
93 int64
/* version_id */)
95 // Informs the browser of a new scriptable API client in the child process.
96 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_AddScriptClient
,
98 int /* provider_id */)
100 // Informs the browser that the scriptable API client is unregistered.
101 IPC_MESSAGE_CONTROL2(ServiceWorkerHostMsg_RemoveScriptClient
,
103 int /* provider_id */)
105 // Informs the browser that event handling has finished.
106 // Routed to the target ServiceWorkerVersion.
107 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_InstallEventFinished
,
108 int /* request_id */,
109 blink::WebServiceWorkerEventResult
)
110 IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_ActivateEventFinished
,
111 int /* request_id */,
112 blink::WebServiceWorkerEventResult
);
113 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_FetchEventFinished
,
114 int /* request_id */,
115 content::ServiceWorkerFetchEventResult
,
116 content::ServiceWorkerResponse
)
117 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_SyncEventFinished
,
118 int /* request_id */)
120 // Asks the browser to retrieve documents controlled by the sender
122 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GetClientDocuments
,
123 int /* request_id */)
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 // Sent via EmbeddedWorker to dispatch events.
166 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_InstallEvent
,
167 int /* request_id */,
168 int /* active_version_id */)
169 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_ActivateEvent
,
170 int /* request_id */)
171 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_FetchEvent
,
172 int /* request_id */,
173 content::ServiceWorkerFetchRequest
)
174 IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_SyncEvent
,
175 int /* request_id */)
176 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_Message
,
177 base::string16
/* message */,
178 std::vector
<int> /* sent_message_port_ids */,
179 std::vector
<int> /* new_routing_ids */)
181 // Sent via EmbeddedWorker as a response of GetClientDocuments.
182 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClientDocuments
,
183 int /* request_id */,
184 std::vector
<int> /* client_ids */)