blob: d1ae748acdd3609b5d900854f2e7982371d7ab56 [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)
126 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker)
shimazu403d2d92014-09-19 01:25:16127 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_start)
128 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_ready)
129 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_end)
[email protected]94dc971d2011-03-05 19:08:32130IPC_STRUCT_TRAITS_END()
131
[email protected]cba24642014-08-15 20:49:59132IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo)
133 IPC_STRUCT_TRAITS_MEMBER(status_code)
134 IPC_STRUCT_TRAITS_MEMBER(new_method)
135 IPC_STRUCT_TRAITS_MEMBER(new_url)
136 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies)
137 IPC_STRUCT_TRAITS_MEMBER(new_referrer)
138IPC_STRUCT_TRAITS_END()
139
[email protected]94dc971d2011-03-05 19:08:32140// Parameters for a resource request.
141IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
142 // The request method: GET, POST, etc.
143 IPC_STRUCT_MEMBER(std::string, method)
144
145 // The requested URL.
146 IPC_STRUCT_MEMBER(GURL, url)
147
148 // Usually the URL of the document in the top-level window, which may be
149 // checked by the third-party cookie blocking policy. Leaving it empty may
150 // lead to undesired cookie blocking. Third-party cookie blocking can be
151 // bypassed by setting first_party_for_cookies = url, but this should ideally
152 // only be done if there really is no way to determine the correct value.
153 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
154
155 // The referrer to use (may be empty).
156 IPC_STRUCT_MEMBER(GURL, referrer)
157
[email protected]d5a50342011-12-05 21:56:52158 // The referrer policy to use.
[email protected]180ef242013-11-07 06:50:46159 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
[email protected]d5a50342011-12-05 21:56:52160
[email protected]48ed2612014-01-21 00:30:57161 // The frame's visiblity state.
162 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
163
[email protected]94dc971d2011-03-05 19:08:32164 // Additional HTTP request headers.
165 IPC_STRUCT_MEMBER(std::string, headers)
166
167 // net::URLRequest load flags (0 by default).
168 IPC_STRUCT_MEMBER(int, load_flags)
169
170 // Process ID from which this request originated, or zero if it originated
171 // in the renderer itself.
[email protected]01cb19912013-09-11 19:13:03172 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
173 // through the renderer and and this holds the pid of the plugin process.
174 // Otherwise this holds the render_process_id of the view that has the plugin.
[email protected]94dc971d2011-03-05 19:08:32175 IPC_STRUCT_MEMBER(int, origin_pid)
176
177 // What this resource load is for (main frame, sub-frame, sub-resource,
178 // object).
[email protected]6c1e05212014-07-31 00:59:40179 IPC_STRUCT_MEMBER(content::ResourceType, resource_type)
[email protected]94dc971d2011-03-05 19:08:32180
[email protected]102ab682013-02-05 19:45:32181 // The priority of this request.
[email protected]a9344092d2013-02-27 00:56:45182 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
[email protected]102ab682013-02-05 19:45:32183
[email protected]94dc971d2011-03-05 19:08:32184 // Used by plugin->browser requests to get the correct net::URLRequestContext.
185 IPC_STRUCT_MEMBER(uint32, request_context)
186
187 // Indicates which frame (or worker context) the request is being loaded into,
[email protected]10f110fa2014-06-15 23:32:46188 // or kAppCacheNoHostId.
[email protected]94dc971d2011-03-05 19:08:32189 IPC_STRUCT_MEMBER(int, appcache_host_id)
190
[email protected]c4c091f2014-03-07 13:06:13191 // Indicates which frame (or worker context) the request is being loaded into,
192 // or kInvalidServiceWorkerProviderId.
193 IPC_STRUCT_MEMBER(int, service_worker_provider_id)
194
horo258fc4232014-09-05 10:15:31195 // True if the request should not be handled by the ServiceWorker.
196 IPC_STRUCT_MEMBER(bool, skip_service_worker)
197
horo7e40ec72014-09-30 09:23:46198 // The request mode passed to the ServiceWorker.
199 IPC_STRUCT_MEMBER(content::FetchRequestMode, fetch_request_mode)
200
[email protected]e3e402c2012-08-21 13:57:42201 // Optional resource request body (may be null).
[email protected]14f154a2014-03-11 16:24:41202 IPC_STRUCT_MEMBER(scoped_refptr<content::ResourceRequestBody>,
[email protected]e3e402c2012-08-21 13:57:42203 request_body)
[email protected]94dc971d2011-03-05 19:08:32204
205 IPC_STRUCT_MEMBER(bool, download_to_file)
206
207 // True if the request was user initiated.
208 IPC_STRUCT_MEMBER(bool, has_user_gesture)
[email protected]418da612011-07-21 19:01:52209
[email protected]3821f7a2014-08-13 16:40:08210 // True if load timing data should be collected for request.
211 IPC_STRUCT_MEMBER(bool, enable_load_timing)
212
[email protected]60eca4eb2013-12-06 00:02:16213 // The routing id of the RenderFrame.
214 IPC_STRUCT_MEMBER(int, render_frame_id)
215
[email protected]418da612011-07-21 19:01:52216 // True if |frame_id| is the main frame of a RenderView.
217 IPC_STRUCT_MEMBER(bool, is_main_frame)
218
[email protected]79a70282014-03-03 21:29:35219 // True if |parent_render_frame_id| is the main frame of a RenderView.
[email protected]91043a8232011-11-04 16:41:19220 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
221
222 // Identifies the parent frame of the frame that sent the request.
223 // -1 if unknown / invalid.
[email protected]79a70282014-03-03 21:29:35224 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
[email protected]91043a8232011-11-04 16:41:19225
Sylvain Defresnec6ccc77d2014-09-19 10:19:35226 IPC_STRUCT_MEMBER(ui::PageTransition, transition_type)
[email protected]4ad5d77d2011-12-03 02:00:48227
[email protected]4972fc82013-11-19 04:33:42228 // For navigations, whether this navigation should replace the current session
229 // history entry on commit.
230 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
231
[email protected]4ad5d77d2011-12-03 02:00:48232 // The following two members identify a previous request that has been
233 // created before this navigation has been transferred to a new render view.
234 // This serves the purpose of recycling the old request.
235 // Unless this refers to a transferred navigation, these values are -1 and -1.
236 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
237 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
[email protected]80744782012-05-04 01:47:00238
239 // Whether or not we should allow the URL to download.
240 IPC_STRUCT_MEMBER(bool, allow_download)
[email protected]94dc971d2011-03-05 19:08:32241IPC_STRUCT_END()
242
[email protected]dcbe3df2014-02-06 23:08:37243// Parameters for a ResourceMsg_RequestComplete
244IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
245 // The error code.
246 IPC_STRUCT_MEMBER(int, error_code)
247
248 // Was ignored by the request handler.
249 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
250
251 // A copy of the data requested exists in the cache.
252 IPC_STRUCT_MEMBER(bool, exists_in_cache)
253
254 // Serialized security info; see content/common/ssl_status_serialization.h.
255 IPC_STRUCT_MEMBER(std::string, security_info)
256
257 // Time the request completed.
258 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
[email protected]c8c567582014-02-10 12:54:57259
260 // Total amount of data received from the network.
261 IPC_STRUCT_MEMBER(int64, encoded_data_length)
[email protected]dcbe3df2014-02-06 23:08:37262IPC_STRUCT_END()
263
[email protected]94dc971d2011-03-05 19:08:32264// Resource messages sent from the browser to the renderer.
265
266// Sent when the headers are available for a resource request.
[email protected]f4653192013-09-06 19:24:05267IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
268 int /* request_id */,
269 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32270
271// Sent when cached metadata from a resource request is ready.
[email protected]f4653192013-09-06 19:24:05272IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
273 int /* request_id */,
274 std::vector<char> /* data */)
[email protected]94dc971d2011-03-05 19:08:32275
276// Sent as upload progress is being made.
[email protected]f4653192013-09-06 19:24:05277IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
278 int /* request_id */,
279 int64 /* position */,
280 int64 /* size */)
[email protected]94dc971d2011-03-05 19:08:32281
282// Sent when the request has been redirected. The receiver is expected to
283// respond with either a FollowRedirect message (if the redirect is to be
284// followed) or a CancelRequest message (if it should not be followed).
[email protected]cba24642014-08-15 20:49:59285IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
[email protected]f4653192013-09-06 19:24:05286 int /* request_id */,
[email protected]cba24642014-08-15 20:49:59287 net::RedirectInfo /* redirect_info */,
[email protected]f4653192013-09-06 19:24:05288 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32289
[email protected]f0fa1ab2012-09-18 06:28:38290// Sent to set the shared memory buffer to be used to transmit response data to
291// the renderer. Subsequent DataReceived messages refer to byte ranges in the
292// shared memory buffer. The shared memory buffer should be retained by the
293// renderer until the resource request completes.
294//
295// NOTE: The shared memory handle should already be mapped into the process
296// that receives this message.
297//
[email protected]9d9387e2013-01-12 16:55:08298// TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
299// added to help in debugging crbug/160401.
300//
[email protected]f4653192013-09-06 19:24:05301IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
302 int /* request_id */,
303 base::SharedMemoryHandle /* shm_handle */,
304 int /* shm_size */,
305 base::ProcessId /* renderer_pid */)
[email protected]f0fa1ab2012-09-18 06:28:38306
307// Sent when some data from a resource request is ready. The data offset and
308// length specify a byte range into the shared memory buffer provided by the
309// SetDataBuffer message.
[email protected]f4653192013-09-06 19:24:05310IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
311 int /* request_id */,
312 int /* data_offset */,
313 int /* data_length */,
314 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32315
316// Sent when some data from a resource request has been downloaded to
317// file. This is only called in the 'download_to_file' case and replaces
318// ResourceMsg_DataReceived in the call sequence in that case.
[email protected]f4653192013-09-06 19:24:05319IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
320 int /* request_id */,
321 int /* data_len */,
322 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32323
324// Sent when the request has been completed.
[email protected]dcbe3df2014-02-06 23:08:37325IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
[email protected]f4653192013-09-06 19:24:05326 int /* request_id */,
[email protected]dcbe3df2014-02-06 23:08:37327 ResourceMsg_RequestCompleteData)
[email protected]94dc971d2011-03-05 19:08:32328
329// Resource messages sent from the renderer to the browser.
330
331// Makes a resource request via the browser.
[email protected]5636d902014-05-13 23:19:10332IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource,
333 int /* routing_id */,
[email protected]94dc971d2011-03-05 19:08:32334 int /* request_id */,
335 ResourceHostMsg_Request)
336
337// Cancels a resource request with the ID given as the parameter.
[email protected]f4653192013-09-06 19:24:05338IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
339 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32340
[email protected]94dc971d2011-03-05 19:08:32341// Follows a redirect that occured for the resource request with the ID given
342// as the parameter.
[email protected]b97fc382014-05-14 20:06:34343IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect,
344 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32345
346// Makes a synchronous resource request via the browser.
347IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
348 int /* request_id */,
349 ResourceHostMsg_Request,
[email protected]2336ffe2011-11-24 01:23:34350 content::SyncLoadResult)
[email protected]94dc971d2011-03-05 19:08:32351
352// Sent when the renderer process is done processing a DataReceived
353// message.
[email protected]f4653192013-09-06 19:24:05354IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
355 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32356
357// Sent when the renderer has processed a DataDownloaded message.
[email protected]f4653192013-09-06 19:24:05358IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
359 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32360
361// Sent by the renderer process to acknowledge receipt of a
362// UploadProgress message.
[email protected]f4653192013-09-06 19:24:05363IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
364 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32365
366// Sent when the renderer process deletes a resource loader.
367IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
368 int /* request_id */)
[email protected]a9344092d2013-02-27 00:56:45369
370// Sent by the renderer when a resource request changes priority.
[email protected]ed038bf2014-04-07 22:02:39371IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
[email protected]f4653192013-09-06 19:24:05372 int /* request_id */,
[email protected]ed038bf2014-04-07 22:02:39373 net::RequestPriority,
374 int /* intra_priority_value */)