Removing uses of X11 native key events.
[chromium-blink-merge.git] / content / common / resource_messages.h
blob161fea88ce466502ceb5604235dacb97cf7e85be
1 // Copyright (c) 2012 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.
5 // IPC messages for resource loading.
6 //
7 // NOTE: All messages must send an |int request_id| as their first parameter.
9 // Multiply-included message file, hence no include guard.
10 #include "base/memory/shared_memory.h"
11 #include "base/process/process.h"
12 #include "content/common/content_param_traits_macros.h"
13 #include "content/common/resource_request_body.h"
14 #include "content/public/common/common_param_traits.h"
15 #include "content/public/common/resource_response.h"
16 #include "ipc/ipc_message_macros.h"
17 #include "net/base/request_priority.h"
18 #include "net/http/http_response_info.h"
19 #include "net/url_request/redirect_info.h"
21 #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
22 #define CONTENT_COMMON_RESOURCE_MESSAGES_H_
24 namespace net {
25 struct LoadTimingInfo;
28 namespace content {
29 struct ResourceDevToolsInfo;
32 namespace IPC {
34 template <>
35 struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
36 typedef scoped_refptr<net::HttpResponseHeaders> param_type;
37 static void Write(Message* m, const param_type& p);
38 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
39 static void Log(const param_type& p, std::string* l);
42 template <>
43 struct CONTENT_EXPORT ParamTraits<storage::DataElement> {
44 typedef storage::DataElement param_type;
45 static void Write(Message* m, const param_type& p);
46 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
47 static void Log(const param_type& p, std::string* l);
50 template <>
51 struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
52 typedef scoped_refptr<content::ResourceDevToolsInfo> param_type;
53 static void Write(Message* m, const param_type& p);
54 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
55 static void Log(const param_type& p, std::string* l);
58 template <>
59 struct ParamTraits<net::LoadTimingInfo> {
60 typedef net::LoadTimingInfo param_type;
61 static void Write(Message* m, const param_type& p);
62 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
63 static void Log(const param_type& p, std::string* l);
66 template <>
67 struct ParamTraits<scoped_refptr<content::ResourceRequestBody> > {
68 typedef scoped_refptr<content::ResourceRequestBody> param_type;
69 static void Write(Message* m, const param_type& p);
70 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
71 static void Log(const param_type& p, std::string* l);
74 } // namespace IPC
76 #endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
79 #define IPC_MESSAGE_START ResourceMsgStart
80 #undef IPC_MESSAGE_EXPORT
81 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
83 IPC_ENUM_TRAITS_MAX_VALUE( \
84 net::HttpResponseInfo::ConnectionInfo, \
85 net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
87 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
88 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo)
89 IPC_STRUCT_TRAITS_MEMBER(request_start)
90 IPC_STRUCT_TRAITS_MEMBER(response_start)
91 IPC_STRUCT_TRAITS_END()
93 IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
94 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
95 IPC_STRUCT_TRAITS_MEMBER(error_code)
96 IPC_STRUCT_TRAITS_MEMBER(final_url)
97 IPC_STRUCT_TRAITS_MEMBER(data)
98 IPC_STRUCT_TRAITS_END()
100 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo)
101 IPC_STRUCT_TRAITS_MEMBER(request_time)
102 IPC_STRUCT_TRAITS_MEMBER(response_time)
103 IPC_STRUCT_TRAITS_MEMBER(headers)
104 IPC_STRUCT_TRAITS_MEMBER(mime_type)
105 IPC_STRUCT_TRAITS_MEMBER(charset)
106 IPC_STRUCT_TRAITS_MEMBER(security_info)
107 IPC_STRUCT_TRAITS_MEMBER(content_length)
108 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
109 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
110 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
111 IPC_STRUCT_TRAITS_MEMBER(load_timing)
112 IPC_STRUCT_TRAITS_MEMBER(devtools_info)
113 IPC_STRUCT_TRAITS_MEMBER(download_file_path)
114 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
115 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
116 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
117 IPC_STRUCT_TRAITS_MEMBER(connection_info)
118 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
119 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
120 IPC_STRUCT_TRAITS_MEMBER(socket_address)
121 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker)
122 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker)
123 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_start)
124 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_ready)
125 IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_end)
126 IPC_STRUCT_TRAITS_END()
128 IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo)
129 IPC_STRUCT_TRAITS_MEMBER(status_code)
130 IPC_STRUCT_TRAITS_MEMBER(new_method)
131 IPC_STRUCT_TRAITS_MEMBER(new_url)
132 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies)
133 IPC_STRUCT_TRAITS_MEMBER(new_referrer)
134 IPC_STRUCT_TRAITS_END()
136 // Parameters for a resource request.
137 IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
138 // The request method: GET, POST, etc.
139 IPC_STRUCT_MEMBER(std::string, method)
141 // The requested URL.
142 IPC_STRUCT_MEMBER(GURL, url)
144 // Usually the URL of the document in the top-level window, which may be
145 // checked by the third-party cookie blocking policy. Leaving it empty may
146 // lead to undesired cookie blocking. Third-party cookie blocking can be
147 // bypassed by setting first_party_for_cookies = url, but this should ideally
148 // only be done if there really is no way to determine the correct value.
149 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
151 // The referrer to use (may be empty).
152 IPC_STRUCT_MEMBER(GURL, referrer)
154 // The referrer policy to use.
155 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
157 // The frame's visiblity state.
158 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
160 // Additional HTTP request headers.
161 IPC_STRUCT_MEMBER(std::string, headers)
163 // net::URLRequest load flags (0 by default).
164 IPC_STRUCT_MEMBER(int, load_flags)
166 // Process ID from which this request originated, or zero if it originated
167 // in the renderer itself.
168 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
169 // through the renderer and and this holds the pid of the plugin process.
170 // Otherwise this holds the render_process_id of the view that has the plugin.
171 IPC_STRUCT_MEMBER(int, origin_pid)
173 // What this resource load is for (main frame, sub-frame, sub-resource,
174 // object).
175 IPC_STRUCT_MEMBER(content::ResourceType, resource_type)
177 // The priority of this request.
178 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
180 // Used by plugin->browser requests to get the correct net::URLRequestContext.
181 IPC_STRUCT_MEMBER(uint32, request_context)
183 // Indicates which frame (or worker context) the request is being loaded into,
184 // or kAppCacheNoHostId.
185 IPC_STRUCT_MEMBER(int, appcache_host_id)
187 // Indicates which frame (or worker context) the request is being loaded into,
188 // or kInvalidServiceWorkerProviderId.
189 IPC_STRUCT_MEMBER(int, service_worker_provider_id)
191 // True if the request should not be handled by the ServiceWorker.
192 IPC_STRUCT_MEMBER(bool, skip_service_worker)
194 // Optional resource request body (may be null).
195 IPC_STRUCT_MEMBER(scoped_refptr<content::ResourceRequestBody>,
196 request_body)
198 IPC_STRUCT_MEMBER(bool, download_to_file)
200 // True if the request was user initiated.
201 IPC_STRUCT_MEMBER(bool, has_user_gesture)
203 // True if load timing data should be collected for request.
204 IPC_STRUCT_MEMBER(bool, enable_load_timing)
206 // The routing id of the RenderFrame.
207 IPC_STRUCT_MEMBER(int, render_frame_id)
209 // True if |frame_id| is the main frame of a RenderView.
210 IPC_STRUCT_MEMBER(bool, is_main_frame)
212 // True if |parent_render_frame_id| is the main frame of a RenderView.
213 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
215 // Identifies the parent frame of the frame that sent the request.
216 // -1 if unknown / invalid.
217 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
219 IPC_STRUCT_MEMBER(ui::PageTransition, transition_type)
221 // For navigations, whether this navigation should replace the current session
222 // history entry on commit.
223 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
225 // The following two members identify a previous request that has been
226 // created before this navigation has been transferred to a new render view.
227 // This serves the purpose of recycling the old request.
228 // Unless this refers to a transferred navigation, these values are -1 and -1.
229 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
230 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
232 // Whether or not we should allow the URL to download.
233 IPC_STRUCT_MEMBER(bool, allow_download)
234 IPC_STRUCT_END()
236 // Parameters for a ResourceMsg_RequestComplete
237 IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
238 // The error code.
239 IPC_STRUCT_MEMBER(int, error_code)
241 // Was ignored by the request handler.
242 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
244 // A copy of the data requested exists in the cache.
245 IPC_STRUCT_MEMBER(bool, exists_in_cache)
247 // Serialized security info; see content/common/ssl_status_serialization.h.
248 IPC_STRUCT_MEMBER(std::string, security_info)
250 // Time the request completed.
251 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
253 // Total amount of data received from the network.
254 IPC_STRUCT_MEMBER(int64, encoded_data_length)
255 IPC_STRUCT_END()
257 // Resource messages sent from the browser to the renderer.
259 // Sent when the headers are available for a resource request.
260 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
261 int /* request_id */,
262 content::ResourceResponseHead)
264 // Sent when cached metadata from a resource request is ready.
265 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
266 int /* request_id */,
267 std::vector<char> /* data */)
269 // Sent as upload progress is being made.
270 IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
271 int /* request_id */,
272 int64 /* position */,
273 int64 /* size */)
275 // Sent when the request has been redirected. The receiver is expected to
276 // respond with either a FollowRedirect message (if the redirect is to be
277 // followed) or a CancelRequest message (if it should not be followed).
278 IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
279 int /* request_id */,
280 net::RedirectInfo /* redirect_info */,
281 content::ResourceResponseHead)
283 // Sent to set the shared memory buffer to be used to transmit response data to
284 // the renderer. Subsequent DataReceived messages refer to byte ranges in the
285 // shared memory buffer. The shared memory buffer should be retained by the
286 // renderer until the resource request completes.
288 // NOTE: The shared memory handle should already be mapped into the process
289 // that receives this message.
291 // TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
292 // added to help in debugging crbug/160401.
294 IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
295 int /* request_id */,
296 base::SharedMemoryHandle /* shm_handle */,
297 int /* shm_size */,
298 base::ProcessId /* renderer_pid */)
300 // Sent when some data from a resource request is ready. The data offset and
301 // length specify a byte range into the shared memory buffer provided by the
302 // SetDataBuffer message.
303 IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
304 int /* request_id */,
305 int /* data_offset */,
306 int /* data_length */,
307 int /* encoded_data_length */)
309 // Sent when some data from a resource request has been downloaded to
310 // file. This is only called in the 'download_to_file' case and replaces
311 // ResourceMsg_DataReceived in the call sequence in that case.
312 IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
313 int /* request_id */,
314 int /* data_len */,
315 int /* encoded_data_length */)
317 // Sent when the request has been completed.
318 IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
319 int /* request_id */,
320 ResourceMsg_RequestCompleteData)
322 // Resource messages sent from the renderer to the browser.
324 // Makes a resource request via the browser.
325 IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource,
326 int /* routing_id */,
327 int /* request_id */,
328 ResourceHostMsg_Request)
330 // Cancels a resource request with the ID given as the parameter.
331 IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
332 int /* request_id */)
334 // Follows a redirect that occured for the resource request with the ID given
335 // as the parameter.
336 IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect,
337 int /* request_id */)
339 // Makes a synchronous resource request via the browser.
340 IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
341 int /* request_id */,
342 ResourceHostMsg_Request,
343 content::SyncLoadResult)
345 // Sent when the renderer process is done processing a DataReceived
346 // message.
347 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
348 int /* request_id */)
350 // Sent when the renderer has processed a DataDownloaded message.
351 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
352 int /* request_id */)
354 // Sent by the renderer process to acknowledge receipt of a
355 // UploadProgress message.
356 IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
357 int /* request_id */)
359 // Sent when the renderer process deletes a resource loader.
360 IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
361 int /* request_id */)
363 // Sent by the renderer when a resource request changes priority.
364 IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
365 int /* request_id */,
366 net::RequestPriority,
367 int /* intra_priority_value */)