[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] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 6 | |
[email protected] | e503a12 | 2011-03-17 18:20:52 | [diff] [blame] | 7 | // Multiply-included message file, hence no include guard. |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 8 | #include "base/shared_memory.h" |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame^] | 9 | #include "content/common/content_param_traits_macros.h" |
[email protected] | 19a5c744 | 2011-10-21 20:00:41 | [diff] [blame] | 10 | #include "content/public/common/common_param_traits.h" |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 11 | #include "content/public/common/resource_response.h" |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 12 | #include "ipc/ipc_message_macros.h" |
[email protected] | e3e402c | 2012-08-21 13:57:42 | [diff] [blame] | 13 | #include "webkit/glue/resource_request_body.h" |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 14 | |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame^] | 15 | #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_ |
| 16 | #define CONTENT_COMMON_RESOURCE_MESSAGES_H_ |
| 17 | |
| 18 | namespace webkit_glue { |
| 19 | struct ResourceDevToolsInfo; |
| 20 | struct ResourceLoadTimingInfo; |
| 21 | } |
| 22 | |
| 23 | namespace IPC { |
| 24 | |
| 25 | template <> |
| 26 | struct 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 | |
| 33 | template <> |
| 34 | struct 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 | |
| 41 | template <> |
| 42 | struct 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 | |
| 49 | template <> |
| 50 | struct 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 | |
| 57 | template <> |
| 58 | struct 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] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 70 | #define IPC_MESSAGE_START ResourceMsgStart |
[email protected] | 03ff5e5 | 2011-09-30 00:28:14 | [diff] [blame] | 71 | #undef IPC_MESSAGE_EXPORT |
| 72 | #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 73 | |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 74 | IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead) |
| 75 | IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) |
[email protected] | 2756a8e | 2012-09-07 18:24:29 | [diff] [blame] | 76 | IPC_STRUCT_TRAITS_MEMBER(error_code) |
[email protected] | d43d2e11 | 2012-08-07 01:10:19 | [diff] [blame] | 77 | IPC_STRUCT_TRAITS_MEMBER(request_start) |
| 78 | IPC_STRUCT_TRAITS_MEMBER(response_start) |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 79 | IPC_STRUCT_TRAITS_END() |
| 80 | |
| 81 | IPC_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) |
| 85 | IPC_STRUCT_TRAITS_END() |
| 86 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 87 | IPC_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] | dfd68217 | 2011-04-13 19:57:25 | [diff] [blame] | 95 | IPC_STRUCT_TRAITS_MEMBER(encoded_data_length) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 96 | 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] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 107 | IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 108 | IPC_STRUCT_TRAITS_MEMBER(socket_address) |
| 109 | IPC_STRUCT_TRAITS_END() |
| 110 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 111 | // Parameters for a resource request. |
| 112 | IPC_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] | d5a5034 | 2011-12-05 21:56:52 | [diff] [blame] | 129 | // The referrer policy to use. |
| 130 | IPC_STRUCT_MEMBER(WebKit::WebReferrerPolicy, referrer_policy) |
| 131 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 132 | // 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] | e3e402c | 2012-08-21 13:57:42 | [diff] [blame] | 153 | // Optional resource request body (may be null). |
| 154 | IPC_STRUCT_MEMBER(scoped_refptr<webkit_glue::ResourceRequestBody>, |
| 155 | request_body) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 156 | |
| 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] | 418da61 | 2011-07-21 19:01:52 | [diff] [blame] | 161 | |
| 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] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 168 | |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 169 | // 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] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 176 | IPC_STRUCT_MEMBER(content::PageTransition, transition_type) |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 177 | |
| 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] | 8074478 | 2012-05-04 01:47:00 | [diff] [blame] | 184 | |
| 185 | // Whether or not we should allow the URL to download. |
| 186 | IPC_STRUCT_MEMBER(bool, allow_download) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 187 | IPC_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. |
| 192 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse, |
| 193 | int /* request_id */, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 194 | content::ResourceResponseHead) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 195 | |
| 196 | // Sent when cached metadata from a resource request is ready. |
| 197 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata, |
| 198 | int /* request_id */, |
| 199 | std::vector<char> /* data */) |
| 200 | |
| 201 | // Sent as upload progress is being made. |
| 202 | IPC_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). |
| 210 | IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, |
| 211 | int /* request_id */, |
| 212 | GURL /* new_url */, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 213 | content::ResourceResponseHead) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 214 | |
[email protected] | f0fa1ab | 2012-09-18 06:28:38 | [diff] [blame] | 215 | // 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 | // |
| 223 | IPC_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] | 8bd0de7 | 2011-04-08 18:52:10 | [diff] [blame] | 231 | IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 232 | int /* request_id */, |
[email protected] | f0fa1ab | 2012-09-18 06:28:38 | [diff] [blame] | 233 | int /* data_offset */, |
| 234 | int /* data_length */, |
[email protected] | dfd68217 | 2011-04-13 19:57:25 | [diff] [blame] | 235 | int /* encoded_data_length */) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 236 | |
| 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. |
| 240 | IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded, |
| 241 | int /* request_id */, |
| 242 | int /* data_len */) |
| 243 | |
| 244 | // Sent when the request has been completed. |
[email protected] | 2756a8e | 2012-09-07 18:24:29 | [diff] [blame] | 245 | IPC_MESSAGE_ROUTED5(ResourceMsg_RequestComplete, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 246 | int /* request_id */, |
[email protected] | 2756a8e | 2012-09-07 18:24:29 | [diff] [blame] | 247 | int /* error_code */, |
| 248 | bool /* was_ignored_by_handler */, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 249 | std::string /* security info */, |
[email protected] | cb8a8742 | 2011-12-16 01:15:57 | [diff] [blame] | 250 | base::TimeTicks /* completion_time */) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 251 | |
| 252 | // Resource messages sent from the renderer to the browser. |
| 253 | |
| 254 | // Makes a resource request via the browser. |
| 255 | IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource, |
| 256 | int /* request_id */, |
| 257 | ResourceHostMsg_Request) |
| 258 | |
| 259 | // Cancels a resource request with the ID given as the parameter. |
| 260 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest, |
| 261 | int /* request_id */) |
| 262 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 263 | // Follows a redirect that occured for the resource request with the ID given |
| 264 | // as the parameter. |
| 265 | IPC_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. |
| 271 | IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, |
| 272 | int /* request_id */, |
| 273 | ResourceHostMsg_Request, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 274 | content::SyncLoadResult) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 275 | |
| 276 | // Sent when the renderer process is done processing a DataReceived |
| 277 | // message. |
| 278 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK, |
| 279 | int /* request_id */) |
| 280 | |
| 281 | // Sent when the renderer has processed a DataDownloaded message. |
| 282 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK, |
| 283 | int /* request_id */) |
| 284 | |
| 285 | // Sent by the renderer process to acknowledge receipt of a |
| 286 | // UploadProgress message. |
| 287 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK, |
| 288 | int /* request_id */) |
| 289 | |
| 290 | // Sent when the renderer process deletes a resource loader. |
| 291 | IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile, |
| 292 | int /* request_id */) |