| 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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 // Only process the first Expect-CT header value. | 979 // Only process the first Expect-CT header value. |
| 979 HttpResponseHeaders* headers = GetResponseHeaders(); | 980 HttpResponseHeaders* headers = GetResponseHeaders(); |
| 980 std::string value; | 981 std::string value; |
| 981 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { | 982 if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { |
| 982 security_state->ProcessExpectCTHeader( | 983 security_state->ProcessExpectCTHeader( |
| 983 value, HostPortPair::FromURL(request_info_.url), ssl_info); | 984 value, HostPortPair::FromURL(request_info_.url), ssl_info); |
| 984 } | 985 } |
| 985 } | 986 } |
| 986 | 987 |
| 987 void URLRequestHttpJob::OnStartCompleted(int result) { | 988 void URLRequestHttpJob::OnStartCompleted(int result) { |
| 989 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 990 "URLRequestHttpJob::OnStartCompleted"); |
| 988 RecordTimer(); | 991 RecordTimer(); |
| 989 | 992 |
| 990 // If the request was destroyed, then there is no more work to do. | 993 // If the request was destroyed, then there is no more work to do. |
| 991 if (!request_) | 994 if (!request_) |
| 992 return; | 995 return; |
| 993 | 996 |
| 994 // If the job is done (due to cancellation), can just ignore this | 997 // If the job is done (due to cancellation), can just ignore this |
| 995 // notification. | 998 // notification. |
| 996 if (done_) | 999 if (done_) |
| 997 return; | 1000 return; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { | 1089 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { |
| 1087 awaiting_callback_ = false; | 1090 awaiting_callback_ = false; |
| 1088 | 1091 |
| 1089 // Check that there are no callbacks to already canceled requests. | 1092 // Check that there are no callbacks to already canceled requests. |
| 1090 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); | 1093 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); |
| 1091 | 1094 |
| 1092 SaveCookiesAndNotifyHeadersComplete(result); | 1095 SaveCookiesAndNotifyHeadersComplete(result); |
| 1093 } | 1096 } |
| 1094 | 1097 |
| 1095 void URLRequestHttpJob::OnReadCompleted(int result) { | 1098 void URLRequestHttpJob::OnReadCompleted(int result) { |
| 1099 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 1100 "URLRequestHttpJob::OnReadCompleted"); |
| 1096 read_in_progress_ = false; | 1101 read_in_progress_ = false; |
| 1097 | 1102 |
| 1098 DCHECK_NE(ERR_IO_PENDING, result); | 1103 DCHECK_NE(ERR_IO_PENDING, result); |
| 1099 | 1104 |
| 1100 if (ShouldFixMismatchedContentLength(result)) | 1105 if (ShouldFixMismatchedContentLength(result)) |
| 1101 result = OK; | 1106 result = OK; |
| 1102 | 1107 |
| 1103 // EOF or error, done with this job. | 1108 // EOF or error, done with this job. |
| 1104 if (result <= 0) | 1109 if (result <= 0) |
| 1105 DoneWithRequest(FINISHED); | 1110 DoneWithRequest(FINISHED); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 return override_response_headers_.get() ? | 1665 return override_response_headers_.get() ? |
| 1661 override_response_headers_.get() : | 1666 override_response_headers_.get() : |
| 1662 transaction_->GetResponseInfo()->headers.get(); | 1667 transaction_->GetResponseInfo()->headers.get(); |
| 1663 } | 1668 } |
| 1664 | 1669 |
| 1665 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1670 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1666 awaiting_callback_ = false; | 1671 awaiting_callback_ = false; |
| 1667 } | 1672 } |
| 1668 | 1673 |
| 1669 } // namespace net | 1674 } // namespace net |
| OLD | NEW |