diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 03:27:09 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 03:27:09 +0000 |
commit | ef2bf421b04de3134cd7c02aac40a5565ef24dd9 (patch) | |
tree | 5bf90cca0bd015c23e843614ebf2e9f99cb8cd99 /chrome/browser/profiles | |
parent | 280e9b5d4b2fb0fe14824e526521710a658bce56 (diff) | |
download | chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.zip chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.tar.gz chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.tar.bz2 |
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
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.cc | 12 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.h | 10 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl_io_data.cc | 22 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl_io_data.h | 12 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.cc | 31 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.h | 28 |
6 files changed, 58 insertions, 57 deletions
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index e90b5ac..c33f78c 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -250,9 +250,9 @@ void OffTheRecordProfileIOData::LazyInitializeInternal( extensions_context->set_job_factory(job_factory()); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* OffTheRecordProfileIOData::InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { AppRequestContext* context = new AppRequestContext; @@ -276,18 +276,18 @@ OffTheRecordProfileIOData::InitializeAppRequestContext( return context; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* OffTheRecordProfileIOData::AcquireMediaRequestContext() const { NOTREACHED(); return NULL; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* OffTheRecordProfileIOData::AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { // We create per-app contexts on demand, unlike the others above. - scoped_refptr<ChromeURLRequestContext> app_request_context = + ChromeURLRequestContext* app_request_context = InitializeAppRequestContext(main_context, app_id); DCHECK(app_request_context); return app_request_context; diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h index a23b8fb..2e119a0 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.h +++ b/chrome/browser/profiles/off_the_record_profile_io_data.h @@ -98,14 +98,14 @@ class OffTheRecordProfileIOData : public ProfileIOData { virtual void LazyInitializeInternal( ProfileParams* profile_params) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + virtual ChromeURLRequestContext* InitializeAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireMediaRequestContext() const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; mutable scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_; diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index 12355f7..0f4c473 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -252,7 +252,7 @@ ProfileImplIOData::ProfileImplIOData() ProfileImplIOData::~ProfileImplIOData() { DestroyResourceContext(); - if (media_request_context_) + if (media_request_context_.get()) media_request_context_->AssertNoURLRequests(); } @@ -263,7 +263,7 @@ void ProfileImplIOData::LazyInitializeInternal( ChromeURLRequestContext* main_context = main_request_context(); ChromeURLRequestContext* extensions_context = extensions_request_context(); - media_request_context_ = new ChromeURLRequestContext; + media_request_context_.reset(new ChromeURLRequestContext); IOThread* const io_thread = profile_params->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); @@ -275,7 +275,7 @@ void ProfileImplIOData::LazyInitializeInternal( // Initialize context members. ApplyProfileParamsToContext(main_context); - ApplyProfileParamsToContext(media_request_context_); + ApplyProfileParamsToContext(media_request_context_.get()); ApplyProfileParamsToContext(extensions_context); if (http_server_properties_manager()) @@ -449,9 +449,9 @@ void ProfileImplIOData::LazyInitializeInternal( lazy_params_.reset(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileImplIOData::InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { AppRequestContext* context = new AppRequestContext; @@ -511,18 +511,18 @@ ProfileImplIOData::InitializeAppRequestContext( return context; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileImplIOData::AcquireMediaRequestContext() const { - DCHECK(media_request_context_); - return media_request_context_; + DCHECK(media_request_context_.get()); + return media_request_context_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileImplIOData::AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { // We create per-app contexts on demand, unlike the others above. - scoped_refptr<ChromeURLRequestContext> app_request_context = + ChromeURLRequestContext* app_request_context = InitializeAppRequestContext(main_context, app_id); DCHECK(app_request_context); return app_request_context; diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h index 4bda4a6..153e278 100644 --- a/chrome/browser/profiles/profile_impl_io_data.h +++ b/chrome/browser/profiles/profile_impl_io_data.h @@ -125,14 +125,14 @@ class ProfileImplIOData : public ProfileIOData { virtual void LazyInitializeInternal( ProfileParams* profile_params) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + virtual ChromeURLRequestContext* InitializeAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireMediaRequestContext() const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; // Clears the networking history since |time|. @@ -147,7 +147,7 @@ class ProfileImplIOData : public ProfileIOData { mutable scoped_ptr<chrome_browser_net::Predictor> predictor_; - mutable scoped_refptr<ChromeURLRequestContext> media_request_context_; + mutable scoped_ptr<ChromeURLRequestContext> media_request_context_; // Parameters needed for isolated apps. FilePath app_path_; diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index a9ca5bb..6ea6e86 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -272,13 +272,14 @@ ProfileIOData::~ProfileIOData() { if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (main_request_context_) + if (main_request_context_.get()) main_request_context_->AssertNoURLRequests(); - if (extensions_request_context_) + if (extensions_request_context_.get()) extensions_request_context_->AssertNoURLRequests(); for (AppRequestContextMap::iterator it = app_request_context_map_.begin(); it != app_request_context_map_.end(); ++it) { it->second->AssertNoURLRequests(); + delete it->second; } } @@ -328,33 +329,33 @@ ProfileIOData::GetChromeURLDataManagerBackend() const { return chrome_url_data_manager_backend_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetMainRequestContext() const { LazyInitialize(); - return main_request_context_; + return main_request_context_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetMediaRequestContext() const { LazyInitialize(); - scoped_refptr<ChromeURLRequestContext> context = + ChromeURLRequestContext* context = AcquireMediaRequestContext(); DCHECK(context); return context; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { LazyInitialize(); - return extensions_request_context_; + return extensions_request_context_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { LazyInitialize(); - scoped_refptr<ChromeURLRequestContext> context; + ChromeURLRequestContext* context; if (ContainsKey(app_request_context_map_, app_id)) { context = app_request_context_map_[app_id]; } else { @@ -467,8 +468,8 @@ void ProfileIOData::LazyInitialize() const { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); // Create the common request contexts. - main_request_context_ = new ChromeURLRequestContext; - extensions_request_context_ = new ChromeURLRequestContext; + main_request_context_.reset(new ChromeURLRequestContext); + extensions_request_context_.reset(new ChromeURLRequestContext); chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend); @@ -482,7 +483,7 @@ void ProfileIOData::LazyInitialize() const { fraudulent_certificate_reporter_.reset( new chrome_browser_net::ChromeFraudulentCertificateReporter( - main_request_context_)); + main_request_context_.get())); proxy_service_.reset( ProxyServiceFactory::CreateProxyService( @@ -545,7 +546,7 @@ void ProfileIOData::LazyInitialize() const { extension_info_map_ = profile_params_->extension_info_map; resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); - resource_context_->request_context_ = main_request_context_; + resource_context_->request_context_ = main_request_context_.get(); LazyInitializeInternal(profile_params_.get()); diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index bc10f01..f4702bb 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -74,11 +74,11 @@ class ProfileIOData { // These should only be called at most once each. Ownership is reversed when // they get called, from ProfileIOData owning ChromeURLRequestContext to vice // versa. - scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; - scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; - scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; - scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* GetMainRequestContext() const; + ChromeURLRequestContext* GetMediaRequestContext() const; + ChromeURLRequestContext* GetExtensionsRequestContext() const; + ChromeURLRequestContext* GetIsolatedAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const; // These are useful when the Chrome layer is called from the content layer @@ -225,7 +225,7 @@ class ProfileIOData { chrome_browser_net::HttpServerPropertiesManager* manager) const; ChromeURLRequestContext* main_request_context() const { - return main_request_context_; + return main_request_context_.get(); } // Destroys the ResourceContext first, to cancel any URLRequests that are @@ -254,7 +254,7 @@ class ProfileIOData { net::URLRequestContext* request_context_; }; - typedef base::hash_map<std::string, scoped_refptr<ChromeURLRequestContext> > + typedef base::hash_map<std::string, ChromeURLRequestContext*> AppRequestContextMap; // -------------------------------------------- @@ -267,17 +267,17 @@ class ProfileIOData { // Does an on-demand initialization of a RequestContext for the given // isolated app. - virtual scoped_refptr<ChromeURLRequestContext> InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + virtual ChromeURLRequestContext* InitializeAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const = 0; // These functions are used to transfer ownership of the lazily initialized // context from ProfileIOData to the URLRequestContextGetter. - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireMediaRequestContext() const = 0; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const = 0; // The order *DOES* matter for the majority of these member variables, so @@ -341,8 +341,8 @@ class ProfileIOData { // These are only valid in between LazyInitialize() and their accessor being // called. - mutable scoped_refptr<ChromeURLRequestContext> main_request_context_; - mutable scoped_refptr<ChromeURLRequestContext> extensions_request_context_; + mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; + mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; // One AppRequestContext per isolated app. mutable AppRequestContextMap app_request_context_map_; |