| 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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "net/url_request/url_request_redirect_job.h" | 68 #include "net/url_request/url_request_redirect_job.h" |
| 69 #include "net/url_request/url_request_throttler_manager.h" | 69 #include "net/url_request/url_request_throttler_manager.h" |
| 70 #include "net/websockets/websocket_handshake_stream_base.h" | 70 #include "net/websockets/websocket_handshake_stream_base.h" |
| 71 #include "url/origin.h" | 71 #include "url/origin.h" |
| 72 | 72 |
| 73 #if defined(OS_ANDROID) | 73 #if defined(OS_ANDROID) |
| 74 #include "net/android/network_library.h" | 74 #include "net/android/network_library.h" |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 #if BUILDFLAG(ENABLE_REPORTING) | 77 #if BUILDFLAG(ENABLE_REPORTING) |
| 78 #include "net/reporting/reporting_header_parser.h" |
| 78 #include "net/reporting/reporting_service.h" | 79 #include "net/reporting/reporting_service.h" |
| 79 #endif // BUILDFLAG(ENABLE_REPORTING) | 80 #endif // BUILDFLAG(ENABLE_REPORTING) |
| 80 | 81 |
| 81 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; | 82 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; |
| 82 | 83 |
| 83 namespace { | 84 namespace { |
| 84 | 85 |
| 85 // Logs whether the CookieStore used for this request matches the | 86 // Logs whether the CookieStore used for this request matches the |
| 86 // ChannelIDService used when establishing the connection that this request is | 87 // ChannelIDService used when establishing the connection that this request is |
| 87 // sent over. This logging is only done for requests to accounts.google.com, and | 88 // sent over. This logging is only done for requests to accounts.google.com, and |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { | 852 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { |
| 852 security_state->ProcessExpectCTHeader( | 853 security_state->ProcessExpectCTHeader( |
| 853 value, HostPortPair::FromURL(request_info_.url), ssl_info); | 854 value, HostPortPair::FromURL(request_info_.url), ssl_info); |
| 854 } | 855 } |
| 855 } | 856 } |
| 856 | 857 |
| 857 void URLRequestHttpJob::ProcessReportToHeader() { | 858 void URLRequestHttpJob::ProcessReportToHeader() { |
| 858 DCHECK(response_info_); | 859 DCHECK(response_info_); |
| 859 | 860 |
| 860 #if BUILDFLAG(ENABLE_REPORTING) | 861 #if BUILDFLAG(ENABLE_REPORTING) |
| 862 HttpResponseHeaders* headers = GetResponseHeaders(); |
| 863 std::string value; |
| 864 if (!headers->GetNormalizedHeader("Report-To", &value)) |
| 865 return; |
| 866 |
| 861 ReportingService* service = request_->context()->reporting_service(); | 867 ReportingService* service = request_->context()->reporting_service(); |
| 862 if (!service) | 868 if (!service) { |
| 869 ReportingHeaderParser::RecordHeaderDiscardedForNoReportingService(); |
| 863 return; | 870 return; |
| 871 } |
| 864 | 872 |
| 865 // Only accept Report-To headers on HTTPS connections that have no | 873 // Only accept Report-To headers on HTTPS connections that have no |
| 866 // certificate errors. | 874 // certificate errors. |
| 867 // TODO(juliatuttle): Do we need to check cert status? | 875 // TODO(juliatuttle): Do we need to check cert status? |
| 868 const SSLInfo& ssl_info = response_info_->ssl_info; | 876 const SSLInfo& ssl_info = response_info_->ssl_info; |
| 869 if (!ssl_info.is_valid() || IsCertStatusError(ssl_info.cert_status)) | 877 if (!ssl_info.is_valid()) { |
| 878 ReportingHeaderParser::RecordHeaderDiscardedForInvalidSSLInfo(); |
| 870 return; | 879 return; |
| 871 | 880 } |
| 872 HttpResponseHeaders* headers = GetResponseHeaders(); | 881 if (IsCertStatusError(ssl_info.cert_status)) { |
| 873 std::string value; | 882 ReportingHeaderParser::RecordHeaderDiscardedForCertStatusError(); |
| 874 if (!headers->GetNormalizedHeader("Report-To", &value)) | |
| 875 return; | 883 return; |
| 884 } |
| 876 | 885 |
| 877 service->ProcessHeader(request_info_.url.GetOrigin(), value); | 886 service->ProcessHeader(request_info_.url.GetOrigin(), value); |
| 878 #endif // BUILDFLAG(ENABLE_REPORTING) | 887 #endif // BUILDFLAG(ENABLE_REPORTING) |
| 879 } | 888 } |
| 880 | 889 |
| 881 void URLRequestHttpJob::OnStartCompleted(int result) { | 890 void URLRequestHttpJob::OnStartCompleted(int result) { |
| 882 TRACE_EVENT0(kNetTracingCategory, "URLRequestHttpJob::OnStartCompleted"); | 891 TRACE_EVENT0(kNetTracingCategory, "URLRequestHttpJob::OnStartCompleted"); |
| 883 RecordTimer(); | 892 RecordTimer(); |
| 884 | 893 |
| 885 // If the job is done (due to cancellation), can just ignore this | 894 // If the job is done (due to cancellation), can just ignore this |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1584 awaiting_callback_ = false; | 1593 awaiting_callback_ = false; |
| 1585 | 1594 |
| 1586 // Notify NetworkQualityEstimator. | 1595 // Notify NetworkQualityEstimator. |
| 1587 NetworkQualityEstimator* network_quality_estimator = | 1596 NetworkQualityEstimator* network_quality_estimator = |
| 1588 request()->context()->network_quality_estimator(); | 1597 request()->context()->network_quality_estimator(); |
| 1589 if (network_quality_estimator) | 1598 if (network_quality_estimator) |
| 1590 network_quality_estimator->NotifyURLRequestDestroyed(*request()); | 1599 network_quality_estimator->NotifyURLRequestDestroyed(*request()); |
| 1591 } | 1600 } |
| 1592 | 1601 |
| 1593 } // namespace net | 1602 } // namespace net |
| OLD | NEW |