| 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.h" | 5 #include "net/url_request/url_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/metrics/stats_counters.h" | 14 #include "base/metrics/stats_counters.h" |
| 15 #include "base/stl_util.h" |
| 15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 16 #include "net/base/auth.h" | 17 #include "net/base/auth.h" |
| 17 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 18 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
| 19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
| 21 #include "net/base/network_delegate.h" | 22 #include "net/base/network_delegate.h" |
| 22 #include "net/base/ssl_cert_request_info.h" | 23 #include "net/base/ssl_cert_request_info.h" |
| 23 #include "net/base/upload_data.h" | 24 #include "net/base/upload_data.h" |
| 24 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 PrepareToRestart(); | 708 PrepareToRestart(); |
| 708 Start(); | 709 Start(); |
| 709 return OK; | 710 return OK; |
| 710 } | 711 } |
| 711 | 712 |
| 712 const URLRequestContext* URLRequest::context() const { | 713 const URLRequestContext* URLRequest::context() const { |
| 713 return context_.get(); | 714 return context_.get(); |
| 714 } | 715 } |
| 715 | 716 |
| 716 void URLRequest::set_context(const URLRequestContext* context) { | 717 void URLRequest::set_context(const URLRequestContext* context) { |
| 718 // Update the URLRequest lists in the URLRequestContext. |
| 719 if (context_) { |
| 720 std::set<const URLRequest*>* url_requests = context_->url_requests(); |
| 721 CHECK(ContainsKey(*url_requests, this)); |
| 722 url_requests->erase(this); |
| 723 } |
| 724 |
| 725 if (context) { |
| 726 std::set<const URLRequest*>* url_requests = context->url_requests(); |
| 727 CHECK(!ContainsKey(*url_requests, this)); |
| 728 url_requests->insert(this); |
| 729 } |
| 730 |
| 717 scoped_refptr<const URLRequestContext> prev_context = context_; | 731 scoped_refptr<const URLRequestContext> prev_context = context_; |
| 718 | 732 |
| 719 context_ = context; | 733 context_ = context; |
| 720 | 734 |
| 721 // If the context this request belongs to has changed, update the tracker. | 735 // If the context this request belongs to has changed, update the tracker. |
| 722 if (prev_context != context) { | 736 if (prev_context != context) { |
| 723 int net_error = OK; | 737 int net_error = OK; |
| 724 // Log error only on failure, not cancellation, as even successful requests | 738 // Log error only on failure, not cancellation, as even successful requests |
| 725 // are "cancelled" on destruction. | 739 // are "cancelled" on destruction. |
| 726 if (status_.status() == URLRequestStatus::FAILED) | 740 if (status_.status() == URLRequestStatus::FAILED) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 | 878 |
| 865 void URLRequest::SetUnblockedOnDelegate() { | 879 void URLRequest::SetUnblockedOnDelegate() { |
| 866 if (!blocked_on_delegate_) | 880 if (!blocked_on_delegate_) |
| 867 return; | 881 return; |
| 868 blocked_on_delegate_ = false; | 882 blocked_on_delegate_ = false; |
| 869 load_state_param_.clear(); | 883 load_state_param_.clear(); |
| 870 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 884 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
| 871 } | 885 } |
| 872 | 886 |
| 873 } // namespace net | 887 } // namespace net |
| OLD | NEW |