Chromium Code Reviews| Index: chrome/browser/profiles/profile_io_data.cc |
| diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc |
| index 7d6f2a0fa55281ecb459a4eb5ccdba83955ef172..3940b8aedcc12ba3d82ed3aec5e5027786cba2ac 100644 |
| --- a/chrome/browser/profiles/profile_io_data.cc |
| +++ b/chrome/browser/profiles/profile_io_data.cc |
| @@ -365,56 +365,57 @@ content::ResourceContext* ProfileIOData::GetResourceContext() const { |
| ChromeURLDataManagerBackend* |
| ProfileIOData::GetChromeURLDataManagerBackend() const { |
| - LazyInitialize(); |
| + CHECK(initialized_); |
|
awong
2012/12/13 01:06:15
These should all either DCHECK(initialized_) or CH
pauljensen
2012/12/13 17:58:44
Done.
|
| return chrome_url_data_manager_backend_.get(); |
| } |
| -ChromeURLRequestContext* |
| -ProfileIOData::GetMainRequestContext() const { |
| - LazyInitialize(); |
| +ChromeURLRequestContext* ProfileIOData::GetMainRequestContext() const { |
| + CHECK(initialized_); |
| return main_request_context_.get(); |
| } |
| -ChromeURLRequestContext* |
| -ProfileIOData::GetMediaRequestContext() const { |
| - LazyInitialize(); |
| - ChromeURLRequestContext* context = |
| - AcquireMediaRequestContext(); |
| +ChromeURLRequestContext* ProfileIOData::GetMediaRequestContext() const { |
| + DCHECK(initialized_); |
| + ChromeURLRequestContext* context = AcquireMediaRequestContext(); |
| DCHECK(context); |
| return context; |
| } |
| -ChromeURLRequestContext* |
| -ProfileIOData::GetExtensionsRequestContext() const { |
| - LazyInitialize(); |
| +ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { |
| + CHECK(initialized_); |
| return extensions_request_context_.get(); |
| } |
| -ChromeURLRequestContext* |
| -ProfileIOData::GetIsolatedAppRequestContext( |
| +ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( |
| ChromeURLRequestContext* main_context, |
| const StoragePartitionDescriptor& partition_descriptor, |
| scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| - protocol_handler_interceptor) const { |
| - LazyInitialize(); |
| + protocol_handler_interceptor, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + blob_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + file_system_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| + developer_protocol_handler) const { |
| + DCHECK(initialized_); |
| ChromeURLRequestContext* context = NULL; |
| if (ContainsKey(app_request_context_map_, partition_descriptor)) { |
| context = app_request_context_map_[partition_descriptor]; |
| } else { |
| context = AcquireIsolatedAppRequestContext( |
| - main_context, partition_descriptor, |
| - protocol_handler_interceptor.Pass()); |
| + main_context, partition_descriptor, protocol_handler_interceptor.Pass(), |
| + blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(), |
| + developer_protocol_handler.Pass()); |
| app_request_context_map_[partition_descriptor] = context; |
| } |
| DCHECK(context); |
| return context; |
| } |
| -ChromeURLRequestContext* |
| -ProfileIOData::GetIsolatedMediaRequestContext( |
| +ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( |
| ChromeURLRequestContext* app_context, |
| const StoragePartitionDescriptor& partition_descriptor) const { |
| - LazyInitialize(); |
| + DCHECK(initialized_); |
| ChromeURLRequestContext* context = NULL; |
| if (ContainsKey(isolated_media_request_context_map_, partition_descriptor)) { |
| context = isolated_media_request_context_map_[partition_descriptor]; |
| @@ -488,19 +489,15 @@ ProfileIOData::ResourceContext::ResourceContext(ProfileIOData* io_data) |
| ProfileIOData::ResourceContext::~ResourceContext() {} |
| -void ProfileIOData::ResourceContext::EnsureInitialized() { |
| - io_data_->LazyInitialize(); |
| -} |
| - |
| net::HostResolver* ProfileIOData::ResourceContext::GetHostResolver() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - EnsureInitialized(); |
| + CHECK(io_data_->initialized_); |
| return host_resolver_; |
| } |
| net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - EnsureInitialized(); |
| + CHECK(io_data_->initialized_); |
| return request_context_; |
| } |
| @@ -515,10 +512,15 @@ std::string ProfileIOData::GetSSLSessionCacheShard() { |
| return StringPrintf("profile/%u", ssl_session_cache_instance++); |
| } |
| -void ProfileIOData::LazyInitialize() const { |
| +void ProfileIOData::Init( |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + blob_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + file_system_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| + developer_protocol_handler) const { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - if (initialized_) |
| - return; |
| + DCHECK(!initialized_); |
| // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
| CHECK(initialized_on_UI_thread_); |
| @@ -590,7 +592,10 @@ void ProfileIOData::LazyInitialize() const { |
| profile_params_->resource_prefetch_predictor_observer_.release()); |
| } |
| - LazyInitializeInternal(profile_params_.get()); |
| + InitializeInternal(profile_params_.get(), |
| + blob_protocol_handler.Pass(), |
| + file_system_protocol_handler.Pass(), |
| + developer_protocol_handler.Pass()); |
| profile_params_.reset(); |
| initialized_ = true; |