[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" |
| 10 | #include "ipc/ipc_message_macros.h" |
| 11 | #include "net/base/upload_data.h" |
| 12 | |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 13 | #define IPC_MESSAGE_START ResourceMsgStart |
| 14 | |
| 15 | IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo) |
| 16 | IPC_STRUCT_TRAITS_MEMBER(request_time) |
| 17 | IPC_STRUCT_TRAITS_MEMBER(response_time) |
| 18 | IPC_STRUCT_TRAITS_MEMBER(headers) |
| 19 | IPC_STRUCT_TRAITS_MEMBER(mime_type) |
| 20 | IPC_STRUCT_TRAITS_MEMBER(charset) |
| 21 | IPC_STRUCT_TRAITS_MEMBER(security_info) |
| 22 | IPC_STRUCT_TRAITS_MEMBER(content_length) |
[email protected] | 8bd0de7 | 2011-04-08 18:52:10 | [diff] [blame^] | 23 | IPC_STRUCT_TRAITS_MEMBER(raw_data_length) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 24 | IPC_STRUCT_TRAITS_MEMBER(appcache_id) |
| 25 | IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url) |
| 26 | IPC_STRUCT_TRAITS_MEMBER(connection_id) |
| 27 | IPC_STRUCT_TRAITS_MEMBER(connection_reused) |
| 28 | IPC_STRUCT_TRAITS_MEMBER(load_timing) |
| 29 | IPC_STRUCT_TRAITS_MEMBER(devtools_info) |
| 30 | IPC_STRUCT_TRAITS_MEMBER(download_file_path) |
| 31 | IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy) |
| 32 | IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated) |
| 33 | IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available) |
| 34 | IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy) |
| 35 | IPC_STRUCT_TRAITS_MEMBER(socket_address) |
| 36 | IPC_STRUCT_TRAITS_END() |
| 37 | |
| 38 | IPC_STRUCT_TRAITS_BEGIN(ResourceResponseHead) |
| 39 | IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) |
| 40 | IPC_STRUCT_TRAITS_MEMBER(status) |
| 41 | IPC_STRUCT_TRAITS_END() |
| 42 | |
| 43 | IPC_STRUCT_TRAITS_BEGIN(SyncLoadResult) |
| 44 | IPC_STRUCT_TRAITS_PARENT(ResourceResponseHead) |
| 45 | IPC_STRUCT_TRAITS_MEMBER(final_url) |
| 46 | IPC_STRUCT_TRAITS_MEMBER(data) |
| 47 | IPC_STRUCT_TRAITS_END() |
| 48 | |
| 49 | // Parameters for a resource request. |
| 50 | IPC_STRUCT_BEGIN(ResourceHostMsg_Request) |
| 51 | // The request method: GET, POST, etc. |
| 52 | IPC_STRUCT_MEMBER(std::string, method) |
| 53 | |
| 54 | // The requested URL. |
| 55 | IPC_STRUCT_MEMBER(GURL, url) |
| 56 | |
| 57 | // Usually the URL of the document in the top-level window, which may be |
| 58 | // checked by the third-party cookie blocking policy. Leaving it empty may |
| 59 | // lead to undesired cookie blocking. Third-party cookie blocking can be |
| 60 | // bypassed by setting first_party_for_cookies = url, but this should ideally |
| 61 | // only be done if there really is no way to determine the correct value. |
| 62 | IPC_STRUCT_MEMBER(GURL, first_party_for_cookies) |
| 63 | |
| 64 | // The referrer to use (may be empty). |
| 65 | IPC_STRUCT_MEMBER(GURL, referrer) |
| 66 | |
| 67 | // Additional HTTP request headers. |
| 68 | IPC_STRUCT_MEMBER(std::string, headers) |
| 69 | |
| 70 | // net::URLRequest load flags (0 by default). |
| 71 | IPC_STRUCT_MEMBER(int, load_flags) |
| 72 | |
| 73 | // Process ID from which this request originated, or zero if it originated |
| 74 | // in the renderer itself. |
| 75 | IPC_STRUCT_MEMBER(int, origin_pid) |
| 76 | |
| 77 | // What this resource load is for (main frame, sub-frame, sub-resource, |
| 78 | // object). |
| 79 | IPC_STRUCT_MEMBER(ResourceType::Type, resource_type) |
| 80 | |
| 81 | // Used by plugin->browser requests to get the correct net::URLRequestContext. |
| 82 | IPC_STRUCT_MEMBER(uint32, request_context) |
| 83 | |
| 84 | // Indicates which frame (or worker context) the request is being loaded into, |
| 85 | // or kNoHostId. |
| 86 | IPC_STRUCT_MEMBER(int, appcache_host_id) |
| 87 | |
| 88 | // Optional upload data (may be null). |
| 89 | IPC_STRUCT_MEMBER(scoped_refptr<net::UploadData>, upload_data) |
| 90 | |
| 91 | IPC_STRUCT_MEMBER(bool, download_to_file) |
| 92 | |
| 93 | // True if the request was user initiated. |
| 94 | IPC_STRUCT_MEMBER(bool, has_user_gesture) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 95 | IPC_STRUCT_END() |
| 96 | |
| 97 | // Resource messages sent from the browser to the renderer. |
| 98 | |
| 99 | // Sent when the headers are available for a resource request. |
| 100 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse, |
| 101 | int /* request_id */, |
| 102 | ResourceResponseHead) |
| 103 | |
| 104 | // Sent when cached metadata from a resource request is ready. |
| 105 | IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata, |
| 106 | int /* request_id */, |
| 107 | std::vector<char> /* data */) |
| 108 | |
| 109 | // Sent as upload progress is being made. |
| 110 | IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress, |
| 111 | int /* request_id */, |
| 112 | int64 /* position */, |
| 113 | int64 /* size */) |
| 114 | |
| 115 | // Sent when the request has been redirected. The receiver is expected to |
| 116 | // respond with either a FollowRedirect message (if the redirect is to be |
| 117 | // followed) or a CancelRequest message (if it should not be followed). |
| 118 | IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, |
| 119 | int /* request_id */, |
| 120 | GURL /* new_url */, |
| 121 | ResourceResponseHead) |
| 122 | |
| 123 | // Sent when some data from a resource request is ready. The handle should |
| 124 | // already be mapped into the process that receives this message. |
[email protected] | 8bd0de7 | 2011-04-08 18:52:10 | [diff] [blame^] | 125 | IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived, |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 126 | int /* request_id */, |
| 127 | base::SharedMemoryHandle /* data */, |
[email protected] | 8bd0de7 | 2011-04-08 18:52:10 | [diff] [blame^] | 128 | int /* data_len */, |
| 129 | int /* raw_data_length */) |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 130 | |
| 131 | // Sent when some data from a resource request has been downloaded to |
| 132 | // file. This is only called in the 'download_to_file' case and replaces |
| 133 | // ResourceMsg_DataReceived in the call sequence in that case. |
| 134 | IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded, |
| 135 | int /* request_id */, |
| 136 | int /* data_len */) |
| 137 | |
| 138 | // Sent when the request has been completed. |
| 139 | IPC_MESSAGE_ROUTED4(ResourceMsg_RequestComplete, |
| 140 | int /* request_id */, |
| 141 | net::URLRequestStatus /* status */, |
| 142 | std::string /* security info */, |
| 143 | base::Time /* completion_time */) |
| 144 | |
| 145 | // Resource messages sent from the renderer to the browser. |
| 146 | |
| 147 | // Makes a resource request via the browser. |
| 148 | IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource, |
| 149 | int /* request_id */, |
| 150 | ResourceHostMsg_Request) |
| 151 | |
| 152 | // Cancels a resource request with the ID given as the parameter. |
| 153 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest, |
| 154 | int /* request_id */) |
| 155 | |
| 156 | // Follows a redirect that occured for the resource request with the ID given |
| 157 | // as the parameter. |
| 158 | IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect, |
| 159 | int /* request_id */, |
| 160 | bool /* has_new_first_party_for_cookies */, |
| 161 | GURL /* new_first_party_for_cookies */) |
| 162 | |
| 163 | // Makes a synchronous resource request via the browser. |
| 164 | IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, |
| 165 | int /* request_id */, |
| 166 | ResourceHostMsg_Request, |
| 167 | SyncLoadResult) |
| 168 | |
| 169 | // Sent when the renderer process is done processing a DataReceived |
| 170 | // message. |
| 171 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK, |
| 172 | int /* request_id */) |
| 173 | |
| 174 | // Sent when the renderer has processed a DataDownloaded message. |
| 175 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK, |
| 176 | int /* request_id */) |
| 177 | |
| 178 | // Sent by the renderer process to acknowledge receipt of a |
| 179 | // UploadProgress message. |
| 180 | IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK, |
| 181 | int /* request_id */) |
| 182 | |
| 183 | // Sent when the renderer process deletes a resource loader. |
| 184 | IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile, |
| 185 | int /* request_id */) |