blob: 00ba724d19297fbaab3fd16e1a1553eb18b1ae80 [file] [log] [blame]
[email protected]b9fd01ba2012-02-28 01:50:401// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]94dc971d2011-03-05 19:08:322// 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.
[email protected]a17df45d2013-02-15 11:12:466//
7// NOTE: All messages must send an |int request_id| as their first parameter.
[email protected]94dc971d2011-03-05 19:08:328
[email protected]e503a122011-03-17 18:20:529// Multiply-included message file, hence no include guard.
[email protected]9cc992b2013-07-17 06:30:3610#include "base/memory/shared_memory.h"
[email protected]71ed8e022013-07-25 14:39:5711#include "base/process/process.h"
[email protected]9d8ea302012-09-25 15:04:2212#include "content/common/content_param_traits_macros.h"
[email protected]19a5c7442011-10-21 20:00:4113#include "content/public/common/common_param_traits.h"
[email protected]2336ffe2011-11-24 01:23:3414#include "content/public/common/resource_response.h"
[email protected]94dc971d2011-03-05 19:08:3215#include "ipc/ipc_message_macros.h"
[email protected]a9344092d2013-02-27 00:56:4516#include "net/base/request_priority.h"
[email protected]92a98df92013-06-06 02:47:4217#include "net/http/http_response_info.h"
[email protected]748b0ad2013-06-27 08:00:4718#include "webkit/common/resource_request_body.h"
[email protected]94dc971d2011-03-05 19:08:3219
[email protected]9d8ea302012-09-25 15:04:2220#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
21#define CONTENT_COMMON_RESOURCE_MESSAGES_H_
22
[email protected]ec298802013-03-27 16:45:0723namespace net {
24struct LoadTimingInfo;
25}
26
[email protected]9d8ea302012-09-25 15:04:2227namespace webkit_glue {
28struct ResourceDevToolsInfo;
[email protected]9d8ea302012-09-25 15:04:2229}
30
31namespace IPC {
32
33template <>
34struct 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
41template <>
[email protected]2b4ae172013-07-11 01:46:2042struct CONTENT_EXPORT ParamTraits<webkit_common::DataElement> {
43 typedef webkit_common::DataElement param_type;
[email protected]9d8ea302012-09-25 15:04:2244 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
49template <>
50struct 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
57template <>
[email protected]ec298802013-03-27 16:45:0758struct ParamTraits<net::LoadTimingInfo> {
59 typedef net::LoadTimingInfo param_type;
[email protected]9d8ea302012-09-25 15:04:2260 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
65template <>
66struct 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
[email protected]94dc971d2011-03-05 19:08:3278#define IPC_MESSAGE_START ResourceMsgStart
[email protected]03ff5e52011-09-30 00:28:1479#undef IPC_MESSAGE_EXPORT
80#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
[email protected]94dc971d2011-03-05 19:08:3281
[email protected]92a98df92013-06-06 02:47:4282IPC_ENUM_TRAITS_MAX_VALUE( \
83 net::HttpResponseInfo::ConnectionInfo, \
84 net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
85
[email protected]2336ffe2011-11-24 01:23:3486IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
87 IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo)
[email protected]2756a8e2012-09-07 18:24:2988 IPC_STRUCT_TRAITS_MEMBER(error_code)
[email protected]d43d2e112012-08-07 01:10:1989 IPC_STRUCT_TRAITS_MEMBER(request_start)
90 IPC_STRUCT_TRAITS_MEMBER(response_start)
[email protected]2336ffe2011-11-24 01:23:3491IPC_STRUCT_TRAITS_END()
92
93IPC_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)
97IPC_STRUCT_TRAITS_END()
98
[email protected]94dc971d2011-03-05 19:08:3299IPC_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)
[email protected]dfd682172011-04-13 19:57:25107 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
[email protected]94dc971d2011-03-05 19:08:32108 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
109 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
[email protected]94dc971d2011-03-05 19:08:32110 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)
[email protected]92a98df92013-06-06 02:47:42116 IPC_STRUCT_TRAITS_MEMBER(connection_info)
[email protected]94dc971d2011-03-05 19:08:32117 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
[email protected]b9fd01ba2012-02-28 01:50:40118 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
[email protected]94dc971d2011-03-05 19:08:32119 IPC_STRUCT_TRAITS_MEMBER(socket_address)
120IPC_STRUCT_TRAITS_END()
121
[email protected]94dc971d2011-03-05 19:08:32122// Parameters for a resource request.
123IPC_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
[email protected]d5a50342011-12-05 21:56:52140 // The referrer policy to use.
[email protected]180ef242013-11-07 06:50:46141 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
[email protected]d5a50342011-12-05 21:56:52142
[email protected]48ed2612014-01-21 00:30:57143 // The frame's visiblity state.
144 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
145
[email protected]94dc971d2011-03-05 19:08:32146 // 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.
[email protected]01cb19912013-09-11 19:13:03154 // 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.
[email protected]94dc971d2011-03-05 19:08:32157 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
[email protected]102ab682013-02-05 19:45:32163 // The priority of this request.
[email protected]a9344092d2013-02-27 00:56:45164 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
[email protected]102ab682013-02-05 19:45:32165
[email protected]94dc971d2011-03-05 19:08:32166 // 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
[email protected]e3e402c2012-08-21 13:57:42173 // Optional resource request body (may be null).
174 IPC_STRUCT_MEMBER(scoped_refptr<webkit_glue::ResourceRequestBody>,
175 request_body)
[email protected]94dc971d2011-03-05 19:08:32176
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)
[email protected]418da612011-07-21 19:01:52181
[email protected]60eca4eb2013-12-06 00:02:16182 // The routing id of the RenderFrame.
183 IPC_STRUCT_MEMBER(int, render_frame_id)
184
[email protected]418da612011-07-21 19:01:52185 // True if |frame_id| is the main frame of a RenderView.
186 IPC_STRUCT_MEMBER(bool, is_main_frame)
187
[email protected]79a70282014-03-03 21:29:35188 // True if |parent_render_frame_id| is the main frame of a RenderView.
[email protected]91043a8232011-11-04 16:41:19189 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
190
191 // Identifies the parent frame of the frame that sent the request.
192 // -1 if unknown / invalid.
[email protected]79a70282014-03-03 21:29:35193 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
[email protected]91043a8232011-11-04 16:41:19194
[email protected]2905f742011-10-13 03:51:58195 IPC_STRUCT_MEMBER(content::PageTransition, transition_type)
[email protected]4ad5d77d2011-12-03 02:00:48196
[email protected]4972fc82013-11-19 04:33:42197 // For navigations, whether this navigation should replace the current session
198 // history entry on commit.
199 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
200
[email protected]4ad5d77d2011-12-03 02:00:48201 // The following two members identify a previous request that has been
202 // created before this navigation has been transferred to a new render view.
203 // This serves the purpose of recycling the old request.
204 // Unless this refers to a transferred navigation, these values are -1 and -1.
205 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
206 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
[email protected]80744782012-05-04 01:47:00207
208 // Whether or not we should allow the URL to download.
209 IPC_STRUCT_MEMBER(bool, allow_download)
[email protected]94dc971d2011-03-05 19:08:32210IPC_STRUCT_END()
211
[email protected]dcbe3df2014-02-06 23:08:37212// Parameters for a ResourceMsg_RequestComplete
213IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
214 // The error code.
215 IPC_STRUCT_MEMBER(int, error_code)
216
217 // Was ignored by the request handler.
218 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
219
220 // A copy of the data requested exists in the cache.
221 IPC_STRUCT_MEMBER(bool, exists_in_cache)
222
223 // Serialized security info; see content/common/ssl_status_serialization.h.
224 IPC_STRUCT_MEMBER(std::string, security_info)
225
226 // Time the request completed.
227 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
[email protected]c8c567582014-02-10 12:54:57228
229 // Total amount of data received from the network.
230 IPC_STRUCT_MEMBER(int64, encoded_data_length)
[email protected]dcbe3df2014-02-06 23:08:37231IPC_STRUCT_END()
232
[email protected]94dc971d2011-03-05 19:08:32233// Resource messages sent from the browser to the renderer.
234
235// Sent when the headers are available for a resource request.
[email protected]f4653192013-09-06 19:24:05236IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
237 int /* request_id */,
238 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32239
240// Sent when cached metadata from a resource request is ready.
[email protected]f4653192013-09-06 19:24:05241IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
242 int /* request_id */,
243 std::vector<char> /* data */)
[email protected]94dc971d2011-03-05 19:08:32244
245// Sent as upload progress is being made.
[email protected]f4653192013-09-06 19:24:05246IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
247 int /* request_id */,
248 int64 /* position */,
249 int64 /* size */)
[email protected]94dc971d2011-03-05 19:08:32250
251// Sent when the request has been redirected. The receiver is expected to
252// respond with either a FollowRedirect message (if the redirect is to be
253// followed) or a CancelRequest message (if it should not be followed).
[email protected]f4653192013-09-06 19:24:05254IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
255 int /* request_id */,
256 GURL /* new_url */,
257 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32258
[email protected]f0fa1ab2012-09-18 06:28:38259// Sent to set the shared memory buffer to be used to transmit response data to
260// the renderer. Subsequent DataReceived messages refer to byte ranges in the
261// shared memory buffer. The shared memory buffer should be retained by the
262// renderer until the resource request completes.
263//
264// NOTE: The shared memory handle should already be mapped into the process
265// that receives this message.
266//
[email protected]9d9387e2013-01-12 16:55:08267// TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
268// added to help in debugging crbug/160401.
269//
[email protected]f4653192013-09-06 19:24:05270IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
271 int /* request_id */,
272 base::SharedMemoryHandle /* shm_handle */,
273 int /* shm_size */,
274 base::ProcessId /* renderer_pid */)
[email protected]f0fa1ab2012-09-18 06:28:38275
276// Sent when some data from a resource request is ready. The data offset and
277// length specify a byte range into the shared memory buffer provided by the
278// SetDataBuffer message.
[email protected]f4653192013-09-06 19:24:05279IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
280 int /* request_id */,
281 int /* data_offset */,
282 int /* data_length */,
283 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32284
285// Sent when some data from a resource request has been downloaded to
286// file. This is only called in the 'download_to_file' case and replaces
287// ResourceMsg_DataReceived in the call sequence in that case.
[email protected]f4653192013-09-06 19:24:05288IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
289 int /* request_id */,
290 int /* data_len */,
291 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32292
293// Sent when the request has been completed.
[email protected]dcbe3df2014-02-06 23:08:37294IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
[email protected]f4653192013-09-06 19:24:05295 int /* request_id */,
[email protected]dcbe3df2014-02-06 23:08:37296 ResourceMsg_RequestCompleteData)
[email protected]94dc971d2011-03-05 19:08:32297
298// Resource messages sent from the renderer to the browser.
299
300// Makes a resource request via the browser.
301IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource,
302 int /* request_id */,
303 ResourceHostMsg_Request)
304
305// Cancels a resource request with the ID given as the parameter.
[email protected]f4653192013-09-06 19:24:05306IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
307 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32308
[email protected]94dc971d2011-03-05 19:08:32309// Follows a redirect that occured for the resource request with the ID given
310// as the parameter.
[email protected]f4653192013-09-06 19:24:05311IPC_MESSAGE_CONTROL3(ResourceHostMsg_FollowRedirect,
312 int /* request_id */,
313 bool /* has_new_first_party_for_cookies */,
314 GURL /* new_first_party_for_cookies */)
[email protected]94dc971d2011-03-05 19:08:32315
316// Makes a synchronous resource request via the browser.
317IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
318 int /* request_id */,
319 ResourceHostMsg_Request,
[email protected]2336ffe2011-11-24 01:23:34320 content::SyncLoadResult)
[email protected]94dc971d2011-03-05 19:08:32321
322// Sent when the renderer process is done processing a DataReceived
323// message.
[email protected]f4653192013-09-06 19:24:05324IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
325 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32326
327// Sent when the renderer has processed a DataDownloaded message.
[email protected]f4653192013-09-06 19:24:05328IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
329 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32330
331// Sent by the renderer process to acknowledge receipt of a
332// UploadProgress message.
[email protected]f4653192013-09-06 19:24:05333IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
334 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32335
336// Sent when the renderer process deletes a resource loader.
337IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
338 int /* request_id */)
[email protected]a9344092d2013-02-27 00:56:45339
340// Sent by the renderer when a resource request changes priority.
[email protected]f4653192013-09-06 19:24:05341IPC_MESSAGE_CONTROL2(ResourceHostMsg_DidChangePriority,
342 int /* request_id */,
343 net::RequestPriority)