OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 // | 668 // |
669 // TODO(agl): we might have an issue here where a request for foo.example.com | 669 // TODO(agl): we might have an issue here where a request for foo.example.com |
670 // merges into a SPDY connection to www.example.com, and gets a different | 670 // merges into a SPDY connection to www.example.com, and gets a different |
671 // certificate. | 671 // certificate. |
672 const SSLInfo& ssl_info = transaction_->GetResponseInfo()->ssl_info; | 672 const SSLInfo& ssl_info = transaction_->GetResponseInfo()->ssl_info; |
673 if (result == OK && | 673 if (result == OK && |
674 ssl_info.is_valid() && | 674 ssl_info.is_valid() && |
675 ssl_info.is_issued_by_known_root && | 675 ssl_info.is_issued_by_known_root && |
676 context_->transport_security_state()) { | 676 context_->transport_security_state()) { |
677 TransportSecurityState::DomainState domain_state; | 677 TransportSecurityState::DomainState domain_state; |
678 bool sni = SSLConfigService::IsSNIAvailable(context_->ssl_config_service()); | 678 bool sni_available = SSLConfigService::IsSNIAvailable( |
| 679 context_->ssl_config_service()); |
| 680 std::string host = request_->url().host(); |
| 681 |
679 if (context_->transport_security_state()->HasPinsForHost( | 682 if (context_->transport_security_state()->HasPinsForHost( |
680 &domain_state, | 683 &domain_state, host, sni_available)) { |
681 request_->url().host(), sni)) { | |
682 if (!domain_state.IsChainOfPublicKeysPermitted( | 684 if (!domain_state.IsChainOfPublicKeysPermitted( |
683 ssl_info.public_key_hashes)) { | 685 ssl_info.public_key_hashes)) { |
684 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; | 686 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; |
685 UMA_HISTOGRAM_BOOLEAN("Net.CertificatePinSuccess", false); | 687 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", false); |
| 688 TransportSecurityState::ReportUMAOnPinFailure(host); |
686 FraudulentCertificateReporter* reporter = | 689 FraudulentCertificateReporter* reporter = |
687 context_->fraudulent_certificate_reporter(); | 690 context_->fraudulent_certificate_reporter(); |
688 if (reporter != NULL) | 691 if (reporter != NULL) |
689 reporter->SendReport(request_->url().host(), ssl_info, sni); | 692 reporter->SendReport(host, ssl_info, sni_available); |
690 } else { | 693 } else { |
691 UMA_HISTOGRAM_BOOLEAN("Net.CertificatePinSuccess", true); | 694 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", true); |
692 } | 695 } |
693 } | 696 } |
694 } | 697 } |
695 #endif | 698 #endif |
696 if (result == OK) { | 699 if (result == OK) { |
697 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); | 700 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); |
698 if (request_->context() && request_->context()->network_delegate()) { | 701 if (request_->context() && request_->context()->network_delegate()) { |
699 // Note that |this| may not be deleted until | 702 // Note that |this| may not be deleted until |
700 // |on_headers_received_callback_| or | 703 // |on_headers_received_callback_| or |
701 // |NetworkDelegate::URLRequestDestroyed()| has been called. | 704 // |NetworkDelegate::URLRequestDestroyed()| has been called. |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 if (postfilter_bytes_read() == expected_length) { | 1105 if (postfilter_bytes_read() == expected_length) { |
1103 // Clear the error. | 1106 // Clear the error. |
1104 return true; | 1107 return true; |
1105 } | 1108 } |
1106 } | 1109 } |
1107 } | 1110 } |
1108 return false; | 1111 return false; |
1109 } | 1112 } |
1110 | 1113 |
1111 bool URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size, | 1114 bool URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size, |
1112 int *bytes_read) { | 1115 int* bytes_read) { |
1113 DCHECK_NE(buf_size, 0); | 1116 DCHECK_NE(buf_size, 0); |
1114 DCHECK(bytes_read); | 1117 DCHECK(bytes_read); |
1115 DCHECK(!read_in_progress_); | 1118 DCHECK(!read_in_progress_); |
1116 | 1119 |
1117 int rv = transaction_->Read(buf, buf_size, &read_callback_); | 1120 int rv = transaction_->Read(buf, buf_size, &read_callback_); |
1118 | 1121 |
1119 if (ShouldFixMismatchedContentLength(rv)) | 1122 if (ShouldFixMismatchedContentLength(rv)) |
1120 rv = 0; | 1123 rv = 0; |
1121 | 1124 |
1122 if (rv >= 0) { | 1125 if (rv >= 0) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 NOTREACHED(); | 1277 NOTREACHED(); |
1275 return; | 1278 return; |
1276 } | 1279 } |
1277 } | 1280 } |
1278 | 1281 |
1279 // The common type of histogram we use for all compression-tracking histograms. | 1282 // The common type of histogram we use for all compression-tracking histograms. |
1280 #define COMPRESSION_HISTOGRAM(name, sample) \ | 1283 #define COMPRESSION_HISTOGRAM(name, sample) \ |
1281 do { \ | 1284 do { \ |
1282 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.Compress." name, sample, \ | 1285 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.Compress." name, sample, \ |
1283 500, 1000000, 100); \ | 1286 500, 1000000, 100); \ |
1284 } while(0) | 1287 } while (0) |
1285 | 1288 |
1286 void URLRequestHttpJob::RecordCompressionHistograms() { | 1289 void URLRequestHttpJob::RecordCompressionHistograms() { |
1287 DCHECK(request_); | 1290 DCHECK(request_); |
1288 if (!request_) | 1291 if (!request_) |
1289 return; | 1292 return; |
1290 | 1293 |
1291 if (is_cached_content_ || // Don't record cached content | 1294 if (is_cached_content_ || // Don't record cached content |
1292 !GetStatus().is_success() || // Don't record failed content | 1295 !GetStatus().is_success() || // Don't record failed content |
1293 !IsCompressibleContent() || // Only record compressible content | 1296 !IsCompressibleContent() || // Only record compressible content |
1294 !prefilter_bytes_read()) // Zero-byte responses aren't useful. | 1297 !prefilter_bytes_read()) // Zero-byte responses aren't useful. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 return override_response_headers_.get() ? | 1426 return override_response_headers_.get() ? |
1424 override_response_headers_ : | 1427 override_response_headers_ : |
1425 transaction_->GetResponseInfo()->headers; | 1428 transaction_->GetResponseInfo()->headers; |
1426 } | 1429 } |
1427 | 1430 |
1428 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1431 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1429 awaiting_callback_ = false; | 1432 awaiting_callback_ = false; |
1430 } | 1433 } |
1431 | 1434 |
1432 } // namespace net | 1435 } // namespace net |
OLD | NEW |