blob: 4afd3b20cdd6feafaa193d1ca19d67287b867cd9 [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"
horo7e40ec72014-09-30 09:23:4614#include "content/common/service_worker/service_worker_types.h"
[email protected]19a5c7442011-10-21 20:00:4115#include "content/public/common/common_param_traits.h"
[email protected]2336ffe2011-11-24 01:23:3416#include "content/public/common/resource_response.h"
[email protected]94dc971d2011-03-05 19:08:3217#include "ipc/ipc_message_macros.h"
[email protected]a9344092d2013-02-27 00:56:4518#include "net/base/request_priority.h"
[email protected]92a98df92013-06-06 02:47:4219#include "net/http/http_response_info.h"
[email protected]cba24642014-08-15 20:49:5920#include "net/url_request/redirect_info.h"
[email protected]94dc971d2011-03-05 19:08:3221
[email protected]9d8ea302012-09-25 15:04:2222#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
23#define CONTENT_COMMON_RESOURCE_MESSAGES_H_
24
[email protected]ec298802013-03-27 16:45:0725namespace net {
26struct LoadTimingInfo;
27}
28
[email protected]48ffdf72014-05-31 02:16:5729namespace content {
[email protected]9d8ea302012-09-25 15:04:2230struct ResourceDevToolsInfo;
[email protected]9d8ea302012-09-25 15:04:2231}
32
33namespace IPC {
34
35template <>
36struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
37 typedef scoped_refptr<net::HttpResponseHeaders> param_type;
38 static void Write(Message* m, const param_type& p);
39 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
40 static void Log(const param_type& p, std::string* l);
41};
42
43template <>
[email protected]cd501a72014-08-22 19:58:3144struct CONTENT_EXPORT ParamTraits<storage::DataElement> {
45 typedef storage::DataElement param_type;
[email protected]9d8ea302012-09-25 15:04:2246 static void Write(Message* m, const param_type& p);
47 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
48 static void Log(const param_type& p, std::string* l);
49};
50
51template <>
[email protected]48ffdf72014-05-31 02:16:5752struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
53 typedef scoped_refptr<content::ResourceDevToolsInfo> param_type;
[email protected]9d8ea302012-09-25 15:04:2254 static void Write(Message* m, const param_type& p);
55 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
56 static void Log(const param_type& p, std::string* l);
57};
58
59template <>
[email protected]ec298802013-03-27 16:45:0760struct ParamTraits<net::LoadTimingInfo> {
61 typedef net::LoadTimingInfo param_type;
[email protected]9d8ea302012-09-25 15:04:2262 static void Write(Message* m, const param_type& p);
63 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
64 static void Log(const param_type& p, std::string* l);
65};
66
67template <>
[email protected]14f154a2014-03-11 16:24:4168struct ParamTraits<scoped_refptr<content::ResourceRequestBody> > {
69 typedef scoped_refptr<content::ResourceRequestBody> param_type;
[email protected]9d8ea302012-09-25 15:04:2270 static void Write(Message* m, const param_type& p);
71 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
72 static void Log(const param_type& p, std::string* l);
73};
74
75} // namespace IPC
76
77#endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
78
79
[email protected]94dc971d2011-03-05 19:08:3280#define IPC_MESSAGE_START ResourceMsgStart
[email protected]03ff5e52011-09-30 00:28:1481#undef IPC_MESSAGE_EXPORT
82#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
[email protected]94dc971d2011-03-05 19:08:3283
[email protected]92a98df92013-06-06 02:47:4284IPC_ENUM_TRAITS_MAX_VALUE( \
85 net::HttpResponseInfo::ConnectionInfo, \
86 net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
87
horo7e40ec72014-09-30 09:23:4688IPC_ENUM_TRAITS_MAX_VALUE(content::FetchRequestMode,
89 content::FETCH_REQUEST_MODE_LAST)
90
[email protected]2336ffe2011-11-24 01:23:3491IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
[email protected]0bf419d12014-05-28 01:02:2392IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo)
[email protected]d43d2e112012-08-07 01:10:1993 IPC_STRUCT_TRAITS_MEMBER(request_start)
94 IPC_STRUCT_TRAITS_MEMBER(response_start)
[email protected]2336ffe2011-11-24 01:23:3495IPC_STRUCT_TRAITS_END()
96
97IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
98 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
davidben015fd322014-09-03 23:31:3399 IPC_STRUCT_TRAITS_MEMBER(error_code)
[email protected]2336ffe2011-11-24 01:23:34100 IPC_STRUCT_TRAITS_MEMBER(final_url)
101 IPC_STRUCT_TRAITS_MEMBER(data)
102IPC_STRUCT_TRAITS_END()
103
[email protected]0bf419d12014-05-28 01:02:23104IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo)
[email protected]94dc971d2011-03-05 19:08:32105 IPC_STRUCT_TRAITS_MEMBER(request_time)
106 IPC_STRUCT_TRAITS_MEMBER(response_time)
107 IPC_STRUCT_TRAITS_MEMBER(headers)
108 IPC_STRUCT_TRAITS_MEMBER(mime_type)
109 IPC_STRUCT_TRAITS_MEMBER(charset)
110 IPC_STRUCT_TRAITS_MEMBER(security_info)
111 IPC_STRUCT_TRAITS_MEMBER(content_length)
[email protected]dfd682172011-04-13 19:57:25112 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
[email protected]94dc971d2011-03-05 19:08:32113 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
114 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
[email protected]94dc971d2011-03-05 19:08:32115 IPC_STRUCT_TRAITS_MEMBER(load_timing)
116 IPC_STRUCT_TRAITS_MEMBER(devtools_info)
117 IPC_STRUCT_TRAITS_MEMBER(download_file_path)
118 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
119 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
120 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
[email protected]92a98df92013-06-06 02:47:42121 IPC_STRUCT_TRAITS_MEMBER(connection_info)
[email protected]94dc971d2011-03-05 19:08:32122 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
[email protected]b9fd01ba2012-02-28 01:50:40123 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
[email protected]94dc971d2011-03-05 19:08:32124 IPC_STRUCT_TRAITS_MEMBER(socket_address)
[email protected]6ee72da12014-07-22 04:39:10125 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker)
horo00320572014-10-01 07:56:28126 IPC_STRUCT_TRAITS_MEMBER(was_fallback_required_by_service_worker)
[email protected]6ee72da12014-07-22 04:39:10127 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker)
shimazu403d2d92014-09-19 01:25:16128 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_start)
129 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_ready)
130 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_end)
[email protected]94dc971d2011-03-05 19:08:32131IPC_STRUCT_TRAITS_END()
132
[email protected]cba24642014-08-15 20:49:59133IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo)
134 IPC_STRUCT_TRAITS_MEMBER(status_code)
135 IPC_STRUCT_TRAITS_MEMBER(new_method)
136 IPC_STRUCT_TRAITS_MEMBER(new_url)
137 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies)
138 IPC_STRUCT_TRAITS_MEMBER(new_referrer)
139IPC_STRUCT_TRAITS_END()
140
[email protected]94dc971d2011-03-05 19:08:32141// Parameters for a resource request.
142IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
143 // The request method: GET, POST, etc.
144 IPC_STRUCT_MEMBER(std::string, method)
145
146 // The requested URL.
147 IPC_STRUCT_MEMBER(GURL, url)
148
149 // Usually the URL of the document in the top-level window, which may be
150 // checked by the third-party cookie blocking policy. Leaving it empty may
151 // lead to undesired cookie blocking. Third-party cookie blocking can be
152 // bypassed by setting first_party_for_cookies = url, but this should ideally
153 // only be done if there really is no way to determine the correct value.
154 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
155
156 // The referrer to use (may be empty).
157 IPC_STRUCT_MEMBER(GURL, referrer)
158
[email protected]d5a50342011-12-05 21:56:52159 // The referrer policy to use.
[email protected]180ef242013-11-07 06:50:46160 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
[email protected]d5a50342011-12-05 21:56:52161
[email protected]48ed2612014-01-21 00:30:57162 // The frame's visiblity state.
163 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
164
[email protected]94dc971d2011-03-05 19:08:32165 // Additional HTTP request headers.
166 IPC_STRUCT_MEMBER(std::string, headers)
167
168 // net::URLRequest load flags (0 by default).
169 IPC_STRUCT_MEMBER(int, load_flags)
170
171 // Process ID from which this request originated, or zero if it originated
172 // in the renderer itself.
[email protected]01cb19912013-09-11 19:13:03173 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
174 // through the renderer and and this holds the pid of the plugin process.
175 // Otherwise this holds the render_process_id of the view that has the plugin.
[email protected]94dc971d2011-03-05 19:08:32176 IPC_STRUCT_MEMBER(int, origin_pid)
177
178 // What this resource load is for (main frame, sub-frame, sub-resource,
179 // object).
[email protected]6c1e05212014-07-31 00:59:40180 IPC_STRUCT_MEMBER(content::ResourceType, resource_type)
[email protected]94dc971d2011-03-05 19:08:32181
[email protected]102ab682013-02-05 19:45:32182 // The priority of this request.
[email protected]a9344092d2013-02-27 00:56:45183 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
[email protected]102ab682013-02-05 19:45:32184
[email protected]94dc971d2011-03-05 19:08:32185 // Used by plugin->browser requests to get the correct net::URLRequestContext.
186 IPC_STRUCT_MEMBER(uint32, request_context)
187
188 // Indicates which frame (or worker context) the request is being loaded into,
[email protected]10f110fa2014-06-15 23:32:46189 // or kAppCacheNoHostId.
[email protected]94dc971d2011-03-05 19:08:32190 IPC_STRUCT_MEMBER(int, appcache_host_id)
191
[email protected]c4c091f2014-03-07 13:06:13192 // Indicates which frame (or worker context) the request is being loaded into,
193 // or kInvalidServiceWorkerProviderId.
194 IPC_STRUCT_MEMBER(int, service_worker_provider_id)
195
horo258fc4232014-09-05 10:15:31196 // True if the request should not be handled by the ServiceWorker.
197 IPC_STRUCT_MEMBER(bool, skip_service_worker)
198
horo7e40ec72014-09-30 09:23:46199 // The request mode passed to the ServiceWorker.
200 IPC_STRUCT_MEMBER(content::FetchRequestMode, fetch_request_mode)
201
[email protected]e3e402c2012-08-21 13:57:42202 // Optional resource request body (may be null).
[email protected]14f154a2014-03-11 16:24:41203 IPC_STRUCT_MEMBER(scoped_refptr<content::ResourceRequestBody>,
[email protected]e3e402c2012-08-21 13:57:42204 request_body)
[email protected]94dc971d2011-03-05 19:08:32205
206 IPC_STRUCT_MEMBER(bool, download_to_file)
207
208 // True if the request was user initiated.
209 IPC_STRUCT_MEMBER(bool, has_user_gesture)
[email protected]418da612011-07-21 19:01:52210
[email protected]3821f7a2014-08-13 16:40:08211 // True if load timing data should be collected for request.
212 IPC_STRUCT_MEMBER(bool, enable_load_timing)
213
[email protected]60eca4eb2013-12-06 00:02:16214 // The routing id of the RenderFrame.
215 IPC_STRUCT_MEMBER(int, render_frame_id)
216
[email protected]418da612011-07-21 19:01:52217 // True if |frame_id| is the main frame of a RenderView.
218 IPC_STRUCT_MEMBER(bool, is_main_frame)
219
[email protected]79a70282014-03-03 21:29:35220 // True if |parent_render_frame_id| is the main frame of a RenderView.
[email protected]91043a8232011-11-04 16:41:19221 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
222
223 // Identifies the parent frame of the frame that sent the request.
224 // -1 if unknown / invalid.
[email protected]79a70282014-03-03 21:29:35225 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
[email protected]91043a8232011-11-04 16:41:19226
Sylvain Defresnec6ccc77d2014-09-19 10:19:35227 IPC_STRUCT_MEMBER(ui::PageTransition, transition_type)
[email protected]4ad5d77d2011-12-03 02:00:48228
[email protected]4972fc82013-11-19 04:33:42229 // For navigations, whether this navigation should replace the current session
230 // history entry on commit.
231 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
232
[email protected]4ad5d77d2011-12-03 02:00:48233 // The following two members identify a previous request that has been
234 // created before this navigation has been transferred to a new render view.
235 // This serves the purpose of recycling the old request.
236 // Unless this refers to a transferred navigation, these values are -1 and -1.
237 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
238 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
[email protected]80744782012-05-04 01:47:00239
240 // Whether or not we should allow the URL to download.
241 IPC_STRUCT_MEMBER(bool, allow_download)
[email protected]94dc971d2011-03-05 19:08:32242IPC_STRUCT_END()
243
[email protected]dcbe3df2014-02-06 23:08:37244// Parameters for a ResourceMsg_RequestComplete
245IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
246 // The error code.
247 IPC_STRUCT_MEMBER(int, error_code)
248
249 // Was ignored by the request handler.
250 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
251
252 // A copy of the data requested exists in the cache.
253 IPC_STRUCT_MEMBER(bool, exists_in_cache)
254
255 // Serialized security info; see content/common/ssl_status_serialization.h.
256 IPC_STRUCT_MEMBER(std::string, security_info)
257
258 // Time the request completed.
259 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
[email protected]c8c567582014-02-10 12:54:57260
261 // Total amount of data received from the network.
262 IPC_STRUCT_MEMBER(int64, encoded_data_length)
[email protected]dcbe3df2014-02-06 23:08:37263IPC_STRUCT_END()
264
[email protected]94dc971d2011-03-05 19:08:32265// Resource messages sent from the browser to the renderer.
266
267// Sent when the headers are available for a resource request.
[email protected]f4653192013-09-06 19:24:05268IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
269 int /* request_id */,
270 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32271
272// Sent when cached metadata from a resource request is ready.
[email protected]f4653192013-09-06 19:24:05273IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
274 int /* request_id */,
275 std::vector<char> /* data */)
[email protected]94dc971d2011-03-05 19:08:32276
277// Sent as upload progress is being made.
[email protected]f4653192013-09-06 19:24:05278IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
279 int /* request_id */,
280 int64 /* position */,
281 int64 /* size */)
[email protected]94dc971d2011-03-05 19:08:32282
283// Sent when the request has been redirected. The receiver is expected to
284// respond with either a FollowRedirect message (if the redirect is to be
285// followed) or a CancelRequest message (if it should not be followed).
[email protected]cba24642014-08-15 20:49:59286IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
[email protected]f4653192013-09-06 19:24:05287 int /* request_id */,
[email protected]cba24642014-08-15 20:49:59288 net::RedirectInfo /* redirect_info */,
[email protected]f4653192013-09-06 19:24:05289 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32290
[email protected]f0fa1ab2012-09-18 06:28:38291// Sent to set the shared memory buffer to be used to transmit response data to
292// the renderer. Subsequent DataReceived messages refer to byte ranges in the
293// shared memory buffer. The shared memory buffer should be retained by the
294// renderer until the resource request completes.
295//
296// NOTE: The shared memory handle should already be mapped into the process
297// that receives this message.
298//
[email protected]9d9387e2013-01-12 16:55:08299// TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
300// added to help in debugging crbug/160401.
301//
[email protected]f4653192013-09-06 19:24:05302IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
303 int /* request_id */,
304 base::SharedMemoryHandle /* shm_handle */,
305 int /* shm_size */,
306 base::ProcessId /* renderer_pid */)
[email protected]f0fa1ab2012-09-18 06:28:38307
308// Sent when some data from a resource request is ready. The data offset and
309// length specify a byte range into the shared memory buffer provided by the
310// SetDataBuffer message.
[email protected]f4653192013-09-06 19:24:05311IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
312 int /* request_id */,
313 int /* data_offset */,
314 int /* data_length */,
315 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32316
317// Sent when some data from a resource request has been downloaded to
318// file. This is only called in the 'download_to_file' case and replaces
319// ResourceMsg_DataReceived in the call sequence in that case.
[email protected]f4653192013-09-06 19:24:05320IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
321 int /* request_id */,
322 int /* data_len */,
323 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32324
325// Sent when the request has been completed.
[email protected]dcbe3df2014-02-06 23:08:37326IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
[email protected]f4653192013-09-06 19:24:05327 int /* request_id */,
[email protected]dcbe3df2014-02-06 23:08:37328 ResourceMsg_RequestCompleteData)
[email protected]94dc971d2011-03-05 19:08:32329
330// Resource messages sent from the renderer to the browser.
331
332// Makes a resource request via the browser.
[email protected]5636d902014-05-13 23:19:10333IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource,
334 int /* routing_id */,
[email protected]94dc971d2011-03-05 19:08:32335 int /* request_id */,
336 ResourceHostMsg_Request)
337
338// Cancels a resource request with the ID given as the parameter.
[email protected]f4653192013-09-06 19:24:05339IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
340 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32341
[email protected]94dc971d2011-03-05 19:08:32342// Follows a redirect that occured for the resource request with the ID given
343// as the parameter.
[email protected]b97fc382014-05-14 20:06:34344IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect,
345 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32346
347// Makes a synchronous resource request via the browser.
348IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
349 int /* request_id */,
350 ResourceHostMsg_Request,
[email protected]2336ffe2011-11-24 01:23:34351 content::SyncLoadResult)
[email protected]94dc971d2011-03-05 19:08:32352
353// Sent when the renderer process is done processing a DataReceived
354// message.
[email protected]f4653192013-09-06 19:24:05355IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
356 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32357
358// Sent when the renderer has processed a DataDownloaded message.
[email protected]f4653192013-09-06 19:24:05359IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
360 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32361
362// Sent by the renderer process to acknowledge receipt of a
363// UploadProgress message.
[email protected]f4653192013-09-06 19:24:05364IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
365 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32366
367// Sent when the renderer process deletes a resource loader.
368IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
369 int /* request_id */)
[email protected]a9344092d2013-02-27 00:56:45370
371// Sent by the renderer when a resource request changes priority.
[email protected]ed038bf2014-04-07 22:02:39372IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
[email protected]f4653192013-09-06 19:24:05373 int /* request_id */,
[email protected]ed038bf2014-04-07 22:02:39374 net::RequestPriority,
375 int /* intra_priority_value */)