[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 1 | // Copyright (c) 2011 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. |
| 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] | 19a5c744 | 2011-10-21 20:00:41 | [diff] [blame] | 9 | #include "content/public/common/common_param_traits.h" |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 10 | #include "content/public/common/resource_response.h" |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 11 | #include "ipc/ipc_message_macros.h" |
| 12 | #include "net/base/upload_data.h" |
| 13 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 14 | #define IPC_MESSAGE_START ResourceMsgStart |
[email protected] | 03ff5e5 | 2011-09-30 00:28:14 | [diff] [blame] | 15 | #undef IPC_MESSAGE_EXPORT |
| 16 | #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 17 | |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 18 | IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead) |
| 19 | IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) |
| 20 | IPC_STRUCT_TRAITS_MEMBER(status) |
| 21 | IPC_STRUCT_TRAITS_END() |
| 22 | |
| 23 | IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult) |
| 24 | IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead) |
| 25 | IPC_STRUCT_TRAITS_MEMBER(final_url) |
| 26 | IPC_STRUCT_TRAITS_MEMBER(data) |
| 27 | IPC_STRUCT_TRAITS_END() |
| 28 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 29 | IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo) |
| 30 | IPC_STRUCT_TRAITS_MEMBER(request_time) |
| 31 | IPC_STRUCT_TRAITS_MEMBER(response_time) |
| 32 | IPC_STRUCT_TRAITS_MEMBER(headers) |
| 33 | IPC_STRUCT_TRAITS_MEMBER(mime_type) |
| 34 | IPC_STRUCT_TRAITS_MEMBER(charset) |
| 35 | IPC_STRUCT_TRAITS_MEMBER(security_info) |
| 36 | IPC_STRUCT_TRAITS_MEMBER(content_length) |
[email protected] | dfd68217 | 2011-04-13 19:57:25 | [diff] [blame] | 37 | IPC_STRUCT_TRAITS_MEMBER(encoded_data_length) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 38 | IPC_STRUCT_TRAITS_MEMBER(appcache_id) |
| 39 | IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url) |
| 40 | IPC_STRUCT_TRAITS_MEMBER(connection_id) |
| 41 | IPC_STRUCT_TRAITS_MEMBER(connection_reused) |
| 42 | IPC_STRUCT_TRAITS_MEMBER(load_timing) |
| 43 | IPC_STRUCT_TRAITS_MEMBER(devtools_info) |
| 44 | IPC_STRUCT_TRAITS_MEMBER(download_file_path) |
| 45 | IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy) |
| 46 | IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated) |
| 47 | IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available) |
| 48 | IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy) |
| 49 | IPC_STRUCT_TRAITS_MEMBER(socket_address) |
| 50 | IPC_STRUCT_TRAITS_END() |
| 51 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 52 | // Parameters for a resource request. |
| 53 | IPC_STRUCT_BEGIN(ResourceHostMsg_Request) |
| 54 | // The request method: GET, POST, etc. |
| 55 | IPC_STRUCT_MEMBER(std::string, method) |
| 56 | |
| 57 | // The requested URL. |
| 58 | IPC_STRUCT_MEMBER(GURL, url) |
| 59 | |
| 60 | // Usually the URL of the document in the top-level window, which may be |
| 61 | // checked by the third-party cookie blocking policy. Leaving it empty may |
| 62 | // lead to undesired cookie blocking. Third-party cookie blocking can be |
| 63 | // bypassed by setting first_party_for_cookies = url, but this should ideally |
| 64 | // only be done if there really is no way to determine the correct value. |
| 65 | IPC_STRUCT_MEMBER(GURL, first_party_for_cookies) |
| 66 | |
| 67 | // The referrer to use (may be empty). |
| 68 | IPC_STRUCT_MEMBER(GURL, referrer) |
| 69 | |
[email protected] | d5a5034 | 2011-12-05 21:56:52 | [diff] [blame] | 70 | // The referrer policy to use. |
| 71 | IPC_STRUCT_MEMBER(WebKit::WebReferrerPolicy, referrer_policy) |
| 72 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 73 | // Additional HTTP request headers. |
| 74 | IPC_STRUCT_MEMBER(std::string, headers) |
| 75 | |
| 76 | // net::URLRequest load flags (0 by default). |
| 77 | IPC_STRUCT_MEMBER(int, load_flags) |
| 78 | |
| 79 | // Process ID from which this request originated, or zero if it originated |
| 80 | // in the renderer itself. |
| 81 | IPC_STRUCT_MEMBER(int, origin_pid) |
| 82 | |
| 83 | // What this resource load is for (main frame, sub-frame, sub-resource, |
| 84 | // object). |
| 85 | IPC_STRUCT_MEMBER(ResourceType::Type, resource_type) |
| 86 | |
| 87 | // Used by plugin->browser requests to get the correct net::URLRequestContext. |
| 88 | IPC_STRUCT_MEMBER(uint32, request_context) |
| 89 | |
| 90 | // Indicates which frame (or worker context) the request is being loaded into, |
| 91 | // or kNoHostId. |
| 92 | IPC_STRUCT_MEMBER(int, appcache_host_id) |
| 93 | |
| 94 | // Optional upload data (may be null). |
| 95 | IPC_STRUCT_MEMBER(scoped_refptr<net::UploadData>, upload_data) |
| 96 | |
| 97 | IPC_STRUCT_MEMBER(bool, download_to_file) |
| 98 | |
| 99 | // True if the request was user initiated. |
| 100 | IPC_STRUCT_MEMBER(bool, has_user_gesture) |
[email protected] | 418da61 | 2011-07-21 19:01:52 | [diff] [blame] | 101 | |
| 102 | // True if |frame_id| is the main frame of a RenderView. |
| 103 | IPC_STRUCT_MEMBER(bool, is_main_frame) |
| 104 | |
| 105 | // Identifies the frame within the RenderView that sent the request. |
| 106 | // -1 if unknown / invalid. |
| 107 | IPC_STRUCT_MEMBER(int64, frame_id) |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 108 | |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 109 | // True if |parent_frame_id| is the main frame of a RenderView. |
| 110 | IPC_STRUCT_MEMBER(bool, parent_is_main_frame) |
| 111 | |
| 112 | // Identifies the parent frame of the frame that sent the request. |
| 113 | // -1 if unknown / invalid. |
| 114 | IPC_STRUCT_MEMBER(int64, parent_frame_id) |
| 115 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 116 | IPC_STRUCT_MEMBER(content::PageTransition, transition_type) |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 117 | |
| 118 | // The following two members identify a previous request that has been |
| 119 | // created before this navigation has been transferred to a new render view. |
| 120 | // This serves the purpose of recycling the old request. |
| 121 | // Unless this refers to a transferred navigation, these values are -1 and -1. |
| 122 | IPC_STRUCT_MEMBER(int, transferred_request_child_id) |
| 123 | IPC_STRUCT_MEMBER(int, transferred_request_request_id) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 124 | IPC_STRUCT_END() |
| 125 | |
| 126 | // Resource messages sent from the browser to the renderer. |
| 127 | |
| 128 | // Sent when the headers are available for a resource request. |
| 129 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse, |
| 130 | int /* request_id */, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 131 | content::ResourceResponseHead) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 132 | |
| 133 | // Sent when cached metadata from a resource request is ready. |
| 134 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata, |
| 135 | int /* request_id */, |
| 136 | std::vector<char> /* data */) |
| 137 | |
| 138 | // Sent as upload progress is being made. |
| 139 | IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress, |
| 140 | int /* request_id */, |
| 141 | int64 /* position */, |
| 142 | int64 /* size */) |
| 143 | |
| 144 | // Sent when the request has been redirected. The receiver is expected to |
| 145 | // respond with either a FollowRedirect message (if the redirect is to be |
| 146 | // followed) or a CancelRequest message (if it should not be followed). |
| 147 | IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, |
| 148 | int /* request_id */, |
| 149 | GURL /* new_url */, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 150 | content::ResourceResponseHead) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 151 | |
| 152 | // Sent when some data from a resource request is ready. The handle should |
| 153 | // already be mapped into the process that receives this message. |
[email protected] | 8bd0de7 | 2011-04-08 18:52:10 | [diff] [blame] | 154 | IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 155 | int /* request_id */, |
| 156 | base::SharedMemoryHandle /* data */, |
[email protected] | 8bd0de7 | 2011-04-08 18:52:10 | [diff] [blame] | 157 | int /* data_len */, |
[email protected] | dfd68217 | 2011-04-13 19:57:25 | [diff] [blame] | 158 | int /* encoded_data_length */) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 159 | |
| 160 | // Sent when some data from a resource request has been downloaded to |
| 161 | // file. This is only called in the 'download_to_file' case and replaces |
| 162 | // ResourceMsg_DataReceived in the call sequence in that case. |
| 163 | IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded, |
| 164 | int /* request_id */, |
| 165 | int /* data_len */) |
| 166 | |
| 167 | // Sent when the request has been completed. |
| 168 | IPC_MESSAGE_ROUTED4(ResourceMsg_RequestComplete, |
| 169 | int /* request_id */, |
| 170 | net::URLRequestStatus /* status */, |
| 171 | std::string /* security info */, |
[email protected] | cb8a8742 | 2011-12-16 01:15:57 | [diff] [blame^] | 172 | base::TimeTicks /* completion_time */) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 173 | |
| 174 | // Resource messages sent from the renderer to the browser. |
| 175 | |
| 176 | // Makes a resource request via the browser. |
| 177 | IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource, |
| 178 | int /* request_id */, |
| 179 | ResourceHostMsg_Request) |
| 180 | |
| 181 | // Cancels a resource request with the ID given as the parameter. |
| 182 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest, |
| 183 | int /* request_id */) |
| 184 | |
[email protected] | b00ba70 | 2011-08-17 01:41:03 | [diff] [blame] | 185 | // Sets a new routing id for the resource request with the ID given as the |
| 186 | // parameter. This happens when a pending request is transferred to another |
| 187 | // page. |
| 188 | IPC_MESSAGE_CONTROL2(ResourceHostMsg_TransferRequestToNewPage, |
| 189 | int /* new routing_id */, |
| 190 | int /* request_id */) |
| 191 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 192 | // Follows a redirect that occured for the resource request with the ID given |
| 193 | // as the parameter. |
| 194 | IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect, |
| 195 | int /* request_id */, |
| 196 | bool /* has_new_first_party_for_cookies */, |
| 197 | GURL /* new_first_party_for_cookies */) |
| 198 | |
| 199 | // Makes a synchronous resource request via the browser. |
| 200 | IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, |
| 201 | int /* request_id */, |
| 202 | ResourceHostMsg_Request, |
[email protected] | 2336ffe | 2011-11-24 01:23:34 | [diff] [blame] | 203 | content::SyncLoadResult) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 204 | |
| 205 | // Sent when the renderer process is done processing a DataReceived |
| 206 | // message. |
| 207 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK, |
| 208 | int /* request_id */) |
| 209 | |
| 210 | // Sent when the renderer has processed a DataDownloaded message. |
| 211 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK, |
| 212 | int /* request_id */) |
| 213 | |
| 214 | // Sent by the renderer process to acknowledge receipt of a |
| 215 | // UploadProgress message. |
| 216 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK, |
| 217 | int /* request_id */) |
| 218 | |
| 219 | // Sent when the renderer process deletes a resource loader. |
| 220 | IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile, |
| 221 | int /* request_id */) |