Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / public / common / resource_response_info.h
blobd7d1698d451d10cab8ada43fa9167cf732f5e54b
1 // Copyright 2014 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 #ifndef CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_INFO_H_
6 #define CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_INFO_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/time/time.h"
14 #include "content/common/content_export.h"
15 #include "content/public/common/resource_devtools_info.h"
16 #include "net/base/host_port_pair.h"
17 #include "net/base/load_timing_info.h"
18 #include "net/http/http_response_headers.h"
19 #include "net/http/http_response_info.h"
20 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponseType.h"
21 #include "url/gurl.h"
23 namespace content {
25 // Note: when modifying this structure, also update ResourceResponse::DeepCopy
26 // in resource_response.cc.
27 struct ResourceResponseInfo {
28 CONTENT_EXPORT ResourceResponseInfo();
29 CONTENT_EXPORT ~ResourceResponseInfo();
31 // The time at which the request was made that resulted in this response.
32 // For cached responses, this time could be "far" in the past.
33 base::Time request_time;
35 // The time at which the response headers were received. For cached
36 // responses, this time could be "far" in the past.
37 base::Time response_time;
39 // The response headers or NULL if the URL type does not support headers.
40 scoped_refptr<net::HttpResponseHeaders> headers;
42 // The mime type of the response. This may be a derived value.
43 std::string mime_type;
45 // The character encoding of the response or none if not applicable to the
46 // response's mime type. This may be a derived value.
47 std::string charset;
49 // An opaque string carrying security information pertaining to this
50 // response. This may include information about the SSL connection used.
51 std::string security_info;
53 // Content length if available. -1 if not available
54 int64 content_length;
56 // Length of the encoded data transferred over the network. In case there is
57 // no data, contains -1.
58 int64 encoded_data_length;
60 // The appcache this response was loaded from, or kAppCacheNoCacheId.
61 int64 appcache_id;
63 // The manifest url of the appcache this response was loaded from.
64 // Note: this value is only populated for main resource requests.
65 GURL appcache_manifest_url;
67 // Detailed timing information used by the WebTiming, HAR and Developer
68 // Tools. Includes socket ID and socket reuse information.
69 net::LoadTimingInfo load_timing;
71 // Actual request and response headers, as obtained from the network stack.
72 // Only present if the renderer set report_raw_headers to true and had the
73 // CanReadRawCookies permission.
74 scoped_refptr<ResourceDevToolsInfo> devtools_info;
76 // The path to a file that will contain the response body. It may only
77 // contain a portion of the response body at the time that the ResponseInfo
78 // becomes available.
79 base::FilePath download_file_path;
81 // True if the response was delivered using SPDY.
82 bool was_fetched_via_spdy;
84 // True if the response was delivered after NPN is negotiated.
85 bool was_npn_negotiated;
87 // True if response could use alternate protocol. However, browser will
88 // ignore the alternate protocol when spdy is not enabled on browser side.
89 bool was_alternate_protocol_available;
91 // Information about the type of connection used to fetch this response.
92 net::HttpResponseInfo::ConnectionInfo connection_info;
94 // True if the response was fetched via an explicit proxy (as opposed to a
95 // transparent proxy). The proxy could be any type of proxy, HTTP or SOCKS.
96 // Note: we cannot tell if a transparent proxy may have been involved. If
97 // true, |proxy_server| contains the name of the proxy server that was used.
98 bool was_fetched_via_proxy;
99 net::HostPortPair proxy_server;
101 // NPN protocol negotiated with the server.
102 std::string npn_negotiated_protocol;
104 // Remote address of the socket which fetched this resource.
105 net::HostPortPair socket_address;
107 // True if the response was fetched by a ServiceWorker.
108 bool was_fetched_via_service_worker;
110 // True when the request whoes mode is |CORS| or |CORS-with-forced-preflight|
111 // is sent to a ServiceWorker but FetchEvent.respondWith is not called. So the
112 // renderer have to resend the request with skip service worker flag
113 // considering the CORS preflight logic.
114 bool was_fallback_required_by_service_worker;
116 // The original URL of the response which was fetched by the ServiceWorker.
117 // This may be empty if the response was created inside the ServiceWorker.
118 GURL original_url_via_service_worker;
120 // The type of the response which was fetched by the ServiceWorker.
121 blink::WebServiceWorkerResponseType response_type_via_service_worker;
123 // The time immediately before starting ServiceWorker. If the response is not
124 // provided by the ServiceWorker, kept empty.
125 // TODO(ksakamoto): Move this to net::LoadTimingInfo.
126 base::TimeTicks service_worker_start_time;
128 // The time immediately before dispatching fetch event in ServiceWorker.
129 // If the response is not provided by the ServiceWorker, kept empty.
130 // TODO(ksakamoto): Move this to net::LoadTimingInfo.
131 base::TimeTicks service_worker_ready_time;
134 } // namespace content
136 #endif // CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_INFO_H_