| 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/file_version_info.h" | 14 #include "base/file_version_info.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/profiler/scoped_tracker.h" | 19 #include "base/profiler/scoped_tracker.h" |
| 20 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
| 21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "build/buildflag.h" |
| 27 #include "net/base/host_port_pair.h" | 28 #include "net/base/host_port_pair.h" |
| 28 #include "net/base/load_flags.h" | 29 #include "net/base/load_flags.h" |
| 29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 30 #include "net/base/network_delegate.h" | 31 #include "net/base/network_delegate.h" |
| 31 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 32 #include "net/base/sdch_manager.h" | 33 #include "net/base/sdch_manager.h" |
| 33 #include "net/base/sdch_problem_codes.h" | 34 #include "net/base/sdch_problem_codes.h" |
| 34 #include "net/base/trace_constants.h" | 35 #include "net/base/trace_constants.h" |
| 35 #include "net/base/url_util.h" | 36 #include "net/base/url_util.h" |
| 36 #include "net/cert/cert_status_flags.h" | 37 #include "net/cert/cert_status_flags.h" |
| 37 #include "net/cookies/cookie_store.h" | 38 #include "net/cookies/cookie_store.h" |
| 38 #include "net/filter/brotli_source_stream.h" | 39 #include "net/filter/brotli_source_stream.h" |
| 39 #include "net/filter/filter_source_stream.h" | 40 #include "net/filter/filter_source_stream.h" |
| 40 #include "net/filter/gzip_source_stream.h" | 41 #include "net/filter/gzip_source_stream.h" |
| 41 #include "net/filter/sdch_source_stream.h" | 42 #include "net/filter/sdch_source_stream.h" |
| 42 #include "net/filter/source_stream.h" | 43 #include "net/filter/source_stream.h" |
| 43 #include "net/http/http_content_disposition.h" | 44 #include "net/http/http_content_disposition.h" |
| 44 #include "net/http/http_network_session.h" | 45 #include "net/http/http_network_session.h" |
| 45 #include "net/http/http_request_headers.h" | 46 #include "net/http/http_request_headers.h" |
| 46 #include "net/http/http_response_headers.h" | 47 #include "net/http/http_response_headers.h" |
| 47 #include "net/http/http_response_info.h" | 48 #include "net/http/http_response_info.h" |
| 48 #include "net/http/http_status_code.h" | 49 #include "net/http/http_status_code.h" |
| 49 #include "net/http/http_transaction.h" | 50 #include "net/http/http_transaction.h" |
| 50 #include "net/http/http_transaction_factory.h" | 51 #include "net/http/http_transaction_factory.h" |
| 51 #include "net/http/http_util.h" | 52 #include "net/http/http_util.h" |
| 52 #include "net/log/net_log_event_type.h" | 53 #include "net/log/net_log_event_type.h" |
| 53 #include "net/log/net_log_with_source.h" | 54 #include "net/log/net_log_with_source.h" |
| 55 #include "net/net_features.h" |
| 54 #include "net/nqe/network_quality_estimator.h" | 56 #include "net/nqe/network_quality_estimator.h" |
| 55 #include "net/proxy/proxy_info.h" | 57 #include "net/proxy/proxy_info.h" |
| 56 #include "net/proxy/proxy_retry_info.h" | 58 #include "net/proxy/proxy_retry_info.h" |
| 57 #include "net/proxy/proxy_service.h" | 59 #include "net/proxy/proxy_service.h" |
| 58 #include "net/reporting/reporting_service.h" | |
| 59 #include "net/ssl/channel_id_service.h" | 60 #include "net/ssl/channel_id_service.h" |
| 60 #include "net/ssl/ssl_cert_request_info.h" | 61 #include "net/ssl/ssl_cert_request_info.h" |
| 61 #include "net/ssl/ssl_config_service.h" | 62 #include "net/ssl/ssl_config_service.h" |
| 62 #include "net/url_request/http_user_agent_settings.h" | 63 #include "net/url_request/http_user_agent_settings.h" |
| 63 #include "net/url_request/url_request.h" | 64 #include "net/url_request/url_request.h" |
| 64 #include "net/url_request/url_request_context.h" | 65 #include "net/url_request/url_request_context.h" |
| 65 #include "net/url_request/url_request_error_job.h" | 66 #include "net/url_request/url_request_error_job.h" |
| 66 #include "net/url_request/url_request_job_factory.h" | 67 #include "net/url_request/url_request_job_factory.h" |
| 67 #include "net/url_request/url_request_redirect_job.h" | 68 #include "net/url_request/url_request_redirect_job.h" |
| 68 #include "net/url_request/url_request_throttler_manager.h" | 69 #include "net/url_request/url_request_throttler_manager.h" |
| 69 #include "net/websockets/websocket_handshake_stream_base.h" | 70 #include "net/websockets/websocket_handshake_stream_base.h" |
| 70 #include "url/origin.h" | 71 #include "url/origin.h" |
| 71 | 72 |
| 72 #if defined(OS_ANDROID) | 73 #if defined(OS_ANDROID) |
| 73 #include "net/android/network_library.h" | 74 #include "net/android/network_library.h" |
| 74 #endif | 75 #endif |
| 75 | 76 |
| 77 #if BUILDFLAG(ENABLE_REPORTING) |
| 78 #include "net/reporting/reporting_service.h" |
| 79 #endif // BUILDFLAG(ENABLE_REPORTING) |
| 80 |
| 76 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; | 81 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; |
| 77 | 82 |
| 78 namespace { | 83 namespace { |
| 79 | 84 |
| 80 // Logs whether the CookieStore used for this request matches the | 85 // Logs whether the CookieStore used for this request matches the |
| 81 // ChannelIDService used when establishing the connection that this request is | 86 // ChannelIDService used when establishing the connection that this request is |
| 82 // sent over. This logging is only done for requests to accounts.google.com, and | 87 // sent over. This logging is only done for requests to accounts.google.com, and |
| 83 // only for requests where Channel ID was sent when establishing the connection. | 88 // only for requests where Channel ID was sent when establishing the connection. |
| 84 void LogChannelIDAndCookieStores(const GURL& url, | 89 void LogChannelIDAndCookieStores(const GURL& url, |
| 85 const net::URLRequestContext* context, | 90 const net::URLRequestContext* context, |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 std::string value; | 850 std::string value; |
| 846 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { | 851 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { |
| 847 security_state->ProcessExpectCTHeader( | 852 security_state->ProcessExpectCTHeader( |
| 848 value, HostPortPair::FromURL(request_info_.url), ssl_info); | 853 value, HostPortPair::FromURL(request_info_.url), ssl_info); |
| 849 } | 854 } |
| 850 } | 855 } |
| 851 | 856 |
| 852 void URLRequestHttpJob::ProcessReportToHeader() { | 857 void URLRequestHttpJob::ProcessReportToHeader() { |
| 853 DCHECK(response_info_); | 858 DCHECK(response_info_); |
| 854 | 859 |
| 860 #if BUILDFLAG(ENABLE_REPORTING) |
| 855 ReportingService* service = request_->context()->reporting_service(); | 861 ReportingService* service = request_->context()->reporting_service(); |
| 856 if (!service) | 862 if (!service) |
| 857 return; | 863 return; |
| 858 | 864 |
| 859 // Only accept Report-To headers on HTTPS connections that have no | 865 // Only accept Report-To headers on HTTPS connections that have no |
| 860 // certificate errors. | 866 // certificate errors. |
| 861 // TODO(juliatuttle): Do we need to check cert status? | 867 // TODO(juliatuttle): Do we need to check cert status? |
| 862 const SSLInfo& ssl_info = response_info_->ssl_info; | 868 const SSLInfo& ssl_info = response_info_->ssl_info; |
| 863 if (!ssl_info.is_valid() || IsCertStatusError(ssl_info.cert_status)) | 869 if (!ssl_info.is_valid() || IsCertStatusError(ssl_info.cert_status)) |
| 864 return; | 870 return; |
| 865 | 871 |
| 866 HttpResponseHeaders* headers = GetResponseHeaders(); | 872 HttpResponseHeaders* headers = GetResponseHeaders(); |
| 867 std::string value; | 873 std::string value; |
| 868 if (!headers->GetNormalizedHeader("Report-To", &value)) | 874 if (!headers->GetNormalizedHeader("Report-To", &value)) |
| 869 return; | 875 return; |
| 870 | 876 |
| 871 service->ProcessHeader(request_info_.url.GetOrigin(), value); | 877 service->ProcessHeader(request_info_.url.GetOrigin(), value); |
| 878 #endif // BUILDFLAG(ENABLE_REPORTING) |
| 872 } | 879 } |
| 873 | 880 |
| 874 void URLRequestHttpJob::OnStartCompleted(int result) { | 881 void URLRequestHttpJob::OnStartCompleted(int result) { |
| 875 TRACE_EVENT0(kNetTracingCategory, "URLRequestHttpJob::OnStartCompleted"); | 882 TRACE_EVENT0(kNetTracingCategory, "URLRequestHttpJob::OnStartCompleted"); |
| 876 RecordTimer(); | 883 RecordTimer(); |
| 877 | 884 |
| 878 // If the job is done (due to cancellation), can just ignore this | 885 // If the job is done (due to cancellation), can just ignore this |
| 879 // notification. | 886 // notification. |
| 880 if (done_) | 887 if (done_) |
| 881 return; | 888 return; |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 awaiting_callback_ = false; | 1583 awaiting_callback_ = false; |
| 1577 | 1584 |
| 1578 // Notify NetworkQualityEstimator. | 1585 // Notify NetworkQualityEstimator. |
| 1579 NetworkQualityEstimator* network_quality_estimator = | 1586 NetworkQualityEstimator* network_quality_estimator = |
| 1580 request()->context()->network_quality_estimator(); | 1587 request()->context()->network_quality_estimator(); |
| 1581 if (network_quality_estimator) | 1588 if (network_quality_estimator) |
| 1582 network_quality_estimator->NotifyURLRequestDestroyed(*request()); | 1589 network_quality_estimator->NotifyURLRequestDestroyed(*request()); |
| 1583 } | 1590 } |
| 1584 | 1591 |
| 1585 } // namespace net | 1592 } // namespace net |
| OLD | NEW |