Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / common / resource_messages.h
1 // Copyright (c) 2012 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 // IPC messages for resource loading.
6 //
7 // NOTE: All messages must send an |int request_id| as their first parameter.
8
9 // Multiply-included message file, hence no include guard.
10 #include "base/memory/shared_memory.h"
11 #include "base/process/process.h"
12 #include "content/common/content_param_traits_macros.h"
13 #include "content/public/common/common_param_traits.h"
14 #include "content/public/common/resource_response.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "net/base/request_priority.h"
17 #include "net/http/http_response_info.h"
18 #include "webkit/common/resource_request_body.h"
19
20 #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
21 #define CONTENT_COMMON_RESOURCE_MESSAGES_H_
22
23 namespace net {
24 struct LoadTimingInfo;
25 }
26
27 namespace webkit_glue {
28 struct ResourceDevToolsInfo;
29 }
30
31 namespace IPC {
32
33 template <>
34 struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
35   typedef scoped_refptr<net::HttpResponseHeaders> param_type;
36   static void Write(Message* m, const param_type& p);
37   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
38   static void Log(const param_type& p, std::string* l);
39 };
40
41 template <>
42 struct CONTENT_EXPORT ParamTraits<webkit_common::DataElement> {
43   typedef webkit_common::DataElement param_type;
44   static void Write(Message* m, const param_type& p);
45   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
46   static void Log(const param_type& p, std::string* l);
47 };
48
49 template <>
50 struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > {
51   typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type;
52   static void Write(Message* m, const param_type& p);
53   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
54   static void Log(const param_type& p, std::string* l);
55 };
56
57 template <>
58 struct ParamTraits<net::LoadTimingInfo> {
59   typedef net::LoadTimingInfo param_type;
60   static void Write(Message* m, const param_type& p);
61   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
62   static void Log(const param_type& p, std::string* l);
63 };
64
65 template <>
66 struct ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> > {
67   typedef scoped_refptr<webkit_glue::ResourceRequestBody> param_type;
68   static void Write(Message* m, const param_type& p);
69   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
70   static void Log(const param_type& p, std::string* l);
71 };
72
73 }  // namespace IPC
74
75 #endif  // CONTENT_COMMON_RESOURCE_MESSAGES_H_
76
77
78 #define IPC_MESSAGE_START ResourceMsgStart
79 #undef IPC_MESSAGE_EXPORT
80 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
81
82 IPC_ENUM_TRAITS_MAX_VALUE( \
83     net::HttpResponseInfo::ConnectionInfo, \
84     net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
85
86 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
87   IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo)
88   IPC_STRUCT_TRAITS_MEMBER(error_code)
89   IPC_STRUCT_TRAITS_MEMBER(request_start)
90   IPC_STRUCT_TRAITS_MEMBER(response_start)
91 IPC_STRUCT_TRAITS_END()
92
93 IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
94   IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
95   IPC_STRUCT_TRAITS_MEMBER(final_url)
96   IPC_STRUCT_TRAITS_MEMBER(data)
97 IPC_STRUCT_TRAITS_END()
98
99 IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo)
100   IPC_STRUCT_TRAITS_MEMBER(request_time)
101   IPC_STRUCT_TRAITS_MEMBER(response_time)
102   IPC_STRUCT_TRAITS_MEMBER(headers)
103   IPC_STRUCT_TRAITS_MEMBER(mime_type)
104   IPC_STRUCT_TRAITS_MEMBER(charset)
105   IPC_STRUCT_TRAITS_MEMBER(security_info)
106   IPC_STRUCT_TRAITS_MEMBER(content_length)
107   IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
108   IPC_STRUCT_TRAITS_MEMBER(appcache_id)
109   IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
110   IPC_STRUCT_TRAITS_MEMBER(load_timing)
111   IPC_STRUCT_TRAITS_MEMBER(devtools_info)
112   IPC_STRUCT_TRAITS_MEMBER(download_file_path)
113   IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
114   IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
115   IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
116   IPC_STRUCT_TRAITS_MEMBER(connection_info)
117   IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
118   IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
119   IPC_STRUCT_TRAITS_MEMBER(socket_address)
120 IPC_STRUCT_TRAITS_END()
121
122 // Parameters for a resource request.
123 IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
124   // The request method: GET, POST, etc.
125   IPC_STRUCT_MEMBER(std::string, method)
126
127   // The requested URL.
128   IPC_STRUCT_MEMBER(GURL, url)
129
130   // Usually the URL of the document in the top-level window, which may be
131   // checked by the third-party cookie blocking policy. Leaving it empty may
132   // lead to undesired cookie blocking. Third-party cookie blocking can be
133   // bypassed by setting first_party_for_cookies = url, but this should ideally
134   // only be done if there really is no way to determine the correct value.
135   IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
136
137   // The referrer to use (may be empty).
138   IPC_STRUCT_MEMBER(GURL, referrer)
139
140   // The referrer policy to use.
141   IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
142
143   // The frame's visiblity state.
144   IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
145
146   // Additional HTTP request headers.
147   IPC_STRUCT_MEMBER(std::string, headers)
148
149   // net::URLRequest load flags (0 by default).
150   IPC_STRUCT_MEMBER(int, load_flags)
151
152   // Process ID from which this request originated, or zero if it originated
153   // in the renderer itself.
154   // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
155   // through the renderer and and this holds the pid of the plugin process.
156   // Otherwise this holds the render_process_id of the view that has the plugin.
157   IPC_STRUCT_MEMBER(int, origin_pid)
158
159   // What this resource load is for (main frame, sub-frame, sub-resource,
160   // object).
161   IPC_STRUCT_MEMBER(ResourceType::Type, resource_type)
162
163   // The priority of this request.
164   IPC_STRUCT_MEMBER(net::RequestPriority, priority)
165
166   // Used by plugin->browser requests to get the correct net::URLRequestContext.
167   IPC_STRUCT_MEMBER(uint32, request_context)
168
169   // Indicates which frame (or worker context) the request is being loaded into,
170   // or kNoHostId.
171   IPC_STRUCT_MEMBER(int, appcache_host_id)
172
173   // Optional resource request body (may be null).
174   IPC_STRUCT_MEMBER(scoped_refptr<webkit_glue::ResourceRequestBody>,
175                     request_body)
176
177   IPC_STRUCT_MEMBER(bool, download_to_file)
178
179   // True if the request was user initiated.
180   IPC_STRUCT_MEMBER(bool, has_user_gesture)
181
182   // The routing id of the RenderFrame.
183   IPC_STRUCT_MEMBER(int, render_frame_id)
184
185   // True if |frame_id| is the main frame of a RenderView.
186   IPC_STRUCT_MEMBER(bool, is_main_frame)
187
188   // Identifies the frame within the RenderView that sent the request.
189   // -1 if unknown / invalid.
190   IPC_STRUCT_MEMBER(int64, frame_id)
191
192   // True if |parent_frame_id| is the main frame of a RenderView.
193   IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
194
195   // Identifies the parent frame of the frame that sent the request.
196   // -1 if unknown / invalid.
197   IPC_STRUCT_MEMBER(int64, parent_frame_id)
198
199   IPC_STRUCT_MEMBER(content::PageTransition, transition_type)
200
201   // For navigations, whether this navigation should replace the current session
202   // history entry on commit.
203   IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
204
205   // The following two members identify a previous request that has been
206   // created before this navigation has been transferred to a new render view.
207   // This serves the purpose of recycling the old request.
208   // Unless this refers to a transferred navigation, these values are -1 and -1.
209   IPC_STRUCT_MEMBER(int, transferred_request_child_id)
210   IPC_STRUCT_MEMBER(int, transferred_request_request_id)
211
212   // Whether or not we should allow the URL to download.
213   IPC_STRUCT_MEMBER(bool, allow_download)
214 IPC_STRUCT_END()
215
216 // Parameters for a ResourceMsg_RequestComplete
217 IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
218   // The error code.
219   IPC_STRUCT_MEMBER(int, error_code)
220
221   // Was ignored by the request handler.
222   IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
223
224   // A copy of the data requested exists in the cache.
225   IPC_STRUCT_MEMBER(bool, exists_in_cache)
226
227   // Serialized security info; see content/common/ssl_status_serialization.h.
228   IPC_STRUCT_MEMBER(std::string, security_info)
229
230   // Time the request completed.
231   IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
232
233   // Total amount of data received from the network.
234   IPC_STRUCT_MEMBER(int64, encoded_data_length)
235 IPC_STRUCT_END()
236
237 // Resource messages sent from the browser to the renderer.
238
239 // Sent when the headers are available for a resource request.
240 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
241                      int /* request_id */,
242                      content::ResourceResponseHead)
243
244 // Sent when cached metadata from a resource request is ready.
245 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
246                      int /* request_id */,
247                      std::vector<char> /* data */)
248
249 // Sent as upload progress is being made.
250 IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
251                      int /* request_id */,
252                      int64 /* position */,
253                      int64 /* size */)
254
255 // Sent when the request has been redirected.  The receiver is expected to
256 // respond with either a FollowRedirect message (if the redirect is to be
257 // followed) or a CancelRequest message (if it should not be followed).
258 IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
259                      int /* request_id */,
260                      GURL /* new_url */,
261                      content::ResourceResponseHead)
262
263 // Sent to set the shared memory buffer to be used to transmit response data to
264 // the renderer.  Subsequent DataReceived messages refer to byte ranges in the
265 // shared memory buffer.  The shared memory buffer should be retained by the
266 // renderer until the resource request completes.
267 //
268 // NOTE: The shared memory handle should already be mapped into the process
269 // that receives this message.
270 //
271 // TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
272 // added to help in debugging crbug/160401.
273 //
274 IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
275                      int /* request_id */,
276                      base::SharedMemoryHandle /* shm_handle */,
277                      int /* shm_size */,
278                      base::ProcessId /* renderer_pid */)
279
280 // Sent when some data from a resource request is ready.  The data offset and
281 // length specify a byte range into the shared memory buffer provided by the
282 // SetDataBuffer message.
283 IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
284                      int /* request_id */,
285                      int /* data_offset */,
286                      int /* data_length */,
287                      int /* encoded_data_length */)
288
289 // Sent when some data from a resource request has been downloaded to
290 // file. This is only called in the 'download_to_file' case and replaces
291 // ResourceMsg_DataReceived in the call sequence in that case.
292 IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
293                      int /* request_id */,
294                      int /* data_len */,
295                      int /* encoded_data_length */)
296
297 // Sent when the request has been completed.
298 IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
299                      int /* request_id */,
300                      ResourceMsg_RequestCompleteData)
301
302 // Resource messages sent from the renderer to the browser.
303
304 // Makes a resource request via the browser.
305 IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource,
306                     int /* request_id */,
307                     ResourceHostMsg_Request)
308
309 // Cancels a resource request with the ID given as the parameter.
310 IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
311                      int /* request_id */)
312
313 // Follows a redirect that occured for the resource request with the ID given
314 // as the parameter.
315 IPC_MESSAGE_CONTROL3(ResourceHostMsg_FollowRedirect,
316                      int /* request_id */,
317                      bool /* has_new_first_party_for_cookies */,
318                      GURL /* new_first_party_for_cookies */)
319
320 // Makes a synchronous resource request via the browser.
321 IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
322                            int /* request_id */,
323                            ResourceHostMsg_Request,
324                            content::SyncLoadResult)
325
326 // Sent when the renderer process is done processing a DataReceived
327 // message.
328 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
329                      int /* request_id */)
330
331 // Sent when the renderer has processed a DataDownloaded message.
332 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
333                      int /* request_id */)
334
335 // Sent by the renderer process to acknowledge receipt of a
336 // UploadProgress message.
337 IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
338                      int /* request_id */)
339
340 // Sent when the renderer process deletes a resource loader.
341 IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
342                      int /* request_id */)
343
344 // Sent by the renderer when a resource request changes priority.
345 IPC_MESSAGE_CONTROL2(ResourceHostMsg_DidChangePriority,
346                      int /* request_id */,
347                      net::RequestPriority)