Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / common / service_worker / service_worker_messages.h
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.
4
5 // Message definition file, included multiple times, hence no include guard.
6
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"
14 #include "url/gurl.h"
15
16 #undef IPC_MESSAGE_EXPORT
17 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
18
19 #define IPC_MESSAGE_START ServiceWorkerMsgStart
20
21 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerError::ErrorType,
22                           blink::WebServiceWorkerError::ErrorTypeLast)
23
24 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerEventResult,
25                           blink::WebServiceWorkerEventResultLast)
26
27 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerState,
28                           blink::WebServiceWorkerStateLast)
29
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()
35
36 IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult,
37                           content::SERVICE_WORKER_FETCH_EVENT_LAST)
38
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()
45
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()
52
53 //---------------------------------------------------------------------------
54 // Messages sent from the child process to the browser.
55
56 IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker,
57                      int /* thread_id */,
58                      int /* request_id */,
59                      int /* provider_id */,
60                      GURL /* scope */,
61                      GURL /* script_url */)
62
63 IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker,
64                      int /* thread_id */,
65                      int /* request_id */,
66                      int /* provider_id */,
67                      GURL /* scope (url pattern) */)
68
69 // Sends a 'message' event to a service worker (renderer->browser).
70 IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_PostMessageToWorker,
71                      int /* handle_id */,
72                      base::string16 /* message */,
73                      std::vector<int> /* sent_message_port_ids */)
74
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 */)
79
80 // Informs the browser of a ServiceWorkerProvider being destroyed.
81 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_ProviderDestroyed,
82                      int /* provider_id */)
83
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,
88                      int /* handle_id */)
89 IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount,
90                      int /* handle_id */)
91
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 */)
98
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
114 // Asks the browser to retrieve documents controlled by the sender
115 // ServiceWorker.
116 IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_GetClientDocuments,
117                     int /* request_id */)
118
119 // Sends a 'message' event to a client document (renderer->browser).
120 IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_PostMessageToDocument,
121                     int /* client_id */,
122                     base::string16 /* message */,
123                     std::vector<int> /* sent_message_port_ids */)
124
125 //---------------------------------------------------------------------------
126 // Messages sent from the browser to the child process.
127 //
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.
132
133 // Response to ServiceWorkerMsg_RegisterServiceWorker.
134 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerRegistered,
135                      int /* thread_id */,
136                      int /* request_id */,
137                      content::ServiceWorkerObjectInfo)
138
139 // Response to ServiceWorkerMsg_UnregisterServiceWorker.
140 IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_ServiceWorkerUnregistered,
141                      int /* thread_id */,
142                      int /* request_id */)
143
144 // Sent when any kind of registration error occurs during a
145 // RegisterServiceWorker / UnregisterServiceWorker handler above.
146 IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError,
147                      int /* thread_id */,
148                      int /* request_id */,
149                      blink::WebServiceWorkerError::ErrorType /* code */,
150                      base::string16 /* message */)
151
152 // Informs the child process that the ServiceWorker's state has changed.
153 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged,
154                      int /* thread_id */,
155                      int /* handle_id */,
156                      blink::WebServiceWorkerState)
157
158 // Tells the child process to set the current ServiceWorker for the given
159 // provider.
160 IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_SetCurrentServiceWorker,
161                      int /* thread_id */,
162                      int /* provider_id */,
163                      content::ServiceWorkerObjectInfo)
164
165 // Sends a 'message' event to a client document (browser->renderer).
166 IPC_MESSAGE_CONTROL5(ServiceWorkerMsg_MessageToDocument,
167                      int /* thread_id */,
168                      int /* provider_id */,
169                      base::string16 /* message */,
170                      std::vector<int> /* sent_message_port_ids */,
171                      std::vector<int> /* new_routing_ids */)
172
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 */)
188
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 */)