| 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/trace_event/trace_event.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 10 #include "net/base/auth.h" | 11 #include "net/base/auth.h" |
| 11 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "net/cert/signed_certificate_timestamp.h" | 14 #include "net/cert/signed_certificate_timestamp.h" |
| 14 #include "net/cert/x509_certificate.h" | 15 #include "net/cert/x509_certificate.h" |
| 15 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
| 16 #include "net/ssl/ssl_cert_request_info.h" | 17 #include "net/ssl/ssl_cert_request_info.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 request_time(rhs.request_time), | 130 request_time(rhs.request_time), |
| 130 response_time(rhs.response_time), | 131 response_time(rhs.response_time), |
| 131 auth_challenge(rhs.auth_challenge), | 132 auth_challenge(rhs.auth_challenge), |
| 132 cert_request_info(rhs.cert_request_info), | 133 cert_request_info(rhs.cert_request_info), |
| 133 ssl_info(rhs.ssl_info), | 134 ssl_info(rhs.ssl_info), |
| 134 headers(rhs.headers), | 135 headers(rhs.headers), |
| 135 vary_data(rhs.vary_data), | 136 vary_data(rhs.vary_data), |
| 136 metadata(rhs.metadata) {} | 137 metadata(rhs.metadata) {} |
| 137 | 138 |
| 138 HttpResponseInfo::~HttpResponseInfo() { | 139 HttpResponseInfo::~HttpResponseInfo() { |
| 140 TRACE_EVENT0("toplevel", "HttpResponseInfo::~HttpResponseInfo"); |
| 139 } | 141 } |
| 140 | 142 |
| 141 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { | 143 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { |
| 142 was_cached = rhs.was_cached; | 144 was_cached = rhs.was_cached; |
| 143 server_data_unavailable = rhs.server_data_unavailable; | 145 server_data_unavailable = rhs.server_data_unavailable; |
| 144 network_accessed = rhs.network_accessed; | 146 network_accessed = rhs.network_accessed; |
| 145 was_fetched_via_spdy = rhs.was_fetched_via_spdy; | 147 was_fetched_via_spdy = rhs.was_fetched_via_spdy; |
| 146 proxy_server = rhs.proxy_server; | 148 proxy_server = rhs.proxy_server; |
| 147 was_npn_negotiated = rhs.was_npn_negotiated; | 149 was_npn_negotiated = rhs.was_npn_negotiated; |
| 148 was_fetched_via_proxy = rhs.was_fetched_via_proxy; | 150 was_fetched_via_proxy = rhs.was_fetched_via_proxy; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 160 headers = rhs.headers; | 162 headers = rhs.headers; |
| 161 vary_data = rhs.vary_data; | 163 vary_data = rhs.vary_data; |
| 162 metadata = rhs.metadata; | 164 metadata = rhs.metadata; |
| 163 return *this; | 165 return *this; |
| 164 } | 166 } |
| 165 | 167 |
| 166 bool HttpResponseInfo::InitFromPickle(const base::Pickle& pickle, | 168 bool HttpResponseInfo::InitFromPickle(const base::Pickle& pickle, |
| 167 bool* response_truncated) { | 169 bool* response_truncated) { |
| 168 base::PickleIterator iter(pickle); | 170 base::PickleIterator iter(pickle); |
| 169 | 171 |
| 172 TRACE_EVENT0("toplevel", "HttpResponseInfo::InitFromPickle::A"); |
| 173 |
| 170 // Read flags and verify version | 174 // Read flags and verify version |
| 171 int flags; | 175 int flags; |
| 172 if (!iter.ReadInt(&flags)) | 176 if (!iter.ReadInt(&flags)) |
| 173 return false; | 177 return false; |
| 174 int version = flags & RESPONSE_INFO_VERSION_MASK; | 178 int version = flags & RESPONSE_INFO_VERSION_MASK; |
| 175 if (version < RESPONSE_INFO_MINIMUM_VERSION || | 179 if (version < RESPONSE_INFO_MINIMUM_VERSION || |
| 176 version > RESPONSE_INFO_VERSION) { | 180 version > RESPONSE_INFO_VERSION) { |
| 177 DLOG(ERROR) << "unexpected response info version: " << version; | 181 DLOG(ERROR) << "unexpected response info version: " << version; |
| 178 return false; | 182 return false; |
| 179 } | 183 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 195 if (headers->response_code() == -1) | 199 if (headers->response_code() == -1) |
| 196 return false; | 200 return false; |
| 197 | 201 |
| 198 // Read ssl-info | 202 // Read ssl-info |
| 199 if (flags & RESPONSE_INFO_HAS_CERT) { | 203 if (flags & RESPONSE_INFO_HAS_CERT) { |
| 200 X509Certificate::PickleType type = GetPickleTypeForVersion(version); | 204 X509Certificate::PickleType type = GetPickleTypeForVersion(version); |
| 201 ssl_info.cert = X509Certificate::CreateFromPickle(&iter, type); | 205 ssl_info.cert = X509Certificate::CreateFromPickle(&iter, type); |
| 202 if (!ssl_info.cert.get()) | 206 if (!ssl_info.cert.get()) |
| 203 return false; | 207 return false; |
| 204 } | 208 } |
| 209 |
| 205 if (flags & RESPONSE_INFO_HAS_CERT_STATUS) { | 210 if (flags & RESPONSE_INFO_HAS_CERT_STATUS) { |
| 206 CertStatus cert_status; | 211 CertStatus cert_status; |
| 207 if (!iter.ReadUInt32(&cert_status)) | 212 if (!iter.ReadUInt32(&cert_status)) |
| 208 return false; | 213 return false; |
| 209 ssl_info.cert_status = cert_status; | 214 ssl_info.cert_status = cert_status; |
| 210 } | 215 } |
| 216 |
| 211 if (flags & RESPONSE_INFO_HAS_SECURITY_BITS) { | 217 if (flags & RESPONSE_INFO_HAS_SECURITY_BITS) { |
| 212 int security_bits; | 218 int security_bits; |
| 213 if (!iter.ReadInt(&security_bits)) | 219 if (!iter.ReadInt(&security_bits)) |
| 214 return false; | 220 return false; |
| 215 ssl_info.security_bits = security_bits; | 221 ssl_info.security_bits = security_bits; |
| 216 } | 222 } |
| 217 | 223 |
| 218 if (flags & RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS) { | 224 if (flags & RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS) { |
| 219 int connection_status; | 225 int connection_status; |
| 220 if (!iter.ReadInt(&connection_status)) | 226 if (!iter.ReadInt(&connection_status)) |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 case CONNECTION_INFO_QUIC1_SPDY3: | 435 case CONNECTION_INFO_QUIC1_SPDY3: |
| 430 return "quic/1+spdy/3"; | 436 return "quic/1+spdy/3"; |
| 431 case NUM_OF_CONNECTION_INFOS: | 437 case NUM_OF_CONNECTION_INFOS: |
| 432 break; | 438 break; |
| 433 } | 439 } |
| 434 NOTREACHED(); | 440 NOTREACHED(); |
| 435 return ""; | 441 return ""; |
| 436 } | 442 } |
| 437 | 443 |
| 438 } // namespace net | 444 } // namespace net |
| OLD | NEW |