blob: a838a3433b652d591c963c55dd212c4b2191b192 [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]94dc971d2011-03-05 19:08:328#include "base/shared_memory.h"
[email protected]9d8ea302012-09-25 15:04:229#include "content/common/content_param_traits_macros.h"
[email protected]19a5c7442011-10-21 20:00:4110#include "content/public/common/common_param_traits.h"
[email protected]2336ffe2011-11-24 01:23:3411#include "content/public/common/resource_response.h"
[email protected]94dc971d2011-03-05 19:08:3212#include "ipc/ipc_message_macros.h"
[email protected]e3e402c2012-08-21 13:57:4213#include "webkit/glue/resource_request_body.h"
[email protected]94dc971d2011-03-05 19:08:3214
[email protected]9d8ea302012-09-25 15:04:2215#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
16#define CONTENT_COMMON_RESOURCE_MESSAGES_H_
17
18namespace webkit_glue {
19struct ResourceDevToolsInfo;
20struct ResourceLoadTimingInfo;
21}
22
23namespace IPC {
24
25template <>
26struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
27 typedef scoped_refptr<net::HttpResponseHeaders> param_type;
28 static void Write(Message* m, const param_type& p);
29 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
30 static void Log(const param_type& p, std::string* l);
31};
32
33template <>
34struct CONTENT_EXPORT ParamTraits<webkit_base::DataElement> {
35 typedef webkit_base::DataElement 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 <>
42struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > {
43 typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type;
44 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 <>
50struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> {
51 typedef webkit_glue::ResourceLoadTimingInfo param_type;
52 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 <>
58struct ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> > {
59 typedef scoped_refptr<webkit_glue::ResourceRequestBody> param_type;
60 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
65} // namespace IPC
66
67#endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
68
69
[email protected]94dc971d2011-03-05 19:08:3270#define IPC_MESSAGE_START ResourceMsgStart
[email protected]03ff5e52011-09-30 00:28:1471#undef IPC_MESSAGE_EXPORT
72#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
[email protected]94dc971d2011-03-05 19:08:3273
[email protected]2336ffe2011-11-24 01:23:3474IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
75 IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo)
[email protected]2756a8e2012-09-07 18:24:2976 IPC_STRUCT_TRAITS_MEMBER(error_code)
[email protected]d43d2e112012-08-07 01:10:1977 IPC_STRUCT_TRAITS_MEMBER(request_start)
78 IPC_STRUCT_TRAITS_MEMBER(response_start)
[email protected]2336ffe2011-11-24 01:23:3479IPC_STRUCT_TRAITS_END()
80
81IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
82 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
83 IPC_STRUCT_TRAITS_MEMBER(final_url)
84 IPC_STRUCT_TRAITS_MEMBER(data)
85IPC_STRUCT_TRAITS_END()
86
[email protected]94dc971d2011-03-05 19:08:3287IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo)
88 IPC_STRUCT_TRAITS_MEMBER(request_time)
89 IPC_STRUCT_TRAITS_MEMBER(response_time)
90 IPC_STRUCT_TRAITS_MEMBER(headers)
91 IPC_STRUCT_TRAITS_MEMBER(mime_type)
92 IPC_STRUCT_TRAITS_MEMBER(charset)
93 IPC_STRUCT_TRAITS_MEMBER(security_info)
94 IPC_STRUCT_TRAITS_MEMBER(content_length)
[email protected]dfd682172011-04-13 19:57:2595 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
[email protected]94dc971d2011-03-05 19:08:3296 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
97 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
98 IPC_STRUCT_TRAITS_MEMBER(connection_id)
99 IPC_STRUCT_TRAITS_MEMBER(connection_reused)
100 IPC_STRUCT_TRAITS_MEMBER(load_timing)
101 IPC_STRUCT_TRAITS_MEMBER(devtools_info)
102 IPC_STRUCT_TRAITS_MEMBER(download_file_path)
103 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
104 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
105 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
106 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
[email protected]b9fd01ba2012-02-28 01:50:40107 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
[email protected]94dc971d2011-03-05 19:08:32108 IPC_STRUCT_TRAITS_MEMBER(socket_address)
109IPC_STRUCT_TRAITS_END()
110
[email protected]94dc971d2011-03-05 19:08:32111// Parameters for a resource request.
112IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
113 // The request method: GET, POST, etc.
114 IPC_STRUCT_MEMBER(std::string, method)
115
116 // The requested URL.
117 IPC_STRUCT_MEMBER(GURL, url)
118
119 // Usually the URL of the document in the top-level window, which may be
120 // checked by the third-party cookie blocking policy. Leaving it empty may
121 // lead to undesired cookie blocking. Third-party cookie blocking can be
122 // bypassed by setting first_party_for_cookies = url, but this should ideally
123 // only be done if there really is no way to determine the correct value.
124 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
125
126 // The referrer to use (may be empty).
127 IPC_STRUCT_MEMBER(GURL, referrer)
128
[email protected]d5a50342011-12-05 21:56:52129 // The referrer policy to use.
130 IPC_STRUCT_MEMBER(WebKit::WebReferrerPolicy, referrer_policy)
131
[email protected]94dc971d2011-03-05 19:08:32132 // Additional HTTP request headers.
133 IPC_STRUCT_MEMBER(std::string, headers)
134
135 // net::URLRequest load flags (0 by default).
136 IPC_STRUCT_MEMBER(int, load_flags)
137
138 // Process ID from which this request originated, or zero if it originated
139 // in the renderer itself.
140 IPC_STRUCT_MEMBER(int, origin_pid)
141
142 // What this resource load is for (main frame, sub-frame, sub-resource,
143 // object).
144 IPC_STRUCT_MEMBER(ResourceType::Type, resource_type)
145
146 // Used by plugin->browser requests to get the correct net::URLRequestContext.
147 IPC_STRUCT_MEMBER(uint32, request_context)
148
149 // Indicates which frame (or worker context) the request is being loaded into,
150 // or kNoHostId.
151 IPC_STRUCT_MEMBER(int, appcache_host_id)
152
[email protected]e3e402c2012-08-21 13:57:42153 // Optional resource request body (may be null).
154 IPC_STRUCT_MEMBER(scoped_refptr<webkit_glue::ResourceRequestBody>,
155 request_body)
[email protected]94dc971d2011-03-05 19:08:32156
157 IPC_STRUCT_MEMBER(bool, download_to_file)
158
159 // True if the request was user initiated.
160 IPC_STRUCT_MEMBER(bool, has_user_gesture)
[email protected]418da612011-07-21 19:01:52161
162 // True if |frame_id| is the main frame of a RenderView.
163 IPC_STRUCT_MEMBER(bool, is_main_frame)
164
165 // Identifies the frame within the RenderView that sent the request.
166 // -1 if unknown / invalid.
167 IPC_STRUCT_MEMBER(int64, frame_id)
[email protected]d88bf0a2011-08-30 23:55:57168
[email protected]91043a8232011-11-04 16:41:19169 // True if |parent_frame_id| is the main frame of a RenderView.
170 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
171
172 // Identifies the parent frame of the frame that sent the request.
173 // -1 if unknown / invalid.
174 IPC_STRUCT_MEMBER(int64, parent_frame_id)
175
[email protected]2905f742011-10-13 03:51:58176 IPC_STRUCT_MEMBER(content::PageTransition, transition_type)
[email protected]4ad5d77d2011-12-03 02:00:48177
178 // The following two members identify a previous request that has been
179 // created before this navigation has been transferred to a new render view.
180 // This serves the purpose of recycling the old request.
181 // Unless this refers to a transferred navigation, these values are -1 and -1.
182 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
183 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
[email protected]80744782012-05-04 01:47:00184
185 // Whether or not we should allow the URL to download.
186 IPC_STRUCT_MEMBER(bool, allow_download)
[email protected]94dc971d2011-03-05 19:08:32187IPC_STRUCT_END()
188
189// Resource messages sent from the browser to the renderer.
190
191// Sent when the headers are available for a resource request.
192IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse,
193 int /* request_id */,
[email protected]2336ffe2011-11-24 01:23:34194 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32195
196// Sent when cached metadata from a resource request is ready.
197IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata,
198 int /* request_id */,
199 std::vector<char> /* data */)
200
201// Sent as upload progress is being made.
202IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress,
203 int /* request_id */,
204 int64 /* position */,
205 int64 /* size */)
206
207// Sent when the request has been redirected. The receiver is expected to
208// respond with either a FollowRedirect message (if the redirect is to be
209// followed) or a CancelRequest message (if it should not be followed).
210IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect,
211 int /* request_id */,
212 GURL /* new_url */,
[email protected]2336ffe2011-11-24 01:23:34213 content::ResourceResponseHead)
[email protected]94dc971d2011-03-05 19:08:32214
[email protected]f0fa1ab2012-09-18 06:28:38215// Sent to set the shared memory buffer to be used to transmit response data to
216// the renderer. Subsequent DataReceived messages refer to byte ranges in the
217// shared memory buffer. The shared memory buffer should be retained by the
218// renderer until the resource request completes.
219//
220// NOTE: The shared memory handle should already be mapped into the process
221// that receives this message.
222//
223IPC_MESSAGE_ROUTED3(ResourceMsg_SetDataBuffer,
224 int /* request_id */,
225 base::SharedMemoryHandle /* shm_handle */,
226 int /* shm_size */)
227
228// Sent when some data from a resource request is ready. The data offset and
229// length specify a byte range into the shared memory buffer provided by the
230// SetDataBuffer message.
[email protected]8bd0de72011-04-08 18:52:10231IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived,
[email protected]94dc971d2011-03-05 19:08:32232 int /* request_id */,
[email protected]f0fa1ab2012-09-18 06:28:38233 int /* data_offset */,
234 int /* data_length */,
[email protected]dfd682172011-04-13 19:57:25235 int /* encoded_data_length */)
[email protected]94dc971d2011-03-05 19:08:32236
237// Sent when some data from a resource request has been downloaded to
238// file. This is only called in the 'download_to_file' case and replaces
239// ResourceMsg_DataReceived in the call sequence in that case.
240IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded,
241 int /* request_id */,
242 int /* data_len */)
243
244// Sent when the request has been completed.
[email protected]2756a8e2012-09-07 18:24:29245IPC_MESSAGE_ROUTED5(ResourceMsg_RequestComplete,
[email protected]94dc971d2011-03-05 19:08:32246 int /* request_id */,
[email protected]2756a8e2012-09-07 18:24:29247 int /* error_code */,
248 bool /* was_ignored_by_handler */,
[email protected]94dc971d2011-03-05 19:08:32249 std::string /* security info */,
[email protected]cb8a87422011-12-16 01:15:57250 base::TimeTicks /* completion_time */)
[email protected]94dc971d2011-03-05 19:08:32251
252// Resource messages sent from the renderer to the browser.
253
254// Makes a resource request via the browser.
255IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource,
256 int /* request_id */,
257 ResourceHostMsg_Request)
258
259// Cancels a resource request with the ID given as the parameter.
260IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest,
261 int /* request_id */)
262
[email protected]94dc971d2011-03-05 19:08:32263// Follows a redirect that occured for the resource request with the ID given
264// as the parameter.
265IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect,
266 int /* request_id */,
267 bool /* has_new_first_party_for_cookies */,
268 GURL /* new_first_party_for_cookies */)
269
270// Makes a synchronous resource request via the browser.
271IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
272 int /* request_id */,
273 ResourceHostMsg_Request,
[email protected]2336ffe2011-11-24 01:23:34274 content::SyncLoadResult)
[email protected]94dc971d2011-03-05 19:08:32275
276// Sent when the renderer process is done processing a DataReceived
277// message.
278IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK,
279 int /* request_id */)
280
281// Sent when the renderer has processed a DataDownloaded message.
282IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK,
283 int /* request_id */)
284
285// Sent by the renderer process to acknowledge receipt of a
286// UploadProgress message.
287IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK,
288 int /* request_id */)
289
290// Sent when the renderer process deletes a resource loader.
291IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
292 int /* request_id */)