Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / net / http / http_response_info.h
blobdd1b3da351e39e4d88710845d416bf2e6993f416
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.
5 #ifndef NET_HTTP_HTTP_RESPONSE_INFO_H_
6 #define NET_HTTP_HTTP_RESPONSE_INFO_H_
8 #include <string>
10 #include "base/time/time.h"
11 #include "net/base/host_port_pair.h"
12 #include "net/base/net_export.h"
13 #include "net/http/http_vary_data.h"
14 #include "net/socket/next_proto.h"
15 #include "net/ssl/ssl_info.h"
17 namespace base {
18 class Pickle;
21 namespace net {
23 class AuthChallengeInfo;
24 class HttpResponseHeaders;
25 class IOBufferWithSize;
26 class SSLCertRequestInfo;
28 class NET_EXPORT HttpResponseInfo {
29 public:
30 // Describes the kind of connection used to fetch this response.
32 // NOTE: This is persisted to the cache, so make sure not to reorder
33 // these values.
35 // TODO(akalin): Better yet, just use a string instead of an enum,
36 // like |npn_negotiated_protocol|.
37 enum ConnectionInfo {
38 CONNECTION_INFO_UNKNOWN = 0,
39 CONNECTION_INFO_HTTP1 = 1,
40 CONNECTION_INFO_DEPRECATED_SPDY2 = 2,
41 CONNECTION_INFO_SPDY3 = 3,
42 CONNECTION_INFO_HTTP2 = 4, // HTTP/2.
43 CONNECTION_INFO_QUIC1_SPDY3 = 5,
44 CONNECTION_INFO_HTTP2_14 = 6, // HTTP/2 draft-14.
45 CONNECTION_INFO_HTTP2_15 = 7, // HTTP/2 draft-15.
46 NUM_OF_CONNECTION_INFOS,
49 HttpResponseInfo();
50 HttpResponseInfo(const HttpResponseInfo& rhs);
51 ~HttpResponseInfo();
52 HttpResponseInfo& operator=(const HttpResponseInfo& rhs);
53 // Even though we could get away with the copy ctor and default operator=,
54 // that would prevent us from doing a bunch of forward declaration.
56 // Initializes from the representation stored in the given pickle.
57 bool InitFromPickle(const base::Pickle& pickle, bool* response_truncated);
59 // Call this method to persist the response info.
60 void Persist(base::Pickle* pickle,
61 bool skip_transient_headers,
62 bool response_truncated) const;
64 // Whether QUIC is used or not.
65 bool DidUseQuic() const {
66 return connection_info == CONNECTION_INFO_QUIC1_SPDY3;
69 // The following is only defined if the request_time member is set.
70 // If this resource was found in the cache, then this bool is set, and
71 // request_time may corresponds to a time "far" in the past. Note that
72 // stale content (perhaps un-cacheable) may be fetched from cache subject to
73 // the load flags specified on the request info. For example, this is done
74 // when a user presses the back button to re-render pages, or at startup,
75 // when reloading previously visited pages (without going over the network).
76 // Note also that under normal circumstances, was_cached is set to the correct
77 // value even if the request fails.
78 bool was_cached;
80 // True if the request was fetched from cache rather than the network
81 // because of a LOAD_FROM_CACHE_IF_OFFLINE flag when the system
82 // was unable to contact the server.
83 bool server_data_unavailable;
85 // True if the request accessed the network in the process of retrieving
86 // data.
87 bool network_accessed;
89 // True if the request was fetched over a SPDY channel.
90 bool was_fetched_via_spdy;
92 // True if the npn was negotiated for this request.
93 bool was_npn_negotiated;
95 // True if the request was fetched via an explicit proxy. The proxy could
96 // be any type of proxy, HTTP or SOCKS. Note, we do not know if a
97 // transparent proxy may have been involved. If true, |proxy_server| contains
98 // the name of the proxy server that was used.
99 bool was_fetched_via_proxy;
100 HostPortPair proxy_server;
102 // Whether the request use http proxy or server authentication.
103 bool did_use_http_auth;
105 // True if the resource was originally fetched for a prefetch and has not been
106 // used since.
107 bool unused_since_prefetch;
109 // True if this resource is stale and requires async revalidation.
110 // This value is not persisted by Persist(); it is only ever set when the
111 // response is retrieved from the cache.
112 bool async_revalidation_required;
114 // Remote address of the socket which fetched this resource.
116 // NOTE: If the response was served from the cache (was_cached is true),
117 // the socket address will be set to the address that the content came from
118 // originally. This is true even if the response was re-validated using a
119 // different remote address, or if some of the content came from a byte-range
120 // request to a different address.
121 HostPortPair socket_address;
123 // Protocol negotiated with the server.
124 std::string npn_negotiated_protocol;
126 // The type of connection used for this response.
127 ConnectionInfo connection_info;
129 // The time at which the request was made that resulted in this response.
130 // For cached responses, this is the last time the cache entry was validated.
131 base::Time request_time;
133 // The time at which the response headers were received. For cached
134 // this is the last time the cache entry was validated.
135 base::Time response_time;
137 // If the response headers indicate a 401 or 407 failure, then this structure
138 // will contain additional information about the authentication challenge.
139 scoped_refptr<AuthChallengeInfo> auth_challenge;
141 // The SSL client certificate request info.
142 // TODO(wtc): does this really belong in HttpResponseInfo? I put it here
143 // because it is similar to |auth_challenge|, but unlike HTTP authentication
144 // challenge, client certificate request is not part of an HTTP response.
145 scoped_refptr<SSLCertRequestInfo> cert_request_info;
147 // The SSL connection info (if HTTPS). Note that when a response is
148 // served from cache, not every field is present. See
149 // HttpResponseInfo::InitFromPickle().
150 SSLInfo ssl_info;
152 // The parsed response headers and status line.
153 scoped_refptr<HttpResponseHeaders> headers;
155 // The "Vary" header data for this response.
156 HttpVaryData vary_data;
158 // Any metadata asociated with this resource's cached data.
159 scoped_refptr<IOBufferWithSize> metadata;
161 static ConnectionInfo ConnectionInfoFromNextProto(NextProto next_proto);
163 static std::string ConnectionInfoToString(ConnectionInfo connection_info);
166 } // namespace net
168 #endif // NET_HTTP_HTTP_RESPONSE_INFO_H_