blob: d4a7d976ca5a5b45d5ebbdec571e85db015a11b9 [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]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]48ffdf72014-05-31 02:16:5727namespace content {
[email protected]9d8ea302012-09-25 15:04:2228struct 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 <>
[email protected]48ffdf72014-05-31 02:16:5750struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
51 typedef scoped_refptr<content::ResourceDevToolsInfo> param_type;
[email protected]9d8ea302012-09-25 15:04:2252 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 <>
[email protected]14f154a2014-03-11 16:24:4166struct ParamTraits<scoped_refptr<content::ResourceRequestBody> > {
67 typedef scoped_refptr<content::ResourceRequestBody> param_type;
[email protected]9d8ea302012-09-25 15:04:2268 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)
[email protected]0bf419d12014-05-28 01:02:2387IPC_STRUCT_TRAITS_PARENT(content::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]0bf419d12014-05-28 01:02:2399IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo)
[email protected]94dc971d2011-03-05 19:08:32100 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)
[email protected]6ee72da12014-07-22 04:39:10120 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker)
121 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker)
[email protected]94dc971d2011-03-05 19:08:32122IPC_STRUCT_TRAITS_END()
123
[email protected]94dc971d2011-03-05 19:08:32124// Parameters for a resource request.
125IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
126 // The request method: GET, POST, etc.
127 IPC_STRUCT_MEMBER(std::string, method)
128
129 // The requested URL.
130 IPC_STRUCT_MEMBER(GURL, url)
131
132 // Usually the URL of the document in the top-level window, which may be
133 // checked by the third-party cookie blocking policy. Leaving it empty may
134 // lead to undesired cookie blocking. Third-party cookie blocking can be
135 // bypassed by setting first_party_for_cookies = url, but this should ideally
136 // only be done if there really is no way to determine the correct value.
137 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
138
139 // The referrer to use (may be empty).
140 IPC_STRUCT_MEMBER(GURL, referrer)
141
[email protected]d5a50342011-12-05 21:56:52142 // The referrer policy to use.
[email protected]180ef242013-11-07 06:50:46143 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
[email protected]d5a50342011-12-05 21:56:52144
[email protected]48ed2612014-01-21 00:30:57145 // The frame's visiblity state.
146 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
147
[email protected]94dc971d2011-03-05 19:08:32148 // Additional HTTP request headers.
149 IPC_STRUCT_MEMBER(std::string, headers)
150
151 // net::URLRequest load flags (0 by default).
152 IPC_STRUCT_MEMBER(int, load_flags)
153
154 // Process ID from which this request originated, or zero if it originated
155 // in the renderer itself.
[email protected]01cb19912013-09-11 19:13:03156 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
157 // through the renderer and and this holds the pid of the plugin process.
158 // Otherwise this holds the render_process_id of the view that has the plugin.
[email protected]94dc971d2011-03-05 19:08:32159 IPC_STRUCT_MEMBER(int, origin_pid)
160
161 // What this resource load is for (main frame, sub-frame, sub-resource,
162 // object).
[email protected]6c1e05212014-07-31 00:59:40163 IPC_STRUCT_MEMBER(content::ResourceType, resource_type)
[email protected]94dc971d2011-03-05 19:08:32164
[email protected]102ab682013-02-05 19:45:32165 // The priority of this request.
[email protected]a9344092d2013-02-27 00:56:45166 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
[email protected]102ab682013-02-05 19:45:32167
[email protected]94dc971d2011-03-05 19:08:32168 // Used by plugin->browser requests to get the correct net::URLRequestContext.
169 IPC_STRUCT_MEMBER(uint32, request_context)
170
171 // Indicates which frame (or worker context) the request is being loaded into,
[email protected]10f110fa2014-06-15 23:32:46172 // or kAppCacheNoHostId.
[email protected]94dc971d2011-03-05 19:08:32173 IPC_STRUCT_MEMBER(int, appcache_host_id)
174
[email protected]c4c091f2014-03-07 13:06:13175 // Indicates which frame (or worker context) the request is being loaded into,
176 // or kInvalidServiceWorkerProviderId.
177 IPC_STRUCT_MEMBER(int, service_worker_provider_id)
178
[email protected]e3e402c2012-08-21 13:57:42179 // Optional resource request body (may be null).
[email protected]14f154a2014-03-11 16:24:41180 IPC_STRUCT_MEMBER(scoped_refptr<content::ResourceRequestBody>,
[email protected]e3e402c2012-08-21 13:57:42181 request_body)
[email protected]94dc971d2011-03-05 19:08:32182
183 IPC_STRUCT_MEMBER(bool, download_to_file)
184
185 // True if the request was user initiated.
186 IPC_STRUCT_MEMBER(bool, has_user_gesture)
[email protected]418da612011-07-21 19:01:52187
[email protected]3821f7a2014-08-13 16:40:08188 // True if load timing data should be collected for request.
189 IPC_STRUCT_MEMBER(bool, enable_load_timing)
190
[email protected]60eca4eb2013-12-06 00:02:16191 // The routing id of the RenderFrame.
192 IPC_STRUCT_MEMBER(int, render_frame_id)
193
[email protected]418da612011-07-21 19:01:52194 // True if |frame_id| is the main frame of a RenderView.
195 IPC_STRUCT_MEMBER(bool, is_main_frame)
196
[email protected]79a70282014-03-03 21:29:35197 // True if |parent_render_frame_id| is the main frame of a RenderView.
[email protected]91043a8232011-11-04 16:41:19198 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
199
200 // Identifies the parent frame of the frame that sent the request.
201 // -1 if unknown / invalid.
[email protected]79a70282014-03-03 21:29:35202 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
[email protected]91043a8232011-11-04 16:41:19203
[email protected]2905f742011-10-13 03:51:58204 IPC_STRUCT_MEMBER(content::PageTransition, transition_type)
[email protected]4ad5d77d2011-12-03 02:00:48205
[email protected]4972fc82013-11-19 04:33:42206 // For navigations, whether this navigation should replace the current session
207 // history entry on commit.
208 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
209
[email protected]4ad5d77d2011-12-03 02:00:48210 // The following two members identify a previous request that has been
211 // created before this navigation has been transferred to a new render view.
212 // This serves the purpose of recycling the old request.
213 // Unless this refers to a transferred navigation, these values are -1 and -1.
214 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
215 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
[email protected]80744782012-05-04 01:47:00216
217 // Whether or not we should allow the URL to download.
218 IPC_STRUCT_MEMBER(bool, allow_download)
[email protected]94dc971d2011-03-05 19:08:32219IPC_STRUCT_END()
220
[email protected]dcbe3df2014-02-06 23:08:37221// Parameters for a ResourceMsg_RequestComplete
222IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
223 // The error code.
224 IPC_STRUCT_MEMBER(int, error_code)
225
226 // Was ignored by the request handler.
227 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
228
229 // A copy of the data requested exists in the cache.
230 IPC_STRUCT_MEMBER(bool, exists_in_cache)
231
232 // Serialized security info; see content/common/ssl_status_serialization.h.
233 IPC_STRUCT_MEMBER(std::string, security_info)
234
235 // Time the request completed.
236 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
[email protected]c8c567582014-02-10 12:54:57237
238 // Total amount of data received from the network.
239 IPC_STRUCT_MEMBER(int64, encoded_data_length)
[email protected]dcbe3df2014-02-06 23:08:37240IPC_STRUCT_END()
241
[email protected]94dc971d2011-03-05 19:08:32242// Resource messages sent from the browser to the renderer.
243
244// Sent when the headers are available for a resource request.
[email protected]f4653192013-09-06 19:24:05245IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
246 int /* request_id */,
247 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32248
249// Sent when cached metadata from a resource request is ready.
[email protected]f4653192013-09-06 19:24:05250IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
251 int /* request_id */,
252 std::vector<char> /* data */)
[email protected]94dc971d2011-03-05 19:08:32253
254// Sent as upload progress is being made.
[email protected]f4653192013-09-06 19:24:05255IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
256 int /* request_id */,
257 int64 /* position */,
258 int64 /* size */)
[email protected]94dc971d2011-03-05 19:08:32259
260// Sent when the request has been redirected. The receiver is expected to
261// respond with either a FollowRedirect message (if the redirect is to be
262// followed) or a CancelRequest message (if it should not be followed).
[email protected]b97fc382014-05-14 20:06:34263IPC_MESSAGE_CONTROL4(ResourceMsg_ReceivedRedirect,
[email protected]f4653192013-09-06 19:24:05264 int /* request_id */,
265 GURL /* new_url */,
[email protected]b97fc382014-05-14 20:06:34266 GURL /* new_first_party_for_cookies */,
[email protected]f4653192013-09-06 19:24:05267 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32268
[email protected]f0fa1ab2012-09-18 06:28:38269// Sent to set the shared memory buffer to be used to transmit response data to
270// the renderer. Subsequent DataReceived messages refer to byte ranges in the
271// shared memory buffer. The shared memory buffer should be retained by the
272// renderer until the resource request completes.
273//
274// NOTE: The shared memory handle should already be mapped into the process
275// that receives this message.
276//
[email protected]9d9387e2013-01-12 16:55:08277// TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
278// added to help in debugging crbug/160401.
279//
[email protected]f4653192013-09-06 19:24:05280IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
281 int /* request_id */,
282 base::SharedMemoryHandle /* shm_handle */,
283 int /* shm_size */,
284 base::ProcessId /* renderer_pid */)
[email protected]f0fa1ab2012-09-18 06:28:38285
286// Sent when some data from a resource request is ready. The data offset and
287// length specify a byte range into the shared memory buffer provided by the
288// SetDataBuffer message.
[email protected]f4653192013-09-06 19:24:05289IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
290 int /* request_id */,
291 int /* data_offset */,
292 int /* data_length */,
293 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32294
295// Sent when some data from a resource request has been downloaded to
296// file. This is only called in the 'download_to_file' case and replaces
297// ResourceMsg_DataReceived in the call sequence in that case.
[email protected]f4653192013-09-06 19:24:05298IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
299 int /* request_id */,
300 int /* data_len */,
301 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32302
303// Sent when the request has been completed.
[email protected]dcbe3df2014-02-06 23:08:37304IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
[email protected]f4653192013-09-06 19:24:05305 int /* request_id */,
[email protected]dcbe3df2014-02-06 23:08:37306 ResourceMsg_RequestCompleteData)
[email protected]94dc971d2011-03-05 19:08:32307
308// Resource messages sent from the renderer to the browser.
309
310// Makes a resource request via the browser.
[email protected]5636d902014-05-13 23:19:10311IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource,
312 int /* routing_id */,
[email protected]94dc971d2011-03-05 19:08:32313 int /* request_id */,
314 ResourceHostMsg_Request)
315
316// Cancels a resource request with the ID given as the parameter.
[email protected]f4653192013-09-06 19:24:05317IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
318 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32319
[email protected]94dc971d2011-03-05 19:08:32320// Follows a redirect that occured for the resource request with the ID given
321// as the parameter.
[email protected]b97fc382014-05-14 20:06:34322IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect,
323 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32324
325// Makes a synchronous resource request via the browser.
326IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
327 int /* request_id */,
328 ResourceHostMsg_Request,
[email protected]2336ffe2011-11-24 01:23:34329 content::SyncLoadResult)
[email protected]94dc971d2011-03-05 19:08:32330
331// Sent when the renderer process is done processing a DataReceived
332// message.
[email protected]f4653192013-09-06 19:24:05333IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
334 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32335
336// Sent when the renderer has processed a DataDownloaded message.
[email protected]f4653192013-09-06 19:24:05337IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
338 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32339
340// Sent by the renderer process to acknowledge receipt of a
341// UploadProgress message.
[email protected]f4653192013-09-06 19:24:05342IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
343 int /* request_id */)
[email protected]94dc971d2011-03-05 19:08:32344
345// Sent when the renderer process deletes a resource loader.
346IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
347 int /* request_id */)
[email protected]a9344092d2013-02-27 00:56:45348
349// Sent by the renderer when a resource request changes priority.
[email protected]ed038bf2014-04-07 22:02:39350IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
[email protected]f4653192013-09-06 19:24:05351 int /* request_id */,
[email protected]ed038bf2014-04-07 22:02:39352 net::RequestPriority,
353 int /* intra_priority_value */)