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.
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/common/service_worker/service_worker_types.h"
15 #include "content/public/common/common_param_traits.h"
16 #include "content/public/common/resource_response.h"
17 #include "ipc/ipc_message_macros.h"
18 #include "net/base/request_priority.h"
19 #include "net/http/http_response_info.h"
20 #include "net/url_request/redirect_info.h"
22 #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
23 #define CONTENT_COMMON_RESOURCE_MESSAGES_H_
26 struct LoadTimingInfo
;
30 struct ResourceDevToolsInfo
;
36 struct 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
, base::PickleIterator
* iter
, param_type
* r
);
40 static void Log(const param_type
& p
, std::string
* l
);
44 struct CONTENT_EXPORT ParamTraits
<storage::DataElement
> {
45 typedef storage::DataElement param_type
;
46 static void Write(Message
* m
, const param_type
& p
);
47 static bool Read(const Message
* m
, base::PickleIterator
* iter
, param_type
* r
);
48 static void Log(const param_type
& p
, std::string
* l
);
52 struct ParamTraits
<scoped_refptr
<content::ResourceDevToolsInfo
> > {
53 typedef scoped_refptr
<content::ResourceDevToolsInfo
> param_type
;
54 static void Write(Message
* m
, const param_type
& p
);
55 static bool Read(const Message
* m
, base::PickleIterator
* iter
, param_type
* r
);
56 static void Log(const param_type
& p
, std::string
* l
);
60 struct ParamTraits
<net::LoadTimingInfo
> {
61 typedef net::LoadTimingInfo param_type
;
62 static void Write(Message
* m
, const param_type
& p
);
63 static bool Read(const Message
* m
, base::PickleIterator
* iter
, param_type
* r
);
64 static void Log(const param_type
& p
, std::string
* l
);
68 struct ParamTraits
<scoped_refptr
<content::ResourceRequestBody
> > {
69 typedef scoped_refptr
<content::ResourceRequestBody
> param_type
;
70 static void Write(Message
* m
, const param_type
& p
);
71 static bool Read(const Message
* m
, base::PickleIterator
* iter
, param_type
* r
);
72 static void Log(const param_type
& p
, std::string
* l
);
77 #endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
80 #define IPC_MESSAGE_START ResourceMsgStart
81 #undef IPC_MESSAGE_EXPORT
82 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
84 IPC_ENUM_TRAITS_MAX_VALUE( \
85 net::HttpResponseInfo::ConnectionInfo
, \
86 net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS
- 1)
88 IPC_ENUM_TRAITS_MAX_VALUE(content::FetchRequestMode
,
89 content::FETCH_REQUEST_MODE_LAST
)
91 IPC_ENUM_TRAITS_MAX_VALUE(content::FetchCredentialsMode
,
92 content::FETCH_CREDENTIALS_MODE_LAST
)
94 IPC_ENUM_TRAITS_MAX_VALUE(content::FetchRedirectMode
,
95 content::FetchRedirectMode::LAST
)
97 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead
)
98 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo
)
99 IPC_STRUCT_TRAITS_MEMBER(request_start
)
100 IPC_STRUCT_TRAITS_MEMBER(response_start
)
101 IPC_STRUCT_TRAITS_END()
103 IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult
)
104 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead
)
105 IPC_STRUCT_TRAITS_MEMBER(error_code
)
106 IPC_STRUCT_TRAITS_MEMBER(final_url
)
107 IPC_STRUCT_TRAITS_MEMBER(data
)
108 IPC_STRUCT_TRAITS_END()
110 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo
)
111 IPC_STRUCT_TRAITS_MEMBER(request_time
)
112 IPC_STRUCT_TRAITS_MEMBER(response_time
)
113 IPC_STRUCT_TRAITS_MEMBER(headers
)
114 IPC_STRUCT_TRAITS_MEMBER(mime_type
)
115 IPC_STRUCT_TRAITS_MEMBER(charset
)
116 IPC_STRUCT_TRAITS_MEMBER(security_info
)
117 IPC_STRUCT_TRAITS_MEMBER(content_length
)
118 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length
)
119 IPC_STRUCT_TRAITS_MEMBER(appcache_id
)
120 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url
)
121 IPC_STRUCT_TRAITS_MEMBER(load_timing
)
122 IPC_STRUCT_TRAITS_MEMBER(devtools_info
)
123 IPC_STRUCT_TRAITS_MEMBER(download_file_path
)
124 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy
)
125 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated
)
126 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available
)
127 IPC_STRUCT_TRAITS_MEMBER(connection_info
)
128 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy
)
129 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol
)
130 IPC_STRUCT_TRAITS_MEMBER(socket_address
)
131 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker
)
132 IPC_STRUCT_TRAITS_MEMBER(was_fallback_required_by_service_worker
)
133 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker
)
134 IPC_STRUCT_TRAITS_MEMBER(response_type_via_service_worker
)
135 IPC_STRUCT_TRAITS_MEMBER(service_worker_start_time
)
136 IPC_STRUCT_TRAITS_MEMBER(service_worker_ready_time
)
137 IPC_STRUCT_TRAITS_MEMBER(proxy_server
)
138 IPC_STRUCT_TRAITS_END()
140 IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo
)
141 IPC_STRUCT_TRAITS_MEMBER(status_code
)
142 IPC_STRUCT_TRAITS_MEMBER(new_method
)
143 IPC_STRUCT_TRAITS_MEMBER(new_url
)
144 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies
)
145 IPC_STRUCT_TRAITS_MEMBER(new_referrer
)
146 IPC_STRUCT_TRAITS_END()
148 // Parameters for a resource request.
149 IPC_STRUCT_BEGIN(ResourceHostMsg_Request
)
150 // The request method: GET, POST, etc.
151 IPC_STRUCT_MEMBER(std::string
, method
)
153 // The requested URL.
154 IPC_STRUCT_MEMBER(GURL
, url
)
156 // Usually the URL of the document in the top-level window, which may be
157 // checked by the third-party cookie blocking policy. Leaving it empty may
158 // lead to undesired cookie blocking. Third-party cookie blocking can be
159 // bypassed by setting first_party_for_cookies = url, but this should ideally
160 // only be done if there really is no way to determine the correct value.
161 IPC_STRUCT_MEMBER(GURL
, first_party_for_cookies
)
163 // The referrer to use (may be empty).
164 IPC_STRUCT_MEMBER(GURL
, referrer
)
166 // The referrer policy to use.
167 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy
, referrer_policy
)
169 // The frame's visiblity state.
170 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState
, visiblity_state
)
172 // Additional HTTP request headers.
173 IPC_STRUCT_MEMBER(std::string
, headers
)
175 // net::URLRequest load flags (0 by default).
176 IPC_STRUCT_MEMBER(int, load_flags
)
178 // Process ID from which this request originated, or zero if it originated
179 // in the renderer itself.
180 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
181 // through the renderer and and this holds the pid of the plugin process.
182 // Otherwise this holds the render_process_id of the view that has the plugin.
183 IPC_STRUCT_MEMBER(int, origin_pid
)
185 // What this resource load is for (main frame, sub-frame, sub-resource,
187 IPC_STRUCT_MEMBER(content::ResourceType
, resource_type
)
189 // The priority of this request.
190 IPC_STRUCT_MEMBER(net::RequestPriority
, priority
)
192 // Used by plugin->browser requests to get the correct net::URLRequestContext.
193 IPC_STRUCT_MEMBER(uint32
, request_context
)
195 // Indicates which frame (or worker context) the request is being loaded into,
196 // or kAppCacheNoHostId.
197 IPC_STRUCT_MEMBER(int, appcache_host_id
)
199 // True if corresponding AppCache group should be resetted.
200 IPC_STRUCT_MEMBER(bool, should_reset_appcache
)
202 // Indicates which frame (or worker context) the request is being loaded into,
203 // or kInvalidServiceWorkerProviderId.
204 IPC_STRUCT_MEMBER(int, service_worker_provider_id
)
206 // True if the request should not be handled by the ServiceWorker.
207 IPC_STRUCT_MEMBER(bool, skip_service_worker
)
209 // The request mode passed to the ServiceWorker.
210 IPC_STRUCT_MEMBER(content::FetchRequestMode
, fetch_request_mode
)
212 // The credentials mode passed to the ServiceWorker.
213 IPC_STRUCT_MEMBER(content::FetchCredentialsMode
, fetch_credentials_mode
)
215 // The redirect mode used in Fetch API.
216 IPC_STRUCT_MEMBER(content::FetchRedirectMode
, fetch_redirect_mode
)
218 // The request context passed to the ServiceWorker.
219 IPC_STRUCT_MEMBER(content::RequestContextType
, fetch_request_context_type
)
221 // The frame type passed to the ServiceWorker.
222 IPC_STRUCT_MEMBER(content::RequestContextFrameType
, fetch_frame_type
)
224 // Optional resource request body (may be null).
225 IPC_STRUCT_MEMBER(scoped_refptr
<content::ResourceRequestBody
>,
228 IPC_STRUCT_MEMBER(bool, download_to_file
)
230 // True if the request was user initiated.
231 IPC_STRUCT_MEMBER(bool, has_user_gesture
)
233 // True if load timing data should be collected for request.
234 IPC_STRUCT_MEMBER(bool, enable_load_timing
)
236 // True if upload progress should be available for request.
237 IPC_STRUCT_MEMBER(bool, enable_upload_progress
)
239 // True if login prompts for this request should be supressed.
240 IPC_STRUCT_MEMBER(bool, do_not_prompt_for_login
)
242 // The routing id of the RenderFrame.
243 IPC_STRUCT_MEMBER(int, render_frame_id
)
245 // True if |frame_id| is the main frame of a RenderView.
246 IPC_STRUCT_MEMBER(bool, is_main_frame
)
248 // True if |parent_render_frame_id| is the main frame of a RenderView.
249 IPC_STRUCT_MEMBER(bool, parent_is_main_frame
)
251 // Identifies the parent frame of the frame that sent the request.
252 // -1 if unknown / invalid.
253 IPC_STRUCT_MEMBER(int, parent_render_frame_id
)
255 IPC_STRUCT_MEMBER(ui::PageTransition
, transition_type
)
257 // For navigations, whether this navigation should replace the current session
258 // history entry on commit.
259 IPC_STRUCT_MEMBER(bool, should_replace_current_entry
)
261 // The following two members identify a previous request that has been
262 // created before this navigation has been transferred to a new render view.
263 // This serves the purpose of recycling the old request.
264 // Unless this refers to a transferred navigation, these values are -1 and -1.
265 IPC_STRUCT_MEMBER(int, transferred_request_child_id
)
266 IPC_STRUCT_MEMBER(int, transferred_request_request_id
)
268 // Whether or not we should allow the URL to download.
269 IPC_STRUCT_MEMBER(bool, allow_download
)
271 // Whether to intercept headers to pass back to the renderer.
272 IPC_STRUCT_MEMBER(bool, report_raw_headers
)
275 // Parameters for a ResourceMsg_RequestComplete
276 IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData
)
278 IPC_STRUCT_MEMBER(int, error_code
)
280 // Was ignored by the request handler.
281 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler
)
283 // A copy of the data requested exists in the cache.
284 IPC_STRUCT_MEMBER(bool, exists_in_cache
)
286 // Serialized security info; see content/common/ssl_status_serialization.h.
287 IPC_STRUCT_MEMBER(std::string
, security_info
)
289 // Time the request completed.
290 IPC_STRUCT_MEMBER(base::TimeTicks
, completion_time
)
292 // Total amount of data received from the network.
293 IPC_STRUCT_MEMBER(int64
, encoded_data_length
)
296 // Resource messages sent from the browser to the renderer.
298 // Sent when the headers are available for a resource request.
299 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse
,
300 int /* request_id */,
301 content::ResourceResponseHead
)
303 // Sent when cached metadata from a resource request is ready.
304 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata
,
305 int /* request_id */,
306 std::vector
<char> /* data */)
308 // Sent as upload progress is being made.
309 IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress
,
310 int /* request_id */,
311 int64
/* position */,
314 // Sent when the request has been redirected. The receiver is expected to
315 // respond with either a FollowRedirect message (if the redirect is to be
316 // followed) or a CancelRequest message (if it should not be followed).
317 IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect
,
318 int /* request_id */,
319 net::RedirectInfo
/* redirect_info */,
320 content::ResourceResponseHead
)
322 // Sent to set the shared memory buffer to be used to transmit response data to
323 // the renderer. Subsequent DataReceived messages refer to byte ranges in the
324 // shared memory buffer. The shared memory buffer should be retained by the
325 // renderer until the resource request completes.
327 // NOTE: The shared memory handle should already be mapped into the process
328 // that receives this message.
330 // TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
331 // added to help in debugging crbug/160401.
333 IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer
,
334 int /* request_id */,
335 base::SharedMemoryHandle
/* shm_handle */,
337 base::ProcessId
/* renderer_pid */)
339 // Sent when some data from a resource request is ready. The data offset and
340 // length specify a byte range into the shared memory buffer provided by the
341 // SetDataBuffer message.
342 IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived
,
343 int /* request_id */,
344 int /* data_offset */,
345 int /* data_length */,
346 int /* encoded_data_length */)
348 // Sent when some data from a resource request has been downloaded to
349 // file. This is only called in the 'download_to_file' case and replaces
350 // ResourceMsg_DataReceived in the call sequence in that case.
351 IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded
,
352 int /* request_id */,
354 int /* encoded_data_length */)
356 // Sent when the request has been completed.
357 IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete
,
358 int /* request_id */,
359 ResourceMsg_RequestCompleteData
)
361 // Resource messages sent from the renderer to the browser.
363 // Makes a resource request via the browser.
364 IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource
,
365 int /* routing_id */,
366 int /* request_id */,
367 ResourceHostMsg_Request
)
369 // Cancels a resource request with the ID given as the parameter.
370 IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest
,
371 int /* request_id */)
373 // Follows a redirect that occured for the resource request with the ID given
375 IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect
,
376 int /* request_id */)
378 // Makes a synchronous resource request via the browser.
379 IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad
,
380 int /* request_id */,
381 ResourceHostMsg_Request
,
382 content::SyncLoadResult
)
384 // Sent when the renderer process is done processing a DataReceived
386 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK
,
387 int /* request_id */)
389 // Sent when the renderer has processed a DataDownloaded message.
390 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK
,
391 int /* request_id */)
393 // Sent by the renderer process to acknowledge receipt of a
394 // UploadProgress message.
395 IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK
,
396 int /* request_id */)
398 // Sent when the renderer process deletes a resource loader.
399 IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile
,
400 int /* request_id */)
402 // Sent by the renderer when a resource request changes priority.
403 IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority
,
404 int /* request_id */,
405 net::RequestPriority
,
406 int /* intra_priority_value */)