Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / common / resource_messages.h
blob2e604af7252be41f8b434fcd3737ef02b7d7f467
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // IPC messages for resource loading.
6 //
7 // NOTE: All messages must send an |int request_id| as their first parameter.
9 // Multiply-included message file, hence no include guard.
10 #include "base/memory/shared_memory.h"
11 #include "base/process/process.h"
12 #include "content/common/content_param_traits_macros.h"
13 #include "content/common/resource_request_body.h"
14 #include "content/public/common/common_param_traits.h"
15 #include "content/public/common/resource_response.h"
16 #include "ipc/ipc_message_macros.h"
17 #include "net/base/request_priority.h"
18 #include "net/http/http_response_info.h"
19 #include "net/url_request/redirect_info.h"
21 #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
22 #define CONTENT_COMMON_RESOURCE_MESSAGES_H_
24 namespace net {
25 struct LoadTimingInfo;
28 namespace content {
29 struct ResourceDevToolsInfo;
32 namespace IPC {
34 template <>
35 struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
36 typedef scoped_refptr<net::HttpResponseHeaders> 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);
42 template <>
43 struct CONTENT_EXPORT ParamTraits<storage::DataElement> {
44 typedef storage::DataElement 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);
50 template <>
51 struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
52 typedef scoped_refptr<content::ResourceDevToolsInfo> 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);
58 template <>
59 struct ParamTraits<net::LoadTimingInfo> {
60 typedef net::LoadTimingInfo 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);
66 template <>
67 struct ParamTraits<scoped_refptr<content::ResourceRequestBody> > {
68 typedef scoped_refptr<content::ResourceRequestBody> param_type;
69 static void Write(Message* m, const param_type& p);
70 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
71 static void Log(const param_type& p, std::string* l);
74 } // namespace IPC
76 #endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
79 #define IPC_MESSAGE_START ResourceMsgStart
80 #undef IPC_MESSAGE_EXPORT
81 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
83 IPC_ENUM_TRAITS_MAX_VALUE( \
84 net::HttpResponseInfo::ConnectionInfo, \
85 net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
87 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
88 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo)
89 IPC_STRUCT_TRAITS_MEMBER(error_code)
90 IPC_STRUCT_TRAITS_MEMBER(request_start)
91 IPC_STRUCT_TRAITS_MEMBER(response_start)
92 IPC_STRUCT_TRAITS_END()
94 IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
95 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
96 IPC_STRUCT_TRAITS_MEMBER(final_url)
97 IPC_STRUCT_TRAITS_MEMBER(data)
98 IPC_STRUCT_TRAITS_END()
100 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo)
101 IPC_STRUCT_TRAITS_MEMBER(request_time)
102 IPC_STRUCT_TRAITS_MEMBER(response_time)
103 IPC_STRUCT_TRAITS_MEMBER(headers)
104 IPC_STRUCT_TRAITS_MEMBER(mime_type)
105 IPC_STRUCT_TRAITS_MEMBER(charset)
106 IPC_STRUCT_TRAITS_MEMBER(security_info)
107 IPC_STRUCT_TRAITS_MEMBER(content_length)
108 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
109 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
110 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
111 IPC_STRUCT_TRAITS_MEMBER(load_timing)
112 IPC_STRUCT_TRAITS_MEMBER(devtools_info)
113 IPC_STRUCT_TRAITS_MEMBER(download_file_path)
114 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
115 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
116 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
117 IPC_STRUCT_TRAITS_MEMBER(connection_info)
118 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
119 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
120 IPC_STRUCT_TRAITS_MEMBER(socket_address)
121 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker)
122 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker)
123 IPC_STRUCT_TRAITS_END()
125 IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo)
126 IPC_STRUCT_TRAITS_MEMBER(status_code)
127 IPC_STRUCT_TRAITS_MEMBER(new_method)
128 IPC_STRUCT_TRAITS_MEMBER(new_url)
129 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies)
130 IPC_STRUCT_TRAITS_MEMBER(new_referrer)
131 IPC_STRUCT_TRAITS_END()
133 // Parameters for a resource request.
134 IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
135 // The request method: GET, POST, etc.
136 IPC_STRUCT_MEMBER(std::string, method)
138 // The requested URL.
139 IPC_STRUCT_MEMBER(GURL, url)
141 // Usually the URL of the document in the top-level window, which may be
142 // checked by the third-party cookie blocking policy. Leaving it empty may
143 // lead to undesired cookie blocking. Third-party cookie blocking can be
144 // bypassed by setting first_party_for_cookies = url, but this should ideally
145 // only be done if there really is no way to determine the correct value.
146 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
148 // The referrer to use (may be empty).
149 IPC_STRUCT_MEMBER(GURL, referrer)
151 // The referrer policy to use.
152 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
154 // The frame's visiblity state.
155 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
157 // Additional HTTP request headers.
158 IPC_STRUCT_MEMBER(std::string, headers)
160 // net::URLRequest load flags (0 by default).
161 IPC_STRUCT_MEMBER(int, load_flags)
163 // Process ID from which this request originated, or zero if it originated
164 // in the renderer itself.
165 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
166 // through the renderer and and this holds the pid of the plugin process.
167 // Otherwise this holds the render_process_id of the view that has the plugin.
168 IPC_STRUCT_MEMBER(int, origin_pid)
170 // What this resource load is for (main frame, sub-frame, sub-resource,
171 // object).
172 IPC_STRUCT_MEMBER(content::ResourceType, resource_type)
174 // The priority of this request.
175 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
177 // Used by plugin->browser requests to get the correct net::URLRequestContext.
178 IPC_STRUCT_MEMBER(uint32, request_context)
180 // Indicates which frame (or worker context) the request is being loaded into,
181 // or kAppCacheNoHostId.
182 IPC_STRUCT_MEMBER(int, appcache_host_id)
184 // Indicates which frame (or worker context) the request is being loaded into,
185 // or kInvalidServiceWorkerProviderId.
186 IPC_STRUCT_MEMBER(int, service_worker_provider_id)
188 // Optional resource request body (may be null).
189 IPC_STRUCT_MEMBER(scoped_refptr<content::ResourceRequestBody>,
190 request_body)
192 IPC_STRUCT_MEMBER(bool, download_to_file)
194 // True if the request was user initiated.
195 IPC_STRUCT_MEMBER(bool, has_user_gesture)
197 // True if load timing data should be collected for request.
198 IPC_STRUCT_MEMBER(bool, enable_load_timing)
200 // The routing id of the RenderFrame.
201 IPC_STRUCT_MEMBER(int, render_frame_id)
203 // True if |frame_id| is the main frame of a RenderView.
204 IPC_STRUCT_MEMBER(bool, is_main_frame)
206 // True if |parent_render_frame_id| is the main frame of a RenderView.
207 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
209 // Identifies the parent frame of the frame that sent the request.
210 // -1 if unknown / invalid.
211 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
213 IPC_STRUCT_MEMBER(content::PageTransition, transition_type)
215 // For navigations, whether this navigation should replace the current session
216 // history entry on commit.
217 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
219 // The following two members identify a previous request that has been
220 // created before this navigation has been transferred to a new render view.
221 // This serves the purpose of recycling the old request.
222 // Unless this refers to a transferred navigation, these values are -1 and -1.
223 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
224 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
226 // Whether or not we should allow the URL to download.
227 IPC_STRUCT_MEMBER(bool, allow_download)
228 IPC_STRUCT_END()
230 // Parameters for a ResourceMsg_RequestComplete
231 IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
232 // The error code.
233 IPC_STRUCT_MEMBER(int, error_code)
235 // Was ignored by the request handler.
236 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
238 // A copy of the data requested exists in the cache.
239 IPC_STRUCT_MEMBER(bool, exists_in_cache)
241 // Serialized security info; see content/common/ssl_status_serialization.h.
242 IPC_STRUCT_MEMBER(std::string, security_info)
244 // Time the request completed.
245 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
247 // Total amount of data received from the network.
248 IPC_STRUCT_MEMBER(int64, encoded_data_length)
249 IPC_STRUCT_END()
251 // Resource messages sent from the browser to the renderer.
253 // Sent when the headers are available for a resource request.
254 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
255 int /* request_id */,
256 content::ResourceResponseHead)
258 // Sent when cached metadata from a resource request is ready.
259 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
260 int /* request_id */,
261 std::vector<char> /* data */)
263 // Sent as upload progress is being made.
264 IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
265 int /* request_id */,
266 int64 /* position */,
267 int64 /* size */)
269 // Sent when the request has been redirected. The receiver is expected to
270 // respond with either a FollowRedirect message (if the redirect is to be
271 // followed) or a CancelRequest message (if it should not be followed).
272 IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
273 int /* request_id */,
274 net::RedirectInfo /* redirect_info */,
275 content::ResourceResponseHead)
277 // Sent to set the shared memory buffer to be used to transmit response data to
278 // the renderer. Subsequent DataReceived messages refer to byte ranges in the
279 // shared memory buffer. The shared memory buffer should be retained by the
280 // renderer until the resource request completes.
282 // NOTE: The shared memory handle should already be mapped into the process
283 // that receives this message.
285 // TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
286 // added to help in debugging crbug/160401.
288 IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
289 int /* request_id */,
290 base::SharedMemoryHandle /* shm_handle */,
291 int /* shm_size */,
292 base::ProcessId /* renderer_pid */)
294 // Sent when some data from a resource request is ready. The data offset and
295 // length specify a byte range into the shared memory buffer provided by the
296 // SetDataBuffer message.
297 IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
298 int /* request_id */,
299 int /* data_offset */,
300 int /* data_length */,
301 int /* encoded_data_length */)
303 // Sent when some data from a resource request has been downloaded to
304 // file. This is only called in the 'download_to_file' case and replaces
305 // ResourceMsg_DataReceived in the call sequence in that case.
306 IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
307 int /* request_id */,
308 int /* data_len */,
309 int /* encoded_data_length */)
311 // Sent when the request has been completed.
312 IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
313 int /* request_id */,
314 ResourceMsg_RequestCompleteData)
316 // Resource messages sent from the renderer to the browser.
318 // Makes a resource request via the browser.
319 IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource,
320 int /* routing_id */,
321 int /* request_id */,
322 ResourceHostMsg_Request)
324 // Cancels a resource request with the ID given as the parameter.
325 IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
326 int /* request_id */)
328 // Follows a redirect that occured for the resource request with the ID given
329 // as the parameter.
330 IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect,
331 int /* request_id */)
333 // Makes a synchronous resource request via the browser.
334 IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
335 int /* request_id */,
336 ResourceHostMsg_Request,
337 content::SyncLoadResult)
339 // Sent when the renderer process is done processing a DataReceived
340 // message.
341 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
342 int /* request_id */)
344 // Sent when the renderer has processed a DataDownloaded message.
345 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
346 int /* request_id */)
348 // Sent by the renderer process to acknowledge receipt of a
349 // UploadProgress message.
350 IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
351 int /* request_id */)
353 // Sent when the renderer process deletes a resource loader.
354 IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
355 int /* request_id */)
357 // Sent by the renderer when a resource request changes priority.
358 IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
359 int /* request_id */,
360 net::RequestPriority,
361 int /* intra_priority_value */)