OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_response_info.h" | 5 #include "net/http/http_response_info.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 // This bit is set if the response info has connection info. | 85 // This bit is set if the response info has connection info. |
86 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18, | 86 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18, |
87 | 87 |
88 // This bit is set if the request has http authentication. | 88 // This bit is set if the request has http authentication. |
89 RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19, | 89 RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19, |
90 | 90 |
91 // This bit is set if ssl_info has SCTs. | 91 // This bit is set if ssl_info has SCTs. |
92 RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS = 1 << 20, | 92 RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS = 1 << 20, |
93 | 93 |
| 94 RESPONSE_INFO_UNUSED_SINCE_PREFETCH = 1 << 21, |
| 95 |
94 // TODO(darin): Add other bits to indicate alternate request methods. | 96 // TODO(darin): Add other bits to indicate alternate request methods. |
95 // For now, we don't support storing those. | 97 // For now, we don't support storing those. |
96 }; | 98 }; |
97 | 99 |
98 HttpResponseInfo::HttpResponseInfo() | 100 HttpResponseInfo::HttpResponseInfo() |
99 : was_cached(false), | 101 : was_cached(false), |
100 server_data_unavailable(false), | 102 server_data_unavailable(false), |
101 network_accessed(false), | 103 network_accessed(false), |
102 was_fetched_via_spdy(false), | 104 was_fetched_via_spdy(false), |
103 was_npn_negotiated(false), | 105 was_npn_negotiated(false), |
104 was_fetched_via_proxy(false), | 106 was_fetched_via_proxy(false), |
105 did_use_http_auth(false), | 107 did_use_http_auth(false), |
| 108 unused_since_prefetch(false), |
106 connection_info(CONNECTION_INFO_UNKNOWN) { | 109 connection_info(CONNECTION_INFO_UNKNOWN) { |
107 } | 110 } |
108 | 111 |
109 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) | 112 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) |
110 : was_cached(rhs.was_cached), | 113 : was_cached(rhs.was_cached), |
111 server_data_unavailable(rhs.server_data_unavailable), | 114 server_data_unavailable(rhs.server_data_unavailable), |
112 network_accessed(rhs.network_accessed), | 115 network_accessed(rhs.network_accessed), |
113 was_fetched_via_spdy(rhs.was_fetched_via_spdy), | 116 was_fetched_via_spdy(rhs.was_fetched_via_spdy), |
114 was_npn_negotiated(rhs.was_npn_negotiated), | 117 was_npn_negotiated(rhs.was_npn_negotiated), |
115 was_fetched_via_proxy(rhs.was_fetched_via_proxy), | 118 was_fetched_via_proxy(rhs.was_fetched_via_proxy), |
116 proxy_server(rhs.proxy_server), | 119 proxy_server(rhs.proxy_server), |
117 did_use_http_auth(rhs.did_use_http_auth), | 120 did_use_http_auth(rhs.did_use_http_auth), |
| 121 unused_since_prefetch(rhs.unused_since_prefetch), |
118 socket_address(rhs.socket_address), | 122 socket_address(rhs.socket_address), |
119 npn_negotiated_protocol(rhs.npn_negotiated_protocol), | 123 npn_negotiated_protocol(rhs.npn_negotiated_protocol), |
120 connection_info(rhs.connection_info), | 124 connection_info(rhs.connection_info), |
121 request_time(rhs.request_time), | 125 request_time(rhs.request_time), |
122 response_time(rhs.response_time), | 126 response_time(rhs.response_time), |
123 auth_challenge(rhs.auth_challenge), | 127 auth_challenge(rhs.auth_challenge), |
124 cert_request_info(rhs.cert_request_info), | 128 cert_request_info(rhs.cert_request_info), |
125 ssl_info(rhs.ssl_info), | 129 ssl_info(rhs.ssl_info), |
126 headers(rhs.headers), | 130 headers(rhs.headers), |
127 vary_data(rhs.vary_data), | 131 vary_data(rhs.vary_data), |
128 metadata(rhs.metadata) { | 132 metadata(rhs.metadata) { |
129 } | 133 } |
130 | 134 |
131 HttpResponseInfo::~HttpResponseInfo() { | 135 HttpResponseInfo::~HttpResponseInfo() { |
132 } | 136 } |
133 | 137 |
134 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { | 138 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { |
135 was_cached = rhs.was_cached; | 139 was_cached = rhs.was_cached; |
136 server_data_unavailable = rhs.server_data_unavailable; | 140 server_data_unavailable = rhs.server_data_unavailable; |
137 network_accessed = rhs.network_accessed; | 141 network_accessed = rhs.network_accessed; |
138 was_fetched_via_spdy = rhs.was_fetched_via_spdy; | 142 was_fetched_via_spdy = rhs.was_fetched_via_spdy; |
139 proxy_server = rhs.proxy_server; | 143 proxy_server = rhs.proxy_server; |
140 was_npn_negotiated = rhs.was_npn_negotiated; | 144 was_npn_negotiated = rhs.was_npn_negotiated; |
141 was_fetched_via_proxy = rhs.was_fetched_via_proxy; | 145 was_fetched_via_proxy = rhs.was_fetched_via_proxy; |
142 did_use_http_auth = rhs.did_use_http_auth; | 146 did_use_http_auth = rhs.did_use_http_auth; |
| 147 unused_since_prefetch = rhs.unused_since_prefetch; |
143 socket_address = rhs.socket_address; | 148 socket_address = rhs.socket_address; |
144 npn_negotiated_protocol = rhs.npn_negotiated_protocol; | 149 npn_negotiated_protocol = rhs.npn_negotiated_protocol; |
145 connection_info = rhs.connection_info; | 150 connection_info = rhs.connection_info; |
146 request_time = rhs.request_time; | 151 request_time = rhs.request_time; |
147 response_time = rhs.response_time; | 152 response_time = rhs.response_time; |
148 auth_challenge = rhs.auth_challenge; | 153 auth_challenge = rhs.auth_challenge; |
149 cert_request_info = rhs.cert_request_info; | 154 cert_request_info = rhs.cert_request_info; |
150 ssl_info = rhs.ssl_info; | 155 ssl_info = rhs.ssl_info; |
151 headers = rhs.headers; | 156 headers = rhs.headers; |
152 vary_data = rhs.vary_data; | 157 vary_data = rhs.vary_data; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; | 275 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; |
271 | 276 |
272 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; | 277 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; |
273 | 278 |
274 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; | 279 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; |
275 | 280 |
276 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; | 281 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; |
277 | 282 |
278 did_use_http_auth = (flags & RESPONSE_INFO_USE_HTTP_AUTHENTICATION) != 0; | 283 did_use_http_auth = (flags & RESPONSE_INFO_USE_HTTP_AUTHENTICATION) != 0; |
279 | 284 |
| 285 unused_since_prefetch = (flags & RESPONSE_INFO_UNUSED_SINCE_PREFETCH) != 0; |
| 286 |
280 return true; | 287 return true; |
281 } | 288 } |
282 | 289 |
283 void HttpResponseInfo::Persist(Pickle* pickle, | 290 void HttpResponseInfo::Persist(Pickle* pickle, |
284 bool skip_transient_headers, | 291 bool skip_transient_headers, |
285 bool response_truncated) const { | 292 bool response_truncated) const { |
286 int flags = RESPONSE_INFO_VERSION; | 293 int flags = RESPONSE_INFO_VERSION; |
287 if (ssl_info.is_valid()) { | 294 if (ssl_info.is_valid()) { |
288 flags |= RESPONSE_INFO_HAS_CERT; | 295 flags |= RESPONSE_INFO_HAS_CERT; |
289 flags |= RESPONSE_INFO_HAS_CERT_STATUS; | 296 flags |= RESPONSE_INFO_HAS_CERT_STATUS; |
(...skipping 11 matching lines...) Expand all Loading... |
301 if (was_npn_negotiated) { | 308 if (was_npn_negotiated) { |
302 flags |= RESPONSE_INFO_WAS_NPN; | 309 flags |= RESPONSE_INFO_WAS_NPN; |
303 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; | 310 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; |
304 } | 311 } |
305 if (was_fetched_via_proxy) | 312 if (was_fetched_via_proxy) |
306 flags |= RESPONSE_INFO_WAS_PROXY; | 313 flags |= RESPONSE_INFO_WAS_PROXY; |
307 if (connection_info != CONNECTION_INFO_UNKNOWN) | 314 if (connection_info != CONNECTION_INFO_UNKNOWN) |
308 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; | 315 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; |
309 if (did_use_http_auth) | 316 if (did_use_http_auth) |
310 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION; | 317 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION; |
| 318 if (unused_since_prefetch) |
| 319 flags |= RESPONSE_INFO_UNUSED_SINCE_PREFETCH; |
311 if (!ssl_info.signed_certificate_timestamps.empty()) | 320 if (!ssl_info.signed_certificate_timestamps.empty()) |
312 flags |= RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS; | 321 flags |= RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS; |
313 | 322 |
314 pickle->WriteInt(flags); | 323 pickle->WriteInt(flags); |
315 pickle->WriteInt64(request_time.ToInternalValue()); | 324 pickle->WriteInt64(request_time.ToInternalValue()); |
316 pickle->WriteInt64(response_time.ToInternalValue()); | 325 pickle->WriteInt64(response_time.ToInternalValue()); |
317 | 326 |
318 net::HttpResponseHeaders::PersistOptions persist_options = | 327 net::HttpResponseHeaders::PersistOptions persist_options = |
319 net::HttpResponseHeaders::PERSIST_RAW; | 328 net::HttpResponseHeaders::PERSIST_RAW; |
320 | 329 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 case CONNECTION_INFO_QUIC1_SPDY3: | 416 case CONNECTION_INFO_QUIC1_SPDY3: |
408 return "quic/1+spdy/3"; | 417 return "quic/1+spdy/3"; |
409 case NUM_OF_CONNECTION_INFOS: | 418 case NUM_OF_CONNECTION_INFOS: |
410 break; | 419 break; |
411 } | 420 } |
412 NOTREACHED(); | 421 NOTREACHED(); |
413 return ""; | 422 return ""; |
414 } | 423 } |
415 | 424 |
416 } // namespace net | 425 } // namespace net |
OLD | NEW |