From ef2bf421b04de3134cd7c02aac40a5565ef24dd9 Mon Sep 17 00:00:00 2001 From: "willchan@chromium.org" Date: Fri, 11 May 2012 03:27:09 +0000 Subject: Stop refcounting URLRequestContext. While doing so, fix a few issues with the code like ordering of URLRequestContext to ensure correct destruction order. Also fix const correctness in some places. BUG=58859 TEST=none TBR=willchan Review URL: https://chromiumcodereview.appspot.com/10299002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136497 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/sync/glue/http_bridge.cc | 6 +++--- chrome/browser/sync/glue/http_bridge.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'chrome/browser/sync') diff --git a/chrome/browser/sync/glue/http_bridge.cc b/chrome/browser/sync/glue/http_bridge.cc index dc01ebf..e7a217f 100644 --- a/chrome/browser/sync/glue/http_bridge.cc +++ b/chrome/browser/sync/glue/http_bridge.cc @@ -35,10 +35,10 @@ HttpBridge::RequestContextGetter::~RequestContextGetter() {} net::URLRequestContext* HttpBridge::RequestContextGetter::GetURLRequestContext() { // Lazily create the context. - if (!context_) { + if (!context_.get()) { net::URLRequestContext* baseline_context = baseline_context_getter_->GetURLRequestContext(); - context_ = new RequestContext(baseline_context); + context_.reset(new RequestContext(baseline_context)); baseline_context_getter_ = NULL; } @@ -46,7 +46,7 @@ HttpBridge::RequestContextGetter::GetURLRequestContext() { if (is_user_agent_set()) context_->set_user_agent(user_agent_); - return context_; + return context_.get(); } scoped_refptr diff --git a/chrome/browser/sync/glue/http_bridge.h b/chrome/browser/sync/glue/http_bridge.h index 3e7e98e..a26410d 100644 --- a/chrome/browser/sync/glue/http_bridge.h +++ b/chrome/browser/sync/glue/http_bridge.h @@ -51,6 +51,9 @@ class HttpBridge : public base::RefCountedThreadSafe, // currently active profile. explicit RequestContext(net::URLRequestContext* baseline_context); + // The destructor MUST be called on the IO thread. + virtual ~RequestContext(); + // Set the user agent for requests using this context. The default is // the browser's UA string. void set_user_agent(const std::string& ua) { user_agent_ = ua; } @@ -63,9 +66,6 @@ class HttpBridge : public base::RefCountedThreadSafe, } private: - // The destructor MUST be called on the IO thread. - virtual ~RequestContext(); - std::string user_agent_; net::URLRequestContext* baseline_context_; @@ -96,7 +96,7 @@ class HttpBridge : public base::RefCountedThreadSafe, scoped_refptr baseline_context_getter_; // Lazily initialized by GetURLRequestContext(). - scoped_refptr context_; + scoped_ptr context_; DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); }; -- cgit v1.1