| 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/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/profiler/scoped_tracker.h" |
| 16 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
| 20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
| 21 #include "net/base/mime_util.h" | 22 #include "net/base/mime_util.h" |
| 22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 23 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
| 24 #include "net/base/network_delegate.h" | 25 #include "net/base/network_delegate.h" |
| 25 #include "net/base/sdch_manager.h" | 26 #include "net/base/sdch_manager.h" |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 // If a UA receives more than one PKP header field in an HTTP | 777 // If a UA receives more than one PKP header field in an HTTP |
| 777 // response message over secure transport, then the UA MUST process | 778 // response message over secure transport, then the UA MUST process |
| 778 // only the first such header field. | 779 // only the first such header field. |
| 779 HttpResponseHeaders* headers = GetResponseHeaders(); | 780 HttpResponseHeaders* headers = GetResponseHeaders(); |
| 780 std::string value; | 781 std::string value; |
| 781 if (headers->EnumerateHeader(NULL, "Public-Key-Pins", &value)) | 782 if (headers->EnumerateHeader(NULL, "Public-Key-Pins", &value)) |
| 782 security_state->AddHPKPHeader(request_info_.url.host(), value, ssl_info); | 783 security_state->AddHPKPHeader(request_info_.url.host(), value, ssl_info); |
| 783 } | 784 } |
| 784 | 785 |
| 785 void URLRequestHttpJob::OnStartCompleted(int result) { | 786 void URLRequestHttpJob::OnStartCompleted(int result) { |
| 787 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424359 is fixed. |
| 788 tracked_objects::ScopedTracker tracking_profile( |
| 789 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 790 "424359 URLRequestHttpJob::OnStartCompleted")); |
| 791 |
| 786 RecordTimer(); | 792 RecordTimer(); |
| 787 | 793 |
| 788 // If the request was destroyed, then there is no more work to do. | 794 // If the request was destroyed, then there is no more work to do. |
| 789 if (!request_) | 795 if (!request_) |
| 790 return; | 796 return; |
| 791 | 797 |
| 792 // If the job is done (due to cancellation), can just ignore this | 798 // If the job is done (due to cancellation), can just ignore this |
| 793 // notification. | 799 // notification. |
| 794 if (done_) | 800 if (done_) |
| 795 return; | 801 return; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { | 885 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { |
| 880 awaiting_callback_ = false; | 886 awaiting_callback_ = false; |
| 881 | 887 |
| 882 // Check that there are no callbacks to already canceled requests. | 888 // Check that there are no callbacks to already canceled requests. |
| 883 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); | 889 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); |
| 884 | 890 |
| 885 SaveCookiesAndNotifyHeadersComplete(result); | 891 SaveCookiesAndNotifyHeadersComplete(result); |
| 886 } | 892 } |
| 887 | 893 |
| 888 void URLRequestHttpJob::OnReadCompleted(int result) { | 894 void URLRequestHttpJob::OnReadCompleted(int result) { |
| 895 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424359 is fixed. |
| 896 tracked_objects::ScopedTracker tracking_profile( |
| 897 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 898 "424359 URLRequestHttpJob::OnReadCompleted")); |
| 899 |
| 889 read_in_progress_ = false; | 900 read_in_progress_ = false; |
| 890 | 901 |
| 891 if (ShouldFixMismatchedContentLength(result)) | 902 if (ShouldFixMismatchedContentLength(result)) |
| 892 result = OK; | 903 result = OK; |
| 893 | 904 |
| 894 if (result == OK) { | 905 if (result == OK) { |
| 895 NotifyDone(URLRequestStatus()); | 906 NotifyDone(URLRequestStatus()); |
| 896 } else if (result < 0) { | 907 } else if (result < 0) { |
| 897 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 908 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 898 } else { | 909 } else { |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 return override_response_headers_.get() ? | 1528 return override_response_headers_.get() ? |
| 1518 override_response_headers_.get() : | 1529 override_response_headers_.get() : |
| 1519 transaction_->GetResponseInfo()->headers.get(); | 1530 transaction_->GetResponseInfo()->headers.get(); |
| 1520 } | 1531 } |
| 1521 | 1532 |
| 1522 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1533 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1523 awaiting_callback_ = false; | 1534 awaiting_callback_ = false; |
| 1524 } | 1535 } |
| 1525 | 1536 |
| 1526 } // namespace net | 1537 } // namespace net |
| OLD | NEW |