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 "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "base/trace_event/trace_event.h" |
23 #include "base/values.h" | 24 #include "base/values.h" |
24 #include "net/base/host_port_pair.h" | 25 #include "net/base/host_port_pair.h" |
25 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
26 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
27 #include "net/base/network_delegate.h" | 28 #include "net/base/network_delegate.h" |
28 #include "net/base/network_quality_estimator.h" | 29 #include "net/base/network_quality_estimator.h" |
29 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 30 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
30 #include "net/base/sdch_manager.h" | 31 #include "net/base/sdch_manager.h" |
31 #include "net/base/sdch_net_log_params.h" | 32 #include "net/base/sdch_net_log_params.h" |
32 #include "net/base/url_util.h" | 33 #include "net/base/url_util.h" |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 // Only process the first Expect-CT header value. | 948 // Only process the first Expect-CT header value. |
948 HttpResponseHeaders* headers = GetResponseHeaders(); | 949 HttpResponseHeaders* headers = GetResponseHeaders(); |
949 std::string value; | 950 std::string value; |
950 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { | 951 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { |
951 security_state->ProcessExpectCTHeader( | 952 security_state->ProcessExpectCTHeader( |
952 value, HostPortPair::FromURL(request_info_.url), ssl_info); | 953 value, HostPortPair::FromURL(request_info_.url), ssl_info); |
953 } | 954 } |
954 } | 955 } |
955 | 956 |
956 void URLRequestHttpJob::OnStartCompleted(int result) { | 957 void URLRequestHttpJob::OnStartCompleted(int result) { |
| 958 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 959 "URLRequestHttpJob::OnStartCompleted"); |
957 RecordTimer(); | 960 RecordTimer(); |
958 | 961 |
959 // If the request was destroyed, then there is no more work to do. | 962 // If the request was destroyed, then there is no more work to do. |
960 if (!request_) | 963 if (!request_) |
961 return; | 964 return; |
962 | 965 |
963 // If the job is done (due to cancellation), can just ignore this | 966 // If the job is done (due to cancellation), can just ignore this |
964 // notification. | 967 // notification. |
965 if (done_) | 968 if (done_) |
966 return; | 969 return; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { | 1058 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { |
1056 awaiting_callback_ = false; | 1059 awaiting_callback_ = false; |
1057 | 1060 |
1058 // Check that there are no callbacks to already canceled requests. | 1061 // Check that there are no callbacks to already canceled requests. |
1059 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); | 1062 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); |
1060 | 1063 |
1061 SaveCookiesAndNotifyHeadersComplete(result); | 1064 SaveCookiesAndNotifyHeadersComplete(result); |
1062 } | 1065 } |
1063 | 1066 |
1064 void URLRequestHttpJob::OnReadCompleted(int result) { | 1067 void URLRequestHttpJob::OnReadCompleted(int result) { |
| 1068 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 1069 "URLRequestHttpJob::OnReadCompleted"); |
1065 read_in_progress_ = false; | 1070 read_in_progress_ = false; |
1066 | 1071 |
1067 DCHECK_NE(ERR_IO_PENDING, result); | 1072 DCHECK_NE(ERR_IO_PENDING, result); |
1068 | 1073 |
1069 if (ShouldFixMismatchedContentLength(result)) | 1074 if (ShouldFixMismatchedContentLength(result)) |
1070 result = OK; | 1075 result = OK; |
1071 | 1076 |
1072 // EOF or error, done with this job. | 1077 // EOF or error, done with this job. |
1073 if (result <= 0) | 1078 if (result <= 0) |
1074 DoneWithRequest(FINISHED); | 1079 DoneWithRequest(FINISHED); |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 return override_response_headers_.get() ? | 1634 return override_response_headers_.get() ? |
1630 override_response_headers_.get() : | 1635 override_response_headers_.get() : |
1631 transaction_->GetResponseInfo()->headers.get(); | 1636 transaction_->GetResponseInfo()->headers.get(); |
1632 } | 1637 } |
1633 | 1638 |
1634 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1639 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1635 awaiting_callback_ = false; | 1640 awaiting_callback_ = false; |
1636 } | 1641 } |
1637 | 1642 |
1638 } // namespace net | 1643 } // namespace net |
OLD | NEW |