Add ICU message format support
[chromium-blink-merge.git] / content / common / resource_messages.h
blobbc38f0286fd665660efa9f0592c37f3456a4a09d
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/common/service_worker/service_worker_types.h"
15 #include "content/public/common/common_param_traits.h"
16 #include "content/public/common/resource_response.h"
17 #include "ipc/ipc_message_macros.h"
18 #include "net/base/request_priority.h"
19 #include "net/http/http_response_info.h"
20 #include "net/url_request/redirect_info.h"
22 #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
23 #define CONTENT_COMMON_RESOURCE_MESSAGES_H_
25 namespace net {
26 struct LoadTimingInfo;
29 namespace content {
30 struct ResourceDevToolsInfo;
33 namespace IPC {
35 template <>
36 struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
37 typedef scoped_refptr<net::HttpResponseHeaders> param_type;
38 static void Write(Message* m, const param_type& p);
39 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
40 static void Log(const param_type& p, std::string* l);
43 template <>
44 struct CONTENT_EXPORT ParamTraits<storage::DataElement> {
45 typedef storage::DataElement param_type;
46 static void Write(Message* m, const param_type& p);
47 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
48 static void Log(const param_type& p, std::string* l);
51 template <>
52 struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
53 typedef scoped_refptr<content::ResourceDevToolsInfo> param_type;
54 static void Write(Message* m, const param_type& p);
55 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
56 static void Log(const param_type& p, std::string* l);
59 template <>
60 struct ParamTraits<net::LoadTimingInfo> {
61 typedef net::LoadTimingInfo param_type;
62 static void Write(Message* m, const param_type& p);
63 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
64 static void Log(const param_type& p, std::string* l);
67 template <>
68 struct ParamTraits<scoped_refptr<content::ResourceRequestBody> > {
69 typedef scoped_refptr<content::ResourceRequestBody> param_type;
70 static void Write(Message* m, const param_type& p);
71 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
72 static void Log(const param_type& p, std::string* l);
75 } // namespace IPC
77 #endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
80 #define IPC_MESSAGE_START ResourceMsgStart
81 #undef IPC_MESSAGE_EXPORT
82 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
84 IPC_ENUM_TRAITS_MAX_VALUE( \
85 net::HttpResponseInfo::ConnectionInfo, \
86 net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
88 IPC_ENUM_TRAITS_MAX_VALUE(content::FetchRequestMode,
89 content::FETCH_REQUEST_MODE_LAST)
91 IPC_ENUM_TRAITS_MAX_VALUE(content::FetchCredentialsMode,
92 content::FETCH_CREDENTIALS_MODE_LAST)
94 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
95 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo)
96 IPC_STRUCT_TRAITS_MEMBER(request_start)
97 IPC_STRUCT_TRAITS_MEMBER(response_start)
98 IPC_STRUCT_TRAITS_END()
100 IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult)
101 IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead)
102 IPC_STRUCT_TRAITS_MEMBER(error_code)
103 IPC_STRUCT_TRAITS_MEMBER(final_url)
104 IPC_STRUCT_TRAITS_MEMBER(data)
105 IPC_STRUCT_TRAITS_END()
107 IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo)
108 IPC_STRUCT_TRAITS_MEMBER(request_time)
109 IPC_STRUCT_TRAITS_MEMBER(response_time)
110 IPC_STRUCT_TRAITS_MEMBER(headers)
111 IPC_STRUCT_TRAITS_MEMBER(mime_type)
112 IPC_STRUCT_TRAITS_MEMBER(charset)
113 IPC_STRUCT_TRAITS_MEMBER(security_info)
114 IPC_STRUCT_TRAITS_MEMBER(content_length)
115 IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
116 IPC_STRUCT_TRAITS_MEMBER(appcache_id)
117 IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
118 IPC_STRUCT_TRAITS_MEMBER(load_timing)
119 IPC_STRUCT_TRAITS_MEMBER(devtools_info)
120 IPC_STRUCT_TRAITS_MEMBER(download_file_path)
121 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy)
122 IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated)
123 IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available)
124 IPC_STRUCT_TRAITS_MEMBER(connection_info)
125 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy)
126 IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol)
127 IPC_STRUCT_TRAITS_MEMBER(socket_address)
128 IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker)
129 IPC_STRUCT_TRAITS_MEMBER(was_fallback_required_by_service_worker)
130 IPC_STRUCT_TRAITS_MEMBER(original_url_via_service_worker)
131 IPC_STRUCT_TRAITS_MEMBER(response_type_via_service_worker)
132 IPC_STRUCT_TRAITS_MEMBER(service_worker_start_time)
133 IPC_STRUCT_TRAITS_MEMBER(service_worker_ready_time)
134 IPC_STRUCT_TRAITS_MEMBER(proxy_server)
135 IPC_STRUCT_TRAITS_END()
137 IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo)
138 IPC_STRUCT_TRAITS_MEMBER(status_code)
139 IPC_STRUCT_TRAITS_MEMBER(new_method)
140 IPC_STRUCT_TRAITS_MEMBER(new_url)
141 IPC_STRUCT_TRAITS_MEMBER(new_first_party_for_cookies)
142 IPC_STRUCT_TRAITS_MEMBER(new_referrer)
143 IPC_STRUCT_TRAITS_END()
145 // Parameters for a resource request.
146 IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
147 // The request method: GET, POST, etc.
148 IPC_STRUCT_MEMBER(std::string, method)
150 // The requested URL.
151 IPC_STRUCT_MEMBER(GURL, url)
153 // Usually the URL of the document in the top-level window, which may be
154 // checked by the third-party cookie blocking policy. Leaving it empty may
155 // lead to undesired cookie blocking. Third-party cookie blocking can be
156 // bypassed by setting first_party_for_cookies = url, but this should ideally
157 // only be done if there really is no way to determine the correct value.
158 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
160 // The referrer to use (may be empty).
161 IPC_STRUCT_MEMBER(GURL, referrer)
163 // The referrer policy to use.
164 IPC_STRUCT_MEMBER(blink::WebReferrerPolicy, referrer_policy)
166 // The frame's visiblity state.
167 IPC_STRUCT_MEMBER(blink::WebPageVisibilityState, visiblity_state)
169 // Additional HTTP request headers.
170 IPC_STRUCT_MEMBER(std::string, headers)
172 // net::URLRequest load flags (0 by default).
173 IPC_STRUCT_MEMBER(int, load_flags)
175 // Process ID from which this request originated, or zero if it originated
176 // in the renderer itself.
177 // If kDirectNPAPIRequests isn't specified, then plugin requests get routed
178 // through the renderer and and this holds the pid of the plugin process.
179 // Otherwise this holds the render_process_id of the view that has the plugin.
180 IPC_STRUCT_MEMBER(int, origin_pid)
182 // What this resource load is for (main frame, sub-frame, sub-resource,
183 // object).
184 IPC_STRUCT_MEMBER(content::ResourceType, resource_type)
186 // The priority of this request.
187 IPC_STRUCT_MEMBER(net::RequestPriority, priority)
189 // Used by plugin->browser requests to get the correct net::URLRequestContext.
190 IPC_STRUCT_MEMBER(uint32, request_context)
192 // Indicates which frame (or worker context) the request is being loaded into,
193 // or kAppCacheNoHostId.
194 IPC_STRUCT_MEMBER(int, appcache_host_id)
196 // True if corresponding AppCache group should be resetted.
197 IPC_STRUCT_MEMBER(bool, should_reset_appcache)
199 // Indicates which frame (or worker context) the request is being loaded into,
200 // or kInvalidServiceWorkerProviderId.
201 IPC_STRUCT_MEMBER(int, service_worker_provider_id)
203 // True if the request should not be handled by the ServiceWorker.
204 IPC_STRUCT_MEMBER(bool, skip_service_worker)
206 // The request mode passed to the ServiceWorker.
207 IPC_STRUCT_MEMBER(content::FetchRequestMode, fetch_request_mode)
209 // The credentials mode passed to the ServiceWorker.
210 IPC_STRUCT_MEMBER(content::FetchCredentialsMode, fetch_credentials_mode)
212 // The request context passed to the ServiceWorker.
213 IPC_STRUCT_MEMBER(content::RequestContextType, fetch_request_context_type)
215 // The frame type passed to the ServiceWorker.
216 IPC_STRUCT_MEMBER(content::RequestContextFrameType, fetch_frame_type)
218 // Optional resource request body (may be null).
219 IPC_STRUCT_MEMBER(scoped_refptr<content::ResourceRequestBody>,
220 request_body)
222 IPC_STRUCT_MEMBER(bool, download_to_file)
224 // True if the request was user initiated.
225 IPC_STRUCT_MEMBER(bool, has_user_gesture)
227 // True if load timing data should be collected for request.
228 IPC_STRUCT_MEMBER(bool, enable_load_timing)
230 // True if upload progress should be available for request.
231 IPC_STRUCT_MEMBER(bool, enable_upload_progress)
233 // True if login prompts for this request should be supressed.
234 IPC_STRUCT_MEMBER(bool, do_not_prompt_for_login)
236 // The routing id of the RenderFrame.
237 IPC_STRUCT_MEMBER(int, render_frame_id)
239 // True if |frame_id| is the main frame of a RenderView.
240 IPC_STRUCT_MEMBER(bool, is_main_frame)
242 // True if |parent_render_frame_id| is the main frame of a RenderView.
243 IPC_STRUCT_MEMBER(bool, parent_is_main_frame)
245 // Identifies the parent frame of the frame that sent the request.
246 // -1 if unknown / invalid.
247 IPC_STRUCT_MEMBER(int, parent_render_frame_id)
249 IPC_STRUCT_MEMBER(ui::PageTransition, transition_type)
251 // For navigations, whether this navigation should replace the current session
252 // history entry on commit.
253 IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
255 // The following two members identify a previous request that has been
256 // created before this navigation has been transferred to a new render view.
257 // This serves the purpose of recycling the old request.
258 // Unless this refers to a transferred navigation, these values are -1 and -1.
259 IPC_STRUCT_MEMBER(int, transferred_request_child_id)
260 IPC_STRUCT_MEMBER(int, transferred_request_request_id)
262 // Whether or not we should allow the URL to download.
263 IPC_STRUCT_MEMBER(bool, allow_download)
264 IPC_STRUCT_END()
266 // Parameters for a ResourceMsg_RequestComplete
267 IPC_STRUCT_BEGIN(ResourceMsg_RequestCompleteData)
268 // The error code.
269 IPC_STRUCT_MEMBER(int, error_code)
271 // Was ignored by the request handler.
272 IPC_STRUCT_MEMBER(bool, was_ignored_by_handler)
274 // A copy of the data requested exists in the cache.
275 IPC_STRUCT_MEMBER(bool, exists_in_cache)
277 // Serialized security info; see content/common/ssl_status_serialization.h.
278 IPC_STRUCT_MEMBER(std::string, security_info)
280 // Time the request completed.
281 IPC_STRUCT_MEMBER(base::TimeTicks, completion_time)
283 // Total amount of data received from the network.
284 IPC_STRUCT_MEMBER(int64, encoded_data_length)
285 IPC_STRUCT_END()
287 // Resource messages sent from the browser to the renderer.
289 // Sent when the headers are available for a resource request.
290 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
291 int /* request_id */,
292 content::ResourceResponseHead)
294 // Sent when cached metadata from a resource request is ready.
295 IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
296 int /* request_id */,
297 std::vector<char> /* data */)
299 // Sent as upload progress is being made.
300 IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
301 int /* request_id */,
302 int64 /* position */,
303 int64 /* size */)
305 // Sent when the request has been redirected. The receiver is expected to
306 // respond with either a FollowRedirect message (if the redirect is to be
307 // followed) or a CancelRequest message (if it should not be followed).
308 IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
309 int /* request_id */,
310 net::RedirectInfo /* redirect_info */,
311 content::ResourceResponseHead)
313 // Sent to set the shared memory buffer to be used to transmit response data to
314 // the renderer. Subsequent DataReceived messages refer to byte ranges in the
315 // shared memory buffer. The shared memory buffer should be retained by the
316 // renderer until the resource request completes.
318 // NOTE: The shared memory handle should already be mapped into the process
319 // that receives this message.
321 // TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
322 // added to help in debugging crbug/160401.
324 IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
325 int /* request_id */,
326 base::SharedMemoryHandle /* shm_handle */,
327 int /* shm_size */,
328 base::ProcessId /* renderer_pid */)
330 // Sent when some data from a resource request is ready. The data offset and
331 // length specify a byte range into the shared memory buffer provided by the
332 // SetDataBuffer message.
333 IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
334 int /* request_id */,
335 int /* data_offset */,
336 int /* data_length */,
337 int /* encoded_data_length */)
339 // Sent when some data from a resource request has been downloaded to
340 // file. This is only called in the 'download_to_file' case and replaces
341 // ResourceMsg_DataReceived in the call sequence in that case.
342 IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
343 int /* request_id */,
344 int /* data_len */,
345 int /* encoded_data_length */)
347 // Sent when the request has been completed.
348 IPC_MESSAGE_CONTROL2(ResourceMsg_RequestComplete,
349 int /* request_id */,
350 ResourceMsg_RequestCompleteData)
352 // Resource messages sent from the renderer to the browser.
354 // Makes a resource request via the browser.
355 IPC_MESSAGE_CONTROL3(ResourceHostMsg_RequestResource,
356 int /* routing_id */,
357 int /* request_id */,
358 ResourceHostMsg_Request)
360 // Cancels a resource request with the ID given as the parameter.
361 IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
362 int /* request_id */)
364 // Follows a redirect that occured for the resource request with the ID given
365 // as the parameter.
366 IPC_MESSAGE_CONTROL1(ResourceHostMsg_FollowRedirect,
367 int /* request_id */)
369 // Makes a synchronous resource request via the browser.
370 IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
371 int /* request_id */,
372 ResourceHostMsg_Request,
373 content::SyncLoadResult)
375 // Sent when the renderer process is done processing a DataReceived
376 // message.
377 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
378 int /* request_id */)
380 // Sent when the renderer has processed a DataDownloaded message.
381 IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
382 int /* request_id */)
384 // Sent by the renderer process to acknowledge receipt of a
385 // UploadProgress message.
386 IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
387 int /* request_id */)
389 // Sent when the renderer process deletes a resource loader.
390 IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
391 int /* request_id */)
393 // Sent by the renderer when a resource request changes priority.
394 IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
395 int /* request_id */,
396 net::RequestPriority,
397 int /* intra_priority_value */)