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