Chromium Code Reviews| 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.h" | 9 #include "base/time.h" |
| 10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 RESPONSE_INFO_WAS_PROXY = 1 << 15, | 74 RESPONSE_INFO_WAS_PROXY = 1 << 15, |
| 75 | 75 |
| 76 // This bit is set if the response info has an SSL connection status field. | 76 // This bit is set if the response info has an SSL connection status field. |
| 77 // This contains the ciphersuite used to fetch the resource as well as the | 77 // This contains the ciphersuite used to fetch the resource as well as the |
| 78 // protocol version, compression method and whether SSLv3 fallback was used. | 78 // protocol version, compression method and whether SSLv3 fallback was used. |
| 79 RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16, | 79 RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16, |
| 80 | 80 |
| 81 // This bit is set if the response info has protocol version. | 81 // This bit is set if the response info has protocol version. |
| 82 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17, | 82 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17, |
| 83 | 83 |
| 84 // This bit is set if the request was overriden from cache due to | |
| 85 // various load flags being set. | |
| 86 RESPONSE_INFO_WAS_CACHE_OVERRIDE = 1 << 18, | |
|
rvargas (doing something else)
2013/03/05 02:58:19
This enum is for storing info about this response
Randy Smith (Not in Mondays)
2013/03/05 23:16:14
The enum was used for pickling and unpickling. If
rvargas (doing something else)
2013/03/06 03:11:48
But we don't really want to persist this flag. Tha
Randy Smith (Not in Mondays)
2013/03/06 22:55:55
Done.
| |
| 87 | |
| 84 // TODO(darin): Add other bits to indicate alternate request methods. | 88 // TODO(darin): Add other bits to indicate alternate request methods. |
| 85 // For now, we don't support storing those. | 89 // For now, we don't support storing those. |
| 86 }; | 90 }; |
| 87 | 91 |
| 88 HttpResponseInfo::HttpResponseInfo() | 92 HttpResponseInfo::HttpResponseInfo() |
| 89 : was_cached(false), | 93 : was_cached(false), |
| 90 was_fetched_via_spdy(false), | 94 was_fetched_via_spdy(false), |
| 91 was_npn_negotiated(false), | 95 was_npn_negotiated(false), |
| 92 was_fetched_via_proxy(false) { | 96 was_fetched_via_proxy(false), |
| 97 was_cache_override(false) { | |
| 93 } | 98 } |
| 94 | 99 |
| 95 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) | 100 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) |
| 96 : was_cached(rhs.was_cached), | 101 : was_cached(rhs.was_cached), |
| 97 was_fetched_via_spdy(rhs.was_fetched_via_spdy), | 102 was_fetched_via_spdy(rhs.was_fetched_via_spdy), |
| 98 was_npn_negotiated(rhs.was_npn_negotiated), | 103 was_npn_negotiated(rhs.was_npn_negotiated), |
| 99 was_fetched_via_proxy(rhs.was_fetched_via_proxy), | 104 was_fetched_via_proxy(rhs.was_fetched_via_proxy), |
| 105 was_cache_override(rhs.was_cache_override), | |
| 100 socket_address(rhs.socket_address), | 106 socket_address(rhs.socket_address), |
| 101 npn_negotiated_protocol(rhs.npn_negotiated_protocol), | 107 npn_negotiated_protocol(rhs.npn_negotiated_protocol), |
| 102 request_time(rhs.request_time), | 108 request_time(rhs.request_time), |
| 103 response_time(rhs.response_time), | 109 response_time(rhs.response_time), |
| 104 auth_challenge(rhs.auth_challenge), | 110 auth_challenge(rhs.auth_challenge), |
| 105 cert_request_info(rhs.cert_request_info), | 111 cert_request_info(rhs.cert_request_info), |
| 106 ssl_info(rhs.ssl_info), | 112 ssl_info(rhs.ssl_info), |
| 107 headers(rhs.headers), | 113 headers(rhs.headers), |
| 108 vary_data(rhs.vary_data), | 114 vary_data(rhs.vary_data), |
| 109 metadata(rhs.metadata) { | 115 metadata(rhs.metadata) { |
| 110 } | 116 } |
| 111 | 117 |
| 112 HttpResponseInfo::~HttpResponseInfo() { | 118 HttpResponseInfo::~HttpResponseInfo() { |
| 113 } | 119 } |
| 114 | 120 |
| 115 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { | 121 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { |
| 116 was_cached = rhs.was_cached; | 122 was_cached = rhs.was_cached; |
| 117 was_fetched_via_spdy = rhs.was_fetched_via_spdy; | 123 was_fetched_via_spdy = rhs.was_fetched_via_spdy; |
| 118 was_npn_negotiated = rhs.was_npn_negotiated; | 124 was_npn_negotiated = rhs.was_npn_negotiated; |
| 119 was_fetched_via_proxy = rhs.was_fetched_via_proxy; | 125 was_fetched_via_proxy = rhs.was_fetched_via_proxy; |
| 126 was_cache_override = rhs.was_cache_override; | |
| 120 socket_address = rhs.socket_address; | 127 socket_address = rhs.socket_address; |
| 121 npn_negotiated_protocol = rhs.npn_negotiated_protocol; | 128 npn_negotiated_protocol = rhs.npn_negotiated_protocol; |
| 122 request_time = rhs.request_time; | 129 request_time = rhs.request_time; |
| 123 response_time = rhs.response_time; | 130 response_time = rhs.response_time; |
| 124 auth_challenge = rhs.auth_challenge; | 131 auth_challenge = rhs.auth_challenge; |
| 125 cert_request_info = rhs.cert_request_info; | 132 cert_request_info = rhs.cert_request_info; |
| 126 ssl_info = rhs.ssl_info; | 133 ssl_info = rhs.ssl_info; |
| 127 headers = rhs.headers; | 134 headers = rhs.headers; |
| 128 vary_data = rhs.vary_data; | 135 vary_data = rhs.vary_data; |
| 129 metadata = rhs.metadata; | 136 metadata = rhs.metadata; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 if (!pickle.ReadString(&iter, &npn_negotiated_protocol)) | 221 if (!pickle.ReadString(&iter, &npn_negotiated_protocol)) |
| 215 return false; | 222 return false; |
| 216 } | 223 } |
| 217 | 224 |
| 218 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; | 225 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; |
| 219 | 226 |
| 220 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; | 227 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; |
| 221 | 228 |
| 222 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; | 229 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; |
| 223 | 230 |
| 231 was_cache_override = (flags & RESPONSE_INFO_WAS_CACHE_OVERRIDE) != 0; | |
| 232 | |
| 224 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; | 233 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; |
| 225 | 234 |
| 226 return true; | 235 return true; |
| 227 } | 236 } |
| 228 | 237 |
| 229 void HttpResponseInfo::Persist(Pickle* pickle, | 238 void HttpResponseInfo::Persist(Pickle* pickle, |
| 230 bool skip_transient_headers, | 239 bool skip_transient_headers, |
| 231 bool response_truncated) const { | 240 bool response_truncated) const { |
| 232 int flags = RESPONSE_INFO_VERSION; | 241 int flags = RESPONSE_INFO_VERSION; |
| 233 if (ssl_info.is_valid()) { | 242 if (ssl_info.is_valid()) { |
| 234 flags |= RESPONSE_INFO_HAS_CERT; | 243 flags |= RESPONSE_INFO_HAS_CERT; |
| 235 flags |= RESPONSE_INFO_HAS_CERT_STATUS; | 244 flags |= RESPONSE_INFO_HAS_CERT_STATUS; |
| 236 if (ssl_info.security_bits != -1) | 245 if (ssl_info.security_bits != -1) |
| 237 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; | 246 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; |
| 238 if (ssl_info.connection_status != 0) | 247 if (ssl_info.connection_status != 0) |
| 239 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; | 248 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; |
| 240 } | 249 } |
| 241 if (vary_data.is_valid()) | 250 if (vary_data.is_valid()) |
| 242 flags |= RESPONSE_INFO_HAS_VARY_DATA; | 251 flags |= RESPONSE_INFO_HAS_VARY_DATA; |
| 243 if (response_truncated) | 252 if (response_truncated) |
| 244 flags |= RESPONSE_INFO_TRUNCATED; | 253 flags |= RESPONSE_INFO_TRUNCATED; |
| 245 if (was_fetched_via_spdy) | 254 if (was_fetched_via_spdy) |
| 246 flags |= RESPONSE_INFO_WAS_SPDY; | 255 flags |= RESPONSE_INFO_WAS_SPDY; |
| 247 if (was_npn_negotiated) { | 256 if (was_npn_negotiated) { |
| 248 flags |= RESPONSE_INFO_WAS_NPN; | 257 flags |= RESPONSE_INFO_WAS_NPN; |
| 249 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; | 258 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; |
| 250 } | 259 } |
| 251 if (was_fetched_via_proxy) | 260 if (was_fetched_via_proxy) |
| 252 flags |= RESPONSE_INFO_WAS_PROXY; | 261 flags |= RESPONSE_INFO_WAS_PROXY; |
| 262 if (was_cache_override) | |
| 263 flags |= RESPONSE_INFO_WAS_CACHE_OVERRIDE; | |
| 253 | 264 |
| 254 pickle->WriteInt(flags); | 265 pickle->WriteInt(flags); |
| 255 pickle->WriteInt64(request_time.ToInternalValue()); | 266 pickle->WriteInt64(request_time.ToInternalValue()); |
| 256 pickle->WriteInt64(response_time.ToInternalValue()); | 267 pickle->WriteInt64(response_time.ToInternalValue()); |
| 257 | 268 |
| 258 net::HttpResponseHeaders::PersistOptions persist_options = | 269 net::HttpResponseHeaders::PersistOptions persist_options = |
| 259 net::HttpResponseHeaders::PERSIST_RAW; | 270 net::HttpResponseHeaders::PERSIST_RAW; |
| 260 | 271 |
| 261 if (skip_transient_headers) { | 272 if (skip_transient_headers) { |
| 262 persist_options = | 273 persist_options = |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 283 vary_data.Persist(pickle); | 294 vary_data.Persist(pickle); |
| 284 | 295 |
| 285 pickle->WriteString(socket_address.host()); | 296 pickle->WriteString(socket_address.host()); |
| 286 pickle->WriteUInt16(socket_address.port()); | 297 pickle->WriteUInt16(socket_address.port()); |
| 287 | 298 |
| 288 if (was_npn_negotiated) | 299 if (was_npn_negotiated) |
| 289 pickle->WriteString(npn_negotiated_protocol); | 300 pickle->WriteString(npn_negotiated_protocol); |
| 290 } | 301 } |
| 291 | 302 |
| 292 } // namespace net | 303 } // namespace net |
| OLD | NEW |