blob: dc6147a96d2eebea75f42f863e3c4d055f708f27 [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]14f154a2014-03-11 16:24:4113#include "content/common/resource_request_body.h"
[email protected]19a5c7442011-10-21 20:00:4114#include "content/public/common/common_param_traits.h"
[email protected]2336ffe2011-11-24 01:23:3415#include "content/public/common/resource_response.h"
[email protected]94dc971d2011-03-05 19:08:3216#include "ipc/ipc_message_macros.h"
[email protected]a9344092d2013-02-27 00:56:4517#include "net/base/request_priority.h"
[email protected]92a98df92013-06-06 02:47:4218#include "net/http/http_response_info.h"
[email protected]cba24642014-08-15 20:49:5919#include "net/url_request/redirect_info.h"
[email protected]94dc971d2011-03-05 19:08:3220
[email protected]9d8ea302012-09-25 15:04:2221#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
22#define CONTENT_COMMON_RESOURCE_MESSAGES_H_
23
[email protected]ec298802013-03-27 16:45:0724namespace net {
25struct LoadTimingInfo;
26}
27
[email protected]48ffdf72014-05-31 02:16:5728namespace content {
[email protected]9d8ea302012-09-25 15:04:2229struct ResourceDevToolsInfo;
[email protected]9d8ea302012-09-25 15:04:2230}
31
32namespace IPC {
33
34template <>
35struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
36 typedef scoped_refptr<net::HttpResponseHeaders> param_type;
37 static void Write(Message* m, const param_type& p);
38 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
39 static void Log(const param_type& p, std::string* l);
40};
41
42template <>
[email protected]2b4ae172013-07-11 01:46:2043struct CONTENT_EXPORT ParamTraits<webkit_common::DataElement> {
44 typedef webkit_common::DataElement param_type;
[email protected]9d8ea302012-09-25 15:04:2245 static void Write(Message* m, const param_type& p);
46 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
47 static void Log(const param_type& p, std::string* l);
48};
49
50template <>
[email protected]48ffdf72014-05-31 02:16:5751struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
52 typedef scoped_refptr<content::ResourceDevToolsInfo> param_type;
[email protected]9d8ea302012-09-25 15:04:2253 static void Write(Message* m, const param_type& p);
54 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
55 static void Log(const param_type& p, std::string* l);
56};
57
58template <>
[email protected]ec298802013-03-27 16:45:0759struct ParamTraits<net::LoadTimingInfo> {
60 typedef net::LoadTimingInfo param_type;
[email protected]9d8ea302012-09-25 15:04:2261 static void Write(Message* m, const param_type& p);
62 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
63 static void Log(const param_type& p, std::string* l);
64};
65
66template <>
[email protected]14f154a2014-03-11 16:24:4167struct ParamTraits<scoped_refptr<content::ResourceRequestBody> > {
68 typedef scoped_refptr<content::ResourceRequestBody> param_type;
[email protected]9d8ea302012-09-25 15:04:2269 static void Write(Message* m, const param_type& p);
70 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
71 static void Log(const param_type& p, std::string* l);
72};
73
74} // namespace IPC
75
76#endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
77
78
[email protected]94dc971d2011-03-05 19:08:3279#define IPC_MESSAGE_START ResourceMsgStart
[email protected]03ff5e52011-09-30 00:28:1480#undef IPC_MESSAGE_EXPORT
81#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
[email protected]94dc971d2011-03-05 19:08:3282
[email protected]92a98df92013-06-06 02:47:4283IPC_ENUM_TRAITS_MAX_VALUE( \
84 net::HttpResponseInfo::ConnectionInfo, \
85 net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
86
[email protected]2336ffe2011-11-24 01:23:3487IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
[email protected]0bf419d12014-05-28 01:02:2388IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo)
[email protected]2756a8e2012-09-07 18:24:2989 IPC_STRUCT_TRAITS_MEMBER(error_code)
[email protected]d43d2e112012-08-07 01:10:1990 IPC_STRUCT_TRAITS_MEMBER(request_start)
91 IPC_STRUCT_TRAITS_MEMBER(response_start)
[email protected]2336ffe2011-11-24 01:23:3492IPC_STRUCT_TRAITS_END()
93
94IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
95 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
96 IPC_STRUCT_TRAITS_MEMBER(final_url)
97 IPC_STRUCT_TRAITS_MEMBER(data)
98IPC_STRUCT_TRAITS_END()
99
[email protected]0bf419d12014-05-28 01:02:23100IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo)
[email protected]94dc971d2011-03-05 19:08:32101 IPC_STRUCT_TRAITS_MEMBER(request_time)
102 IPC_STRUCT_TRAITS_MEMBER(response_time)
103 IPC_STRUCT_TRAITS_MEMBER(headers)
104 IPC_STRUCT_TRAITS_MEMBER(mime_type)
105 IPC_STRUCT_TRAITS_MEMBER(charset)
106 IPC_STRUCT_TRAITS_MEMBER(security_info)
107 IPC_STRUCT_TRAITS_MEMBER(content_length)
[email protected]dfd682172011-04-13 19:57:25108 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
[email protected]94dc971d2011-03-05 19:08:32109 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
110 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
[email protected]94dc971d2011-03-05 19:08:32111 IPC_STRUCT_TRAITS_MEMBER(load_timing)
112 IPC_STRUCT_TRAITS_MEMBER(devtools_info)
113 IPC_STRUCT_TRAITS_MEMBER(download_file_path)
114 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
115 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
116 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
[email protected]92a98df92013-06-06 02:47:42117 IPC_STRUCT_TRAITS_MEMBER(connection_info)
[email protected]94dc971d2011-03-05 19:08:32118 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
[email protected]b9fd01ba2012-02-28 01:50:40119 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
[email protected]94dc971d2011-03-05 19:08:32120 IPC_STRUCT_TRAITS_MEMBER(socket_address)
[email protected]6ee72da12014-07-22 04:39:10121 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker)
122 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker)
[email protected]94dc971d2011-03-05 19:08:32123IPC_STRUCT_TRAITS_END()
124
[email protected]cba24642014-08-15 20:49:59125IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo)
126 IPC_STRUCT_TRAITS_MEMBER(status_code)
127 IPC_STRUCT_TRAITS_MEMBER(new_method)
128 IPC_STRUCT_TRAITS_MEMBER(new_url)
129 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies)
130 IPC_STRUCT_TRAITS_MEMBER(new_referrer)
131IPC_STRUCT_TRAITS_END()
132
[email protected]94dc971d2011-03-05 19:08:32133// Parameters for a resource request.
134IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
135 // The request method: GET, POST, etc.
136 IPC_STRUCT_MEMBER(std::string, method)
137
138 // The requested URL.
139 IPC_STRUCT_MEMBER(GURL, url)
140
141 // Usually the URL of the document in the top-level window, which may be
142 // checked by the third-party cookie blocking policy. Leaving it empty may
143 // lead to undesired cookie blocking. Third-party cookie blocking can be
144 // bypassed by setting first_party_for_cookies = url, but this should ideally
145 // only be done if there really is no way to determine the correct value.
146 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
147
148 // The referrer to use (may be empty).
149 IPC_STRUCT_MEMBER(GURL, referrer)
150
[email protected]d5a50342011-12-05 21:56:52151 // The referrer policy to use.
[email protected]180ef242013-11-07 06:50:46152 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
[email protected]d5a50342011-12-05 21:56:52153
[email protected]48ed2612014-01-21 00:30:57154 // The frame's visiblity state.
155 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
156
[email protected]94dc971d2011-03-05 19:08:32157 // Additional HTTP request headers.
158 IPC_STRUCT_MEMBER(std::string, headers)
159
160 // net::URLRequest load flags (0 by default).
161 IPC_STRUCT_MEMBER(int, load_flags)
162
163 // Process ID from which this request originated, or zero if it originated
164 // in the renderer itself.
[email protected]01cb19912013-09-11 19:13:03165 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
166 // through the renderer and and this holds the pid of the plugin process.
167 // Otherwise this holds the render_process_id of the view that has the plugin.
[email protected]94dc971d2011-03-05 19:08:32168 IPC_STRUCT_MEMBER(int, origin_pid)
169
170 // What this resource load is for (main frame, sub-frame, sub-resource,
171 // object).
[email protected]6c1e05212014-07-31 00:59:40172 IPC_STRUCT_MEMBER(content::ResourceType, resource_type)
[email protected]94dc971d2011-03-05 19:08:32173
[email protected]102ab682013-02-05 19:45:32174 // The priority of this request.
[email protected]a9344092d2013-02-27 00:56:45175 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
[email protected]102ab682013-02-05 19:45:32176
[email protected]94dc971d2011-03-05 19:08:32177 // Used by plugin->browser requests to get the correct net::URLRequestContext.
178 IPC_STRUCT_MEMBER(uint32, request_context)
179
180 // Indicates which frame (or worker context) the request is being loaded into,
[email protected]10f110fa2014-06-15 23:32:46181 // or kAppCacheNoHostId.
[email protected]94dc971d2011-03-05 19:08:32182 IPC_STRUCT_MEMBER(int, appcache_host_id)
183
[email protected]c4c091f2014-03-07 13:06:13184 // Indicates which frame (or worker context) the request is being loaded into,
185 // or kInvalidServiceWorkerProviderId.
186 IPC_STRUCT_MEMBER(int, service_worker_provider_id)
187
[email protected]e3e402c2012-08-21 13:57:42188 // Optional resource request body (may be null).
[email protected]14f154a2014-03-11 16:24:41189 IPC_STRUCT_MEMBER(scoped_refptr<content::ResourceRequestBody>,
[email protected]e3e402c2012-08-21 13:57:42190 request_body)
[email protected]94dc971d2011-03-05 19:08:32191
192 IPC_STRUCT_MEMBER(bool, download_to_file)
193
194 // True if the request was user initiated.
195 IPC_STRUCT_MEMBER(bool, has_user_gesture)
[email protected]418da612011-07-21 19:01:52196
[email protected]3821f7a2014-08-13 16:40:08197 // True if load timing data should be collected for request.
198 IPC_STRUCT_MEMBER(bool, enable_load_timing)
199
[email protected]60eca4eb2013-12-06 00:02:16200 // The routing id of the RenderFrame.
201 IPC_STRUCT_MEMBER(int, render_frame_id)
202
[email protected]418da612011-07-21 19:01:52203 // True if |frame_id| is the main frame of a RenderView.
204 IPC_STRUCT_MEMBER(bool, is_main_frame)
205
[email protected]79a70282014-03-03 21:29:35206 // True if |parent_render_frame_id| is the main frame of a RenderView.
[email protected]91043a8232011-11-04 16:41:19207 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
208
209 // Identifies the parent frame of the frame that sent the request.
210 // -1 if unknown / invalid.
[email protected]79a70282014-03-03 21:29:35211 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
[email protected]91043a8232011-11-04 16:41:19212
[email protected]2905f742011-10-13 03:51:58213 IPC_STRUCT_MEMBER(content::PageTransition, transition_type)
[email protected]4ad5d77d2011-12-03 02:00:48214
[email protected]4972fc82013-11-19 04:33:42215 // For navigations, whether this navigation should replace the current session
216 // history entry on commit.
217 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
218
[email protected]4ad5d77d2011-12-03 02:00:48219 // The following two members identify a previous request that has been
220 // created before this navigation has been transferred to a new render view.
221 // This serves the purpose of recycling the old request.
222 // Unless this refers to a transferred navigation, these values are -1 and -1.
223 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
224 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
[email protected]80744782012-05-04 01:47:00225
226 // Whether or not we should allow the URL to download.
227 IPC_STRUCT_MEMBER(bool, allow_download)
[email protected]94dc971d2011-03-05 19:08:32228IPC_STRUCT_END()
229
[email protected]dcbe3df2014-02-06 23:08:37230// Parameters for a ResourceMsg_RequestComplete
231IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
232 // The error code.
233 IPC_STRUCT_MEMBER(int, error_code)
234
235 // Was ignored by the request handler.
236 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
237
238 // A copy of the data requested exists in the cache.
239 IPC_STRUCT_MEMBER(bool, exists_in_cache)
240
241 // Serialized security info; see content/common/ssl_status_serialization.h.
242 IPC_STRUCT_MEMBER(std::string, security_info)
243
244 // Time the request completed.
245 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
[email protected]c8c567582014-02-10 12:54:57246
247 // Total amount of data received from the network.
248 IPC_STRUCT_MEMBER(int64, encoded_data_length)
[email protected]dcbe3df2014-02-06 23:08:37249IPC_STRUCT_END()
250
[email protected]94dc971d2011-03-05 19:08:32251// Resource messages sent from the browser to the renderer.
252
253// Sent when the headers are available for a resource request.
[email protected]f4653192013-09-06 19:24:05254IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
255 int /* request_id */,
256 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32257
258// Sent when cached metadata from a resource request is ready.
[email protected]f4653192013-09-06 19:24:05259IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
260 int /* request_id */,
261 std::vector<char> /* data */)
[email protected]94dc971d2011-03-05 19:08:32262
263// Sent as upload progress is being made.
[email protected]f4653192013-09-06 19:24:05264IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
265 int /* request_id */,
266 int64 /* position */,
267 int64 /* size */)
[email protected]94dc971d2011-03-05 19:08:32268
269// Sent when the request has been redirected. The receiver is expected to
270// respond with either a FollowRedirect message (if the redirect is to be
271// followed) or a CancelRequest message (if it should not be followed).
[email protected]cba24642014-08-15 20:49:59272IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
[email protected]f4653192013-09-06 19:24:05273 int /* request_id */,
[email protected]cba24642014-08-15 20:49:59274 net::RedirectInfo /* redirect_info */,
[email protected]f4653192013-09-06 19:24:05275 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32276
[email protected]f0fa1ab2012-09-18 06:28:38277// Sent to set the shared memory buffer to be used to transmit response data to
278// the renderer. Subsequent DataReceived messages refer to byte ranges in the
279// shared memory buffer. The shared memory buffer should be retained by the
280// renderer until the resource request completes.
281//
282// NOTE: The shared memory handle should already be mapped into the process
283// that receives this message.
284//
[email protected]9d9387e2013-01-12 16:55:08285// TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
286// added to help in debugging crbug/160401.
287//
[email protected]f4653192013-09-06 19:24:05288IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
289 int /* request_id */,
290 base::SharedMemoryHandle /* shm_handle */,
291 int /* shm_size */,
292 base::ProcessId /* renderer_pid */)
[email protected]f0fa1ab2012-09-18 06:28:38293
294// Sent when some data from a resource request is ready. The data offset and
295// length specify a byte range into the shared memory buffer provided by the
296// SetDataBuffer message.
[email protected]f4653192013-09-06 19:24:05297IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
298 int /* request_id */,
299 int /* data_offset */,
300 int /* data_length */,
301 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32302
303// Sent when some data from a resource request has been downloaded to
304// file. This is only called in the 'download_to_file' case and replaces
305// ResourceMsg_DataReceived in the call sequence in that case.
[email protected]f4653192013-09-06 19:24:05306IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
307 int /* request_id */,
308 int /* data_len */,
309 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32310
311// Sent when the request has been completed.
[email protected]dcbe3df2014-02-06 23:08:37312IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
[email protected]f4653192013-09-06 19:24:05313 int /* request_id */,
[email protected]dcbe3df2014-02-06 23:08:37314 ResourceMsg_RequestCompleteData)
[email protected]94dc971d2011-03-05 19:08:32315
316// Resource messages sent from the renderer to the browser.
317
318// Makes a resource request via the browser.
[email protected]5636d902014-05-13 23:19:10319IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource,
320 int /* routing_id */,
[email protected]94dc971d2011-03-05 19:08:32321 int /* request_id */,
322 ResourceHostMsg_Request)
323
324// Cancels a resource request with the ID given as the parameter.
[email protected]f4653192013-09-06 19:24:05325IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
326 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32327
[email protected]94dc971d2011-03-05 19:08:32328// Follows a redirect that occured for the resource request with the ID given
329// as the parameter.
[email protected]b97fc382014-05-14 20:06:34330IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect,
331 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32332
333// Makes a synchronous resource request via the browser.
334IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
335 int /* request_id */,
336 ResourceHostMsg_Request,
[email protected]2336ffe2011-11-24 01:23:34337 content::SyncLoadResult)
[email protected]94dc971d2011-03-05 19:08:32338
339// Sent when the renderer process is done processing a DataReceived
340// message.
[email protected]f4653192013-09-06 19:24:05341IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
342 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32343
344// Sent when the renderer has processed a DataDownloaded message.
[email protected]f4653192013-09-06 19:24:05345IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
346 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32347
348// Sent by the renderer process to acknowledge receipt of a
349// UploadProgress message.
[email protected]f4653192013-09-06 19:24:05350IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
351 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32352
353// Sent when the renderer process deletes a resource loader.
354IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
355 int /* request_id */)
[email protected]a9344092d2013-02-27 00:56:45356
357// Sent by the renderer when a resource request changes priority.
[email protected]ed038bf2014-04-07 22:02:39358IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
[email protected]f4653192013-09-06 19:24:05359 int /* request_id */,
[email protected]ed038bf2014-04-07 22:02:39360 net::RequestPriority,
361 int /* intra_priority_value */)