Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: net/url_request/url_request.cc

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize to NULL Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, 125 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request,
126 const SSLInfo& ssl_info, 126 const SSLInfo& ssl_info,
127 bool is_hsts_ok) { 127 bool is_hsts_ok) {
128 request->Cancel(); 128 request->Cancel();
129 } 129 }
130 130
131 /////////////////////////////////////////////////////////////////////////////// 131 ///////////////////////////////////////////////////////////////////////////////
132 // URLRequest 132 // URLRequest
133 133
134 URLRequest::URLRequest(const GURL& url, Delegate* delegate) 134 URLRequest::URLRequest(const GURL& url, Delegate* delegate)
135 : url_chain_(1, url), 135 : context_(NULL),
136 url_chain_(1, url),
136 method_("GET"), 137 method_("GET"),
137 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), 138 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
138 load_flags_(LOAD_NORMAL), 139 load_flags_(LOAD_NORMAL),
139 delegate_(delegate), 140 delegate_(delegate),
140 is_pending_(false), 141 is_pending_(false),
141 redirect_limit_(kMaxRedirects), 142 redirect_limit_(kMaxRedirects),
142 final_upload_progress_(0), 143 final_upload_progress_(0),
143 priority_(LOWEST), 144 priority_(LOWEST),
144 identifier_(GenerateURLRequestIdentifier()), 145 identifier_(GenerateURLRequestIdentifier()),
145 blocked_on_delegate_(false), 146 blocked_on_delegate_(false),
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 715
715 if (!final_upload_progress_) 716 if (!final_upload_progress_)
716 final_upload_progress_ = job_->GetUploadProgress(); 717 final_upload_progress_ = job_->GetUploadProgress();
717 718
718 PrepareToRestart(); 719 PrepareToRestart();
719 Start(); 720 Start();
720 return OK; 721 return OK;
721 } 722 }
722 723
723 const URLRequestContext* URLRequest::context() const { 724 const URLRequestContext* URLRequest::context() const {
724 return context_.get(); 725 return context_;
725 } 726 }
726 727
727 void URLRequest::set_context(const URLRequestContext* context) { 728 void URLRequest::set_context(const URLRequestContext* context) {
728 // Update the URLRequest lists in the URLRequestContext. 729 // Update the URLRequest lists in the URLRequestContext.
729 if (context_) { 730 if (context_) {
730 std::set<const URLRequest*>* url_requests = context_->url_requests(); 731 std::set<const URLRequest*>* url_requests = context_->url_requests();
731 CHECK(ContainsKey(*url_requests, this)); 732 CHECK(ContainsKey(*url_requests, this));
732 url_requests->erase(this); 733 url_requests->erase(this);
733 } 734 }
734 735
735 if (context) { 736 if (context) {
736 std::set<const URLRequest*>* url_requests = context->url_requests(); 737 std::set<const URLRequest*>* url_requests = context->url_requests();
737 CHECK(!ContainsKey(*url_requests, this)); 738 CHECK(!ContainsKey(*url_requests, this));
738 url_requests->insert(this); 739 url_requests->insert(this);
739 } 740 }
740 741
741 scoped_refptr<const URLRequestContext> prev_context = context_; 742 const URLRequestContext* prev_context = context_;
742 743
743 context_ = context; 744 context_ = context;
744 745
745 // If the context this request belongs to has changed, update the tracker. 746 // If the context this request belongs to has changed, update the tracker.
746 if (prev_context != context) { 747 if (prev_context != context) {
747 int net_error = OK; 748 int net_error = OK;
748 // Log error only on failure, not cancellation, as even successful requests 749 // Log error only on failure, not cancellation, as even successful requests
749 // are "cancelled" on destruction. 750 // are "cancelled" on destruction.
750 if (status_.status() == URLRequestStatus::FAILED) 751 if (status_.status() == URLRequestStatus::FAILED)
751 net_error = status_.error(); 752 net_error = status_.error();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 910
910 void URLRequest::SetUnblockedOnDelegate() { 911 void URLRequest::SetUnblockedOnDelegate() {
911 if (!blocked_on_delegate_) 912 if (!blocked_on_delegate_)
912 return; 913 return;
913 blocked_on_delegate_ = false; 914 blocked_on_delegate_ = false;
914 load_state_param_.clear(); 915 load_state_param_.clear();
915 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); 916 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL);
916 } 917 }
917 918
918 } // namespace net 919 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698