[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 2 | // 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] | a17df45d | 2013-02-15 11:12:46 | [diff] [blame] | 6 | // |
| 7 | // NOTE: All messages must send an |int request_id| as their first parameter. |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 8 | |
[email protected] | e503a12 | 2011-03-17 18:20:52 | [diff] [blame] | 9 | // Multiply-included message file, hence no include guard. |
[email protected] | 9cc992b | 2013-07-17 06:30:36 | [diff] [blame^] | 10 | #include "base/memory/shared_memory.h" |
[email protected] | 9d9387e | 2013-01-12 16:55:08 | [diff] [blame] | 11 | #include "base/process.h" |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 12 | #include "content/common/content_param_traits_macros.h" |
[email protected] | 19a5c744 | 2011-10-21 20:00:41 | [diff] [blame] | 13 | #include "content/public/common/common_param_traits.h" |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 14 | #include "content/public/common/resource_response.h" |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 15 | #include "ipc/ipc_message_macros.h" |
[email protected] | a9344092d | 2013-02-27 00:56:45 | [diff] [blame] | 16 | #include "net/base/request_priority.h" |
[email protected] | 92a98df9 | 2013-06-06 02:47:42 | [diff] [blame] | 17 | #include "net/http/http_response_info.h" |
[email protected] | 748b0ad | 2013-06-27 08:00:47 | [diff] [blame] | 18 | #include "webkit/common/resource_request_body.h" |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 19 | |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 20 | #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_ |
| 21 | #define CONTENT_COMMON_RESOURCE_MESSAGES_H_ |
| 22 | |
[email protected] | ec29880 | 2013-03-27 16:45:07 | [diff] [blame] | 23 | namespace net { |
| 24 | struct LoadTimingInfo; |
| 25 | } |
| 26 | |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 27 | namespace webkit_glue { |
| 28 | struct ResourceDevToolsInfo; |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | namespace IPC { |
| 32 | |
| 33 | template <> |
| 34 | struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { |
| 35 | typedef scoped_refptr<net::HttpResponseHeaders> 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 | |
| 41 | template <> |
[email protected] | 2b4ae17 | 2013-07-11 01:46:20 | [diff] [blame] | 42 | struct CONTENT_EXPORT ParamTraits<webkit_common::DataElement> { |
| 43 | typedef webkit_common::DataElement param_type; |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 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 | |
| 49 | template <> |
| 50 | struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > { |
| 51 | typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> 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 | |
| 57 | template <> |
[email protected] | ec29880 | 2013-03-27 16:45:07 | [diff] [blame] | 58 | struct ParamTraits<net::LoadTimingInfo> { |
| 59 | typedef net::LoadTimingInfo param_type; |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 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 | template <> |
| 66 | struct ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> > { |
| 67 | typedef scoped_refptr<webkit_glue::ResourceRequestBody> param_type; |
| 68 | static void Write(Message* m, const param_type& p); |
| 69 | static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
| 70 | static void Log(const param_type& p, std::string* l); |
| 71 | }; |
| 72 | |
| 73 | } // namespace IPC |
| 74 | |
| 75 | #endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_ |
| 76 | |
| 77 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 78 | #define IPC_MESSAGE_START ResourceMsgStart |
[email protected] | 03ff5e5 | 2011-09-30 00:28:14 | [diff] [blame] | 79 | #undef IPC_MESSAGE_EXPORT |
| 80 | #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 81 | |
[email protected] | 92a98df9 | 2013-06-06 02:47:42 | [diff] [blame] | 82 | IPC_ENUM_TRAITS_MAX_VALUE( \ |
| 83 | net::HttpResponseInfo::ConnectionInfo, \ |
| 84 | net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1) |
| 85 | |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 86 | IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead) |
| 87 | IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) |
[email protected] | 2756a8e | 2012-09-07 18:24:29 | [diff] [blame] | 88 | IPC_STRUCT_TRAITS_MEMBER(error_code) |
[email protected] | d43d2e11 | 2012-08-07 01:10:19 | [diff] [blame] | 89 | IPC_STRUCT_TRAITS_MEMBER(request_start) |
| 90 | IPC_STRUCT_TRAITS_MEMBER(response_start) |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 91 | IPC_STRUCT_TRAITS_END() |
| 92 | |
| 93 | IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult) |
| 94 | IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead) |
| 95 | IPC_STRUCT_TRAITS_MEMBER(final_url) |
| 96 | IPC_STRUCT_TRAITS_MEMBER(data) |
| 97 | IPC_STRUCT_TRAITS_END() |
| 98 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 99 | IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo) |
| 100 | IPC_STRUCT_TRAITS_MEMBER(request_time) |
| 101 | IPC_STRUCT_TRAITS_MEMBER(response_time) |
| 102 | IPC_STRUCT_TRAITS_MEMBER(headers) |
| 103 | IPC_STRUCT_TRAITS_MEMBER(mime_type) |
| 104 | IPC_STRUCT_TRAITS_MEMBER(charset) |
| 105 | IPC_STRUCT_TRAITS_MEMBER(security_info) |
| 106 | IPC_STRUCT_TRAITS_MEMBER(content_length) |
[email protected] | dfd68217 | 2011-04-13 19:57:25 | [diff] [blame] | 107 | IPC_STRUCT_TRAITS_MEMBER(encoded_data_length) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 108 | IPC_STRUCT_TRAITS_MEMBER(appcache_id) |
| 109 | IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 110 | IPC_STRUCT_TRAITS_MEMBER(load_timing) |
| 111 | IPC_STRUCT_TRAITS_MEMBER(devtools_info) |
| 112 | IPC_STRUCT_TRAITS_MEMBER(download_file_path) |
| 113 | IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy) |
| 114 | IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated) |
| 115 | IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available) |
[email protected] | 92a98df9 | 2013-06-06 02:47:42 | [diff] [blame] | 116 | IPC_STRUCT_TRAITS_MEMBER(connection_info) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 117 | IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy) |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 118 | IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 119 | IPC_STRUCT_TRAITS_MEMBER(socket_address) |
| 120 | IPC_STRUCT_TRAITS_END() |
| 121 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 122 | // Parameters for a resource request. |
| 123 | IPC_STRUCT_BEGIN(ResourceHostMsg_Request) |
| 124 | // The request method: GET, POST, etc. |
| 125 | IPC_STRUCT_MEMBER(std::string, method) |
| 126 | |
| 127 | // The requested URL. |
| 128 | IPC_STRUCT_MEMBER(GURL, url) |
| 129 | |
| 130 | // Usually the URL of the document in the top-level window, which may be |
| 131 | // checked by the third-party cookie blocking policy. Leaving it empty may |
| 132 | // lead to undesired cookie blocking. Third-party cookie blocking can be |
| 133 | // bypassed by setting first_party_for_cookies = url, but this should ideally |
| 134 | // only be done if there really is no way to determine the correct value. |
| 135 | IPC_STRUCT_MEMBER(GURL, first_party_for_cookies) |
| 136 | |
| 137 | // The referrer to use (may be empty). |
| 138 | IPC_STRUCT_MEMBER(GURL, referrer) |
| 139 | |
[email protected] | d5a5034 | 2011-12-05 21:56:52 | [diff] [blame] | 140 | // The referrer policy to use. |
| 141 | IPC_STRUCT_MEMBER(WebKit::WebReferrerPolicy, referrer_policy) |
| 142 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 143 | // Additional HTTP request headers. |
| 144 | IPC_STRUCT_MEMBER(std::string, headers) |
| 145 | |
| 146 | // net::URLRequest load flags (0 by default). |
| 147 | IPC_STRUCT_MEMBER(int, load_flags) |
| 148 | |
| 149 | // Process ID from which this request originated, or zero if it originated |
| 150 | // in the renderer itself. |
| 151 | IPC_STRUCT_MEMBER(int, origin_pid) |
| 152 | |
| 153 | // What this resource load is for (main frame, sub-frame, sub-resource, |
| 154 | // object). |
| 155 | IPC_STRUCT_MEMBER(ResourceType::Type, resource_type) |
| 156 | |
[email protected] | 102ab68 | 2013-02-05 19:45:32 | [diff] [blame] | 157 | // The priority of this request. |
[email protected] | a9344092d | 2013-02-27 00:56:45 | [diff] [blame] | 158 | IPC_STRUCT_MEMBER(net::RequestPriority, priority) |
[email protected] | 102ab68 | 2013-02-05 19:45:32 | [diff] [blame] | 159 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 160 | // Used by plugin->browser requests to get the correct net::URLRequestContext. |
| 161 | IPC_STRUCT_MEMBER(uint32, request_context) |
| 162 | |
| 163 | // Indicates which frame (or worker context) the request is being loaded into, |
| 164 | // or kNoHostId. |
| 165 | IPC_STRUCT_MEMBER(int, appcache_host_id) |
| 166 | |
[email protected] | e3e402c | 2012-08-21 13:57:42 | [diff] [blame] | 167 | // Optional resource request body (may be null). |
| 168 | IPC_STRUCT_MEMBER(scoped_refptr<webkit_glue::ResourceRequestBody>, |
| 169 | request_body) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 170 | |
| 171 | IPC_STRUCT_MEMBER(bool, download_to_file) |
| 172 | |
| 173 | // True if the request was user initiated. |
| 174 | IPC_STRUCT_MEMBER(bool, has_user_gesture) |
[email protected] | 418da61 | 2011-07-21 19:01:52 | [diff] [blame] | 175 | |
| 176 | // True if |frame_id| is the main frame of a RenderView. |
| 177 | IPC_STRUCT_MEMBER(bool, is_main_frame) |
| 178 | |
| 179 | // Identifies the frame within the RenderView that sent the request. |
| 180 | // -1 if unknown / invalid. |
| 181 | IPC_STRUCT_MEMBER(int64, frame_id) |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 182 | |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 183 | // True if |parent_frame_id| is the main frame of a RenderView. |
| 184 | IPC_STRUCT_MEMBER(bool, parent_is_main_frame) |
| 185 | |
| 186 | // Identifies the parent frame of the frame that sent the request. |
| 187 | // -1 if unknown / invalid. |
| 188 | IPC_STRUCT_MEMBER(int64, parent_frame_id) |
| 189 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 190 | IPC_STRUCT_MEMBER(content::PageTransition, transition_type) |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 191 | |
| 192 | // The following two members identify a previous request that has been |
| 193 | // created before this navigation has been transferred to a new render view. |
| 194 | // This serves the purpose of recycling the old request. |
| 195 | // Unless this refers to a transferred navigation, these values are -1 and -1. |
| 196 | IPC_STRUCT_MEMBER(int, transferred_request_child_id) |
| 197 | IPC_STRUCT_MEMBER(int, transferred_request_request_id) |
[email protected] | 8074478 | 2012-05-04 01:47:00 | [diff] [blame] | 198 | |
| 199 | // Whether or not we should allow the URL to download. |
| 200 | IPC_STRUCT_MEMBER(bool, allow_download) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 201 | IPC_STRUCT_END() |
| 202 | |
| 203 | // Resource messages sent from the browser to the renderer. |
| 204 | |
| 205 | // Sent when the headers are available for a resource request. |
| 206 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse, |
| 207 | int /* request_id */, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 208 | content::ResourceResponseHead) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 209 | |
| 210 | // Sent when cached metadata from a resource request is ready. |
| 211 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata, |
| 212 | int /* request_id */, |
| 213 | std::vector<char> /* data */) |
| 214 | |
| 215 | // Sent as upload progress is being made. |
| 216 | IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress, |
| 217 | int /* request_id */, |
| 218 | int64 /* position */, |
| 219 | int64 /* size */) |
| 220 | |
| 221 | // Sent when the request has been redirected. The receiver is expected to |
| 222 | // respond with either a FollowRedirect message (if the redirect is to be |
| 223 | // followed) or a CancelRequest message (if it should not be followed). |
| 224 | IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, |
| 225 | int /* request_id */, |
| 226 | GURL /* new_url */, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 227 | content::ResourceResponseHead) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 228 | |
[email protected] | f0fa1ab | 2012-09-18 06:28:38 | [diff] [blame] | 229 | // Sent to set the shared memory buffer to be used to transmit response data to |
| 230 | // the renderer. Subsequent DataReceived messages refer to byte ranges in the |
| 231 | // shared memory buffer. The shared memory buffer should be retained by the |
| 232 | // renderer until the resource request completes. |
| 233 | // |
| 234 | // NOTE: The shared memory handle should already be mapped into the process |
| 235 | // that receives this message. |
| 236 | // |
[email protected] | 9d9387e | 2013-01-12 16:55:08 | [diff] [blame] | 237 | // TODO(darin): The |renderer_pid| parameter is just a temporary parameter, |
| 238 | // added to help in debugging crbug/160401. |
| 239 | // |
| 240 | IPC_MESSAGE_ROUTED4(ResourceMsg_SetDataBuffer, |
[email protected] | f0fa1ab | 2012-09-18 06:28:38 | [diff] [blame] | 241 | int /* request_id */, |
| 242 | base::SharedMemoryHandle /* shm_handle */, |
[email protected] | 9d9387e | 2013-01-12 16:55:08 | [diff] [blame] | 243 | int /* shm_size */, |
| 244 | base::ProcessId /* renderer_pid */) |
[email protected] | f0fa1ab | 2012-09-18 06:28:38 | [diff] [blame] | 245 | |
| 246 | // Sent when some data from a resource request is ready. The data offset and |
| 247 | // length specify a byte range into the shared memory buffer provided by the |
| 248 | // SetDataBuffer message. |
[email protected] | 8bd0de7 | 2011-04-08 18:52:10 | [diff] [blame] | 249 | IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 250 | int /* request_id */, |
[email protected] | f0fa1ab | 2012-09-18 06:28:38 | [diff] [blame] | 251 | int /* data_offset */, |
| 252 | int /* data_length */, |
[email protected] | dfd68217 | 2011-04-13 19:57:25 | [diff] [blame] | 253 | int /* encoded_data_length */) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 254 | |
| 255 | // Sent when some data from a resource request has been downloaded to |
| 256 | // file. This is only called in the 'download_to_file' case and replaces |
| 257 | // ResourceMsg_DataReceived in the call sequence in that case. |
| 258 | IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded, |
| 259 | int /* request_id */, |
| 260 | int /* data_len */) |
| 261 | |
| 262 | // Sent when the request has been completed. |
[email protected] | 2756a8e | 2012-09-07 18:24:29 | [diff] [blame] | 263 | IPC_MESSAGE_ROUTED5(ResourceMsg_RequestComplete, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 264 | int /* request_id */, |
[email protected] | 2756a8e | 2012-09-07 18:24:29 | [diff] [blame] | 265 | int /* error_code */, |
| 266 | bool /* was_ignored_by_handler */, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 267 | std::string /* security info */, |
[email protected] | cb8a8742 | 2011-12-16 01:15:57 | [diff] [blame] | 268 | base::TimeTicks /* completion_time */) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 269 | |
| 270 | // Resource messages sent from the renderer to the browser. |
| 271 | |
| 272 | // Makes a resource request via the browser. |
| 273 | IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource, |
| 274 | int /* request_id */, |
| 275 | ResourceHostMsg_Request) |
| 276 | |
| 277 | // Cancels a resource request with the ID given as the parameter. |
| 278 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest, |
| 279 | int /* request_id */) |
| 280 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 281 | // Follows a redirect that occured for the resource request with the ID given |
| 282 | // as the parameter. |
| 283 | IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect, |
| 284 | int /* request_id */, |
| 285 | bool /* has_new_first_party_for_cookies */, |
| 286 | GURL /* new_first_party_for_cookies */) |
| 287 | |
| 288 | // Makes a synchronous resource request via the browser. |
| 289 | IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, |
| 290 | int /* request_id */, |
| 291 | ResourceHostMsg_Request, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 292 | content::SyncLoadResult) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 293 | |
| 294 | // Sent when the renderer process is done processing a DataReceived |
| 295 | // message. |
| 296 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK, |
| 297 | int /* request_id */) |
| 298 | |
| 299 | // Sent when the renderer has processed a DataDownloaded message. |
| 300 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK, |
| 301 | int /* request_id */) |
| 302 | |
| 303 | // Sent by the renderer process to acknowledge receipt of a |
| 304 | // UploadProgress message. |
| 305 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK, |
| 306 | int /* request_id */) |
| 307 | |
| 308 | // Sent when the renderer process deletes a resource loader. |
| 309 | IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile, |
| 310 | int /* request_id */) |
[email protected] | a9344092d | 2013-02-27 00:56:45 | [diff] [blame] | 311 | |
| 312 | // Sent by the renderer when a resource request changes priority. |
| 313 | IPC_MESSAGE_ROUTED2(ResourceHostMsg_DidChangePriority, |
| 314 | int /* request_id */, |
| 315 | net::RequestPriority) |