blob: 03220afa236eb37a2781c8ab2a451462fe0622f7 [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]94dc971d2011-03-05 19:08:326
[email protected]e503a122011-03-17 18:20:527// Multiply-included message file, hence no include guard.
[email protected]9d9387e2013-01-12 16:55:088#include "base/process.h"
[email protected]94dc971d2011-03-05 19:08:329#include "base/shared_memory.h"
[email protected]9d8ea302012-09-25 15:04:2210#include "content/common/content_param_traits_macros.h"
[email protected]19a5c7442011-10-21 20:00:4111#include "content/public/common/common_param_traits.h"
[email protected]2336ffe2011-11-24 01:23:3412#include "content/public/common/resource_response.h"
[email protected]94dc971d2011-03-05 19:08:3213#include "ipc/ipc_message_macros.h"
[email protected]e3e402c2012-08-21 13:57:4214#include "webkit/glue/resource_request_body.h"
[email protected]94dc971d2011-03-05 19:08:3215
[email protected]9d8ea302012-09-25 15:04:2216#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
17#define CONTENT_COMMON_RESOURCE_MESSAGES_H_
18
19namespace webkit_glue {
20struct ResourceDevToolsInfo;
21struct ResourceLoadTimingInfo;
22}
23
24namespace IPC {
25
26template <>
27struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
28 typedef scoped_refptr<net::HttpResponseHeaders> param_type;
29 static void Write(Message* m, const param_type& p);
30 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
31 static void Log(const param_type& p, std::string* l);
32};
33
34template <>
35struct CONTENT_EXPORT ParamTraits<webkit_base::DataElement> {
36 typedef webkit_base::DataElement 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 <>
43struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > {
44 typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type;
45 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 <>
51struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> {
52 typedef webkit_glue::ResourceLoadTimingInfo param_type;
53 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 <>
59struct ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> > {
60 typedef scoped_refptr<webkit_glue::ResourceRequestBody> param_type;
61 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
66} // namespace IPC
67
68#endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
69
70
[email protected]94dc971d2011-03-05 19:08:3271#define IPC_MESSAGE_START ResourceMsgStart
[email protected]03ff5e52011-09-30 00:28:1472#undef IPC_MESSAGE_EXPORT
73#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
[email protected]94dc971d2011-03-05 19:08:3274
[email protected]2336ffe2011-11-24 01:23:3475IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
76 IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo)
[email protected]2756a8e2012-09-07 18:24:2977 IPC_STRUCT_TRAITS_MEMBER(error_code)
[email protected]d43d2e112012-08-07 01:10:1978 IPC_STRUCT_TRAITS_MEMBER(request_start)
79 IPC_STRUCT_TRAITS_MEMBER(response_start)
[email protected]2336ffe2011-11-24 01:23:3480IPC_STRUCT_TRAITS_END()
81
82IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
83 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
84 IPC_STRUCT_TRAITS_MEMBER(final_url)
85 IPC_STRUCT_TRAITS_MEMBER(data)
86IPC_STRUCT_TRAITS_END()
87
[email protected]94dc971d2011-03-05 19:08:3288IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo)
89 IPC_STRUCT_TRAITS_MEMBER(request_time)
90 IPC_STRUCT_TRAITS_MEMBER(response_time)
91 IPC_STRUCT_TRAITS_MEMBER(headers)
92 IPC_STRUCT_TRAITS_MEMBER(mime_type)
93 IPC_STRUCT_TRAITS_MEMBER(charset)
94 IPC_STRUCT_TRAITS_MEMBER(security_info)
95 IPC_STRUCT_TRAITS_MEMBER(content_length)
[email protected]dfd682172011-04-13 19:57:2596 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
[email protected]94dc971d2011-03-05 19:08:3297 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
98 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
99 IPC_STRUCT_TRAITS_MEMBER(connection_id)
100 IPC_STRUCT_TRAITS_MEMBER(connection_reused)
101 IPC_STRUCT_TRAITS_MEMBER(load_timing)
102 IPC_STRUCT_TRAITS_MEMBER(devtools_info)
103 IPC_STRUCT_TRAITS_MEMBER(download_file_path)
104 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
105 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
106 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
107 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
[email protected]b9fd01ba2012-02-28 01:50:40108 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
[email protected]94dc971d2011-03-05 19:08:32109 IPC_STRUCT_TRAITS_MEMBER(socket_address)
110IPC_STRUCT_TRAITS_END()
111
[email protected]94dc971d2011-03-05 19:08:32112// Parameters for a resource request.
113IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
114 // The request method: GET, POST, etc.
115 IPC_STRUCT_MEMBER(std::string, method)
116
117 // The requested URL.
118 IPC_STRUCT_MEMBER(GURL, url)
119
120 // Usually the URL of the document in the top-level window, which may be
121 // checked by the third-party cookie blocking policy. Leaving it empty may
122 // lead to undesired cookie blocking. Third-party cookie blocking can be
123 // bypassed by setting first_party_for_cookies = url, but this should ideally
124 // only be done if there really is no way to determine the correct value.
125 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
126
127 // The referrer to use (may be empty).
128 IPC_STRUCT_MEMBER(GURL, referrer)
129
[email protected]d5a50342011-12-05 21:56:52130 // The referrer policy to use.
131 IPC_STRUCT_MEMBER(WebKit::WebReferrerPolicy, referrer_policy)
132
[email protected]94dc971d2011-03-05 19:08:32133 // Additional HTTP request headers.
134 IPC_STRUCT_MEMBER(std::string, headers)
135
136 // net::URLRequest load flags (0 by default).
137 IPC_STRUCT_MEMBER(int, load_flags)
138
139 // Process ID from which this request originated, or zero if it originated
140 // in the renderer itself.
141 IPC_STRUCT_MEMBER(int, origin_pid)
142
143 // What this resource load is for (main frame, sub-frame, sub-resource,
144 // object).
145 IPC_STRUCT_MEMBER(ResourceType::Type, resource_type)
146
147 // Used by plugin->browser requests to get the correct net::URLRequestContext.
148 IPC_STRUCT_MEMBER(uint32, request_context)
149
150 // Indicates which frame (or worker context) the request is being loaded into,
151 // or kNoHostId.
152 IPC_STRUCT_MEMBER(int, appcache_host_id)
153
[email protected]e3e402c2012-08-21 13:57:42154 // Optional resource request body (may be null).
155 IPC_STRUCT_MEMBER(scoped_refptr<webkit_glue::ResourceRequestBody>,
156 request_body)
[email protected]94dc971d2011-03-05 19:08:32157
158 IPC_STRUCT_MEMBER(bool, download_to_file)
159
160 // True if the request was user initiated.
161 IPC_STRUCT_MEMBER(bool, has_user_gesture)
[email protected]418da612011-07-21 19:01:52162
163 // True if |frame_id| is the main frame of a RenderView.
164 IPC_STRUCT_MEMBER(bool, is_main_frame)
165
166 // Identifies the frame within the RenderView that sent the request.
167 // -1 if unknown / invalid.
168 IPC_STRUCT_MEMBER(int64, frame_id)
[email protected]d88bf0a2011-08-30 23:55:57169
[email protected]91043a8232011-11-04 16:41:19170 // True if |parent_frame_id| is the main frame of a RenderView.
171 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
172
173 // Identifies the parent frame of the frame that sent the request.
174 // -1 if unknown / invalid.
175 IPC_STRUCT_MEMBER(int64, parent_frame_id)
176
[email protected]2905f742011-10-13 03:51:58177 IPC_STRUCT_MEMBER(content::PageTransition, transition_type)
[email protected]4ad5d77d2011-12-03 02:00:48178
179 // The following two members identify a previous request that has been
180 // created before this navigation has been transferred to a new render view.
181 // This serves the purpose of recycling the old request.
182 // Unless this refers to a transferred navigation, these values are -1 and -1.
183 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
184 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
[email protected]80744782012-05-04 01:47:00185
186 // Whether or not we should allow the URL to download.
187 IPC_STRUCT_MEMBER(bool, allow_download)
[email protected]94dc971d2011-03-05 19:08:32188IPC_STRUCT_END()
189
190// Resource messages sent from the browser to the renderer.
191
192// Sent when the headers are available for a resource request.
193IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse,
194 int /* request_id */,
[email protected]2336ffe2011-11-24 01:23:34195 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32196
197// Sent when cached metadata from a resource request is ready.
198IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata,
199 int /* request_id */,
200 std::vector<char> /* data */)
201
202// Sent as upload progress is being made.
203IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress,
204 int /* request_id */,
205 int64 /* position */,
206 int64 /* size */)
207
208// Sent when the request has been redirected. The receiver is expected to
209// respond with either a FollowRedirect message (if the redirect is to be
210// followed) or a CancelRequest message (if it should not be followed).
211IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect,
212 int /* request_id */,
213 GURL /* new_url */,
[email protected]2336ffe2011-11-24 01:23:34214 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32215
[email protected]f0fa1ab2012-09-18 06:28:38216// Sent to set the shared memory buffer to be used to transmit response data to
217// the renderer. Subsequent DataReceived messages refer to byte ranges in the
218// shared memory buffer. The shared memory buffer should be retained by the
219// renderer until the resource request completes.
220//
221// NOTE: The shared memory handle should already be mapped into the process
222// that receives this message.
223//
[email protected]9d9387e2013-01-12 16:55:08224// TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
225// added to help in debugging crbug/160401.
226//
227IPC_MESSAGE_ROUTED4(ResourceMsg_SetDataBuffer,
[email protected]f0fa1ab2012-09-18 06:28:38228 int /* request_id */,
229 base::SharedMemoryHandle /* shm_handle */,
[email protected]9d9387e2013-01-12 16:55:08230 int /* shm_size */,
231 base::ProcessId /* renderer_pid */)
[email protected]f0fa1ab2012-09-18 06:28:38232
233// Sent when some data from a resource request is ready. The data offset and
234// length specify a byte range into the shared memory buffer provided by the
235// SetDataBuffer message.
[email protected]8bd0de72011-04-08 18:52:10236IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived,
[email protected]94dc971d2011-03-05 19:08:32237 int /* request_id */,
[email protected]f0fa1ab2012-09-18 06:28:38238 int /* data_offset */,
239 int /* data_length */,
[email protected]dfd682172011-04-13 19:57:25240 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32241
242// Sent when some data from a resource request has been downloaded to
243// file. This is only called in the 'download_to_file' case and replaces
244// ResourceMsg_DataReceived in the call sequence in that case.
245IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded,
246 int /* request_id */,
247 int /* data_len */)
248
249// Sent when the request has been completed.
[email protected]2756a8e2012-09-07 18:24:29250IPC_MESSAGE_ROUTED5(ResourceMsg_RequestComplete,
[email protected]94dc971d2011-03-05 19:08:32251 int /* request_id */,
[email protected]2756a8e2012-09-07 18:24:29252 int /* error_code */,
253 bool /* was_ignored_by_handler */,
[email protected]94dc971d2011-03-05 19:08:32254 std::string /* security info */,
[email protected]cb8a87422011-12-16 01:15:57255 base::TimeTicks /* completion_time */)
[email protected]94dc971d2011-03-05 19:08:32256
257// Resource messages sent from the renderer to the browser.
258
259// Makes a resource request via the browser.
260IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource,
261 int /* request_id */,
262 ResourceHostMsg_Request)
263
264// Cancels a resource request with the ID given as the parameter.
265IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest,
266 int /* request_id */)
267
[email protected]94dc971d2011-03-05 19:08:32268// Follows a redirect that occured for the resource request with the ID given
269// as the parameter.
270IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect,
271 int /* request_id */,
272 bool /* has_new_first_party_for_cookies */,
273 GURL /* new_first_party_for_cookies */)
274
275// Makes a synchronous resource request via the browser.
276IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
277 int /* request_id */,
278 ResourceHostMsg_Request,
[email protected]2336ffe2011-11-24 01:23:34279 content::SyncLoadResult)
[email protected]94dc971d2011-03-05 19:08:32280
281// Sent when the renderer process is done processing a DataReceived
282// message.
283IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK,
284 int /* request_id */)
285
286// Sent when the renderer has processed a DataDownloaded message.
287IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK,
288 int /* request_id */)
289
290// Sent by the renderer process to acknowledge receipt of a
291// UploadProgress message.
292IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK,
293 int /* request_id */)
294
295// Sent when the renderer process deletes a resource loader.
296IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
297 int /* request_id */)