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_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead
)
95 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo
)
96 IPC_STRUCT_TRAITS_MEMBER(request_start
)
97 IPC_STRUCT_TRAITS_MEMBER(response_start
)
98 IPC_STRUCT_TRAITS_END()
100 IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult
)
101 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead
)
102 IPC_STRUCT_TRAITS_MEMBER(error_code
)
103 IPC_STRUCT_TRAITS_MEMBER(final_url
)
104 IPC_STRUCT_TRAITS_MEMBER(data
)
105 IPC_STRUCT_TRAITS_END()
107 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo
)
108 IPC_STRUCT_TRAITS_MEMBER(request_time
)
109 IPC_STRUCT_TRAITS_MEMBER(response_time
)
110 IPC_STRUCT_TRAITS_MEMBER(headers
)
111 IPC_STRUCT_TRAITS_MEMBER(mime_type
)
112 IPC_STRUCT_TRAITS_MEMBER(charset
)
113 IPC_STRUCT_TRAITS_MEMBER(security_info
)
114 IPC_STRUCT_TRAITS_MEMBER(content_length
)
115 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length
)
116 IPC_STRUCT_TRAITS_MEMBER(appcache_id
)
117 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url
)
118 IPC_STRUCT_TRAITS_MEMBER(load_timing
)
119 IPC_STRUCT_TRAITS_MEMBER(devtools_info
)
120 IPC_STRUCT_TRAITS_MEMBER(download_file_path
)
121 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy
)
122 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated
)
123 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available
)
124 IPC_STRUCT_TRAITS_MEMBER(connection_info
)
125 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy
)
126 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol
)
127 IPC_STRUCT_TRAITS_MEMBER(socket_address
)
128 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker
)
129 IPC_STRUCT_TRAITS_MEMBER(was_fallback_required_by_service_worker
)
130 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker
)
131 IPC_STRUCT_TRAITS_MEMBER(response_type_via_service_worker
)
132 IPC_STRUCT_TRAITS_MEMBER(service_worker_start_time
)
133 IPC_STRUCT_TRAITS_MEMBER(proxy_server
)
134 IPC_STRUCT_TRAITS_END()
136 IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo
)
137 IPC_STRUCT_TRAITS_MEMBER(status_code
)
138 IPC_STRUCT_TRAITS_MEMBER(new_method
)
139 IPC_STRUCT_TRAITS_MEMBER(new_url
)
140 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies
)
141 IPC_STRUCT_TRAITS_MEMBER(new_referrer
)
142 IPC_STRUCT_TRAITS_END()
144 // Parameters for a resource request.
145 IPC_STRUCT_BEGIN(ResourceHostMsg_Request
)
146 // The request method: GET, POST, etc.
147 IPC_STRUCT_MEMBER(std::string
, method
)
149 // The requested URL.
150 IPC_STRUCT_MEMBER(GURL
, url
)
152 // Usually the URL of the document in the top-level window, which may be
153 // checked by the third-party cookie blocking policy. Leaving it empty may
154 // lead to undesired cookie blocking. Third-party cookie blocking can be
155 // bypassed by setting first_party_for_cookies = url, but this should ideally
156 // only be done if there really is no way to determine the correct value.
157 IPC_STRUCT_MEMBER(GURL
, first_party_for_cookies
)
159 // The referrer to use (may be empty).
160 IPC_STRUCT_MEMBER(GURL
, referrer
)
162 // The referrer policy to use.
163 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy
, referrer_policy
)
165 // The frame's visiblity state.
166 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState
, visiblity_state
)
168 // Additional HTTP request headers.
169 IPC_STRUCT_MEMBER(std::string
, headers
)
171 // net::URLRequest load flags (0 by default).
172 IPC_STRUCT_MEMBER(int, load_flags
)
174 // Process ID from which this request originated, or zero if it originated
175 // in the renderer itself.
176 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
177 // through the renderer and and this holds the pid of the plugin process.
178 // Otherwise this holds the render_process_id of the view that has the plugin.
179 IPC_STRUCT_MEMBER(int, origin_pid
)
181 // What this resource load is for (main frame, sub-frame, sub-resource,
183 IPC_STRUCT_MEMBER(content::ResourceType
, resource_type
)
185 // The priority of this request.
186 IPC_STRUCT_MEMBER(net::RequestPriority
, priority
)
188 // Used by plugin->browser requests to get the correct net::URLRequestContext.
189 IPC_STRUCT_MEMBER(uint32
, request_context
)
191 // Indicates which frame (or worker context) the request is being loaded into,
192 // or kAppCacheNoHostId.
193 IPC_STRUCT_MEMBER(int, appcache_host_id
)
195 // True if corresponding AppCache group should be resetted.
196 IPC_STRUCT_MEMBER(bool, should_reset_appcache
)
198 // Indicates which frame (or worker context) the request is being loaded into,
199 // or kInvalidServiceWorkerProviderId.
200 IPC_STRUCT_MEMBER(int, service_worker_provider_id
)
202 // True if the request should not be handled by the ServiceWorker.
203 IPC_STRUCT_MEMBER(bool, skip_service_worker
)
205 // The request mode passed to the ServiceWorker.
206 IPC_STRUCT_MEMBER(content::FetchRequestMode
, fetch_request_mode
)
208 // The credentials mode passed to the ServiceWorker.
209 IPC_STRUCT_MEMBER(content::FetchCredentialsMode
, fetch_credentials_mode
)
211 // The request context passed to the ServiceWorker.
212 IPC_STRUCT_MEMBER(content::RequestContextType
, fetch_request_context_type
)
214 // The frame type passed to the ServiceWorker.
215 IPC_STRUCT_MEMBER(content::RequestContextFrameType
, fetch_frame_type
)
217 // Optional resource request body (may be null).
218 IPC_STRUCT_MEMBER(scoped_refptr
<content::ResourceRequestBody
>,
221 IPC_STRUCT_MEMBER(bool, download_to_file
)
223 // True if the request was user initiated.
224 IPC_STRUCT_MEMBER(bool, has_user_gesture
)
226 // True if load timing data should be collected for request.
227 IPC_STRUCT_MEMBER(bool, enable_load_timing
)
229 // True if upload progress should be available for request.
230 IPC_STRUCT_MEMBER(bool, enable_upload_progress
)
232 // True if login prompts for this request should be supressed.
233 IPC_STRUCT_MEMBER(bool, do_not_prompt_for_login
)
235 // The routing id of the RenderFrame.
236 IPC_STRUCT_MEMBER(int, render_frame_id
)
238 // True if |frame_id| is the main frame of a RenderView.
239 IPC_STRUCT_MEMBER(bool, is_main_frame
)
241 // True if |parent_render_frame_id| is the main frame of a RenderView.
242 IPC_STRUCT_MEMBER(bool, parent_is_main_frame
)
244 // Identifies the parent frame of the frame that sent the request.
245 // -1 if unknown / invalid.
246 IPC_STRUCT_MEMBER(int, parent_render_frame_id
)
248 IPC_STRUCT_MEMBER(ui::PageTransition
, transition_type
)
250 // For navigations, whether this navigation should replace the current session
251 // history entry on commit.
252 IPC_STRUCT_MEMBER(bool, should_replace_current_entry
)
254 // The following two members identify a previous request that has been
255 // created before this navigation has been transferred to a new render view.
256 // This serves the purpose of recycling the old request.
257 // Unless this refers to a transferred navigation, these values are -1 and -1.
258 IPC_STRUCT_MEMBER(int, transferred_request_child_id
)
259 IPC_STRUCT_MEMBER(int, transferred_request_request_id
)
261 // Whether or not we should allow the URL to download.
262 IPC_STRUCT_MEMBER(bool, allow_download
)
265 // Parameters for a ResourceMsg_RequestComplete
266 IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData
)
268 IPC_STRUCT_MEMBER(int, error_code
)
270 // Was ignored by the request handler.
271 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler
)
273 // A copy of the data requested exists in the cache.
274 IPC_STRUCT_MEMBER(bool, exists_in_cache
)
276 // Serialized security info; see content/common/ssl_status_serialization.h.
277 IPC_STRUCT_MEMBER(std::string
, security_info
)
279 // Time the request completed.
280 IPC_STRUCT_MEMBER(base::TimeTicks
, completion_time
)
282 // Total amount of data received from the network.
283 IPC_STRUCT_MEMBER(int64
, encoded_data_length
)
286 // Resource messages sent from the browser to the renderer.
288 // Sent when the headers are available for a resource request.
289 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse
,
290 int /* request_id */,
291 content::ResourceResponseHead
)
293 // Sent when cached metadata from a resource request is ready.
294 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata
,
295 int /* request_id */,
296 std::vector
<char> /* data */)
298 // Sent as upload progress is being made.
299 IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress
,
300 int /* request_id */,
301 int64
/* position */,
304 // Sent when the request has been redirected. The receiver is expected to
305 // respond with either a FollowRedirect message (if the redirect is to be
306 // followed) or a CancelRequest message (if it should not be followed).
307 IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect
,
308 int /* request_id */,
309 net::RedirectInfo
/* redirect_info */,
310 content::ResourceResponseHead
)
312 // Sent to set the shared memory buffer to be used to transmit response data to
313 // the renderer. Subsequent DataReceived messages refer to byte ranges in the
314 // shared memory buffer. The shared memory buffer should be retained by the
315 // renderer until the resource request completes.
317 // NOTE: The shared memory handle should already be mapped into the process
318 // that receives this message.
320 // TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
321 // added to help in debugging crbug/160401.
323 IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer
,
324 int /* request_id */,
325 base::SharedMemoryHandle
/* shm_handle */,
327 base::ProcessId
/* renderer_pid */)
329 // Sent when some data from a resource request is ready. The data offset and
330 // length specify a byte range into the shared memory buffer provided by the
331 // SetDataBuffer message.
332 IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived
,
333 int /* request_id */,
334 int /* data_offset */,
335 int /* data_length */,
336 int /* encoded_data_length */)
338 // Sent when some data from a resource request has been downloaded to
339 // file. This is only called in the 'download_to_file' case and replaces
340 // ResourceMsg_DataReceived in the call sequence in that case.
341 IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded
,
342 int /* request_id */,
344 int /* encoded_data_length */)
346 // Sent when the request has been completed.
347 IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete
,
348 int /* request_id */,
349 ResourceMsg_RequestCompleteData
)
351 // Resource messages sent from the renderer to the browser.
353 // Makes a resource request via the browser.
354 IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource
,
355 int /* routing_id */,
356 int /* request_id */,
357 ResourceHostMsg_Request
)
359 // Cancels a resource request with the ID given as the parameter.
360 IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest
,
361 int /* request_id */)
363 // Follows a redirect that occured for the resource request with the ID given
365 IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect
,
366 int /* request_id */)
368 // Makes a synchronous resource request via the browser.
369 IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad
,
370 int /* request_id */,
371 ResourceHostMsg_Request
,
372 content::SyncLoadResult
)
374 // Sent when the renderer process is done processing a DataReceived
376 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK
,
377 int /* request_id */)
379 // Sent when the renderer has processed a DataDownloaded message.
380 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK
,
381 int /* request_id */)
383 // Sent by the renderer process to acknowledge receipt of a
384 // UploadProgress message.
385 IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK
,
386 int /* request_id */)
388 // Sent when the renderer process deletes a resource loader.
389 IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile
,
390 int /* request_id */)
392 // Sent by the renderer when a resource request changes priority.
393 IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority
,
394 int /* request_id */,
395 net::RequestPriority
,
396 int /* intra_priority_value */)