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..02cfd6a68c15f0398c197e74bf9887fff213d3ae 100644 |
--- a/chrome/browser/profiles/profile_io_data.cc |
+++ b/chrome/browser/profiles/profile_io_data.cc |
@@ -173,7 +173,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
// The profile instance is only available here in the InitializeOnUIThread |
// method, so we create the url interceptor here, then save it for |
- // later delivery to the job factory in LazyInitialize. |
+ // later delivery to the job factory in Init(). |
params->protocol_handler_interceptor.reset( |
protocol_handler_registry->CreateURLInterceptor()); |
@@ -365,56 +365,57 @@ content::ResourceContext* ProfileIOData::GetResourceContext() const { |
ChromeURLDataManagerBackend* |
ProfileIOData::GetChromeURLDataManagerBackend() const { |
- LazyInitialize(); |
+ DCHECK(initialized_); |
return chrome_url_data_manager_backend_.get(); |
} |
-ChromeURLRequestContext* |
-ProfileIOData::GetMainRequestContext() const { |
- LazyInitialize(); |
+ChromeURLRequestContext* ProfileIOData::GetMainRequestContext() const { |
+ DCHECK(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 { |
+ DCHECK(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(); |
+ DCHECK(io_data_->initialized_); |
return host_resolver_; |
} |
net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- EnsureInitialized(); |
+ DCHECK(io_data_->initialized_); |
return request_context_; |
} |
@@ -515,10 +512,18 @@ 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 { |
+ // The basic logic is implemented here. The specific initialization |
+ // is done in InitializeInternal(), implemented by subtypes. Static helper |
+ // functions have been provided to assist in common operations. |
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 +595,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; |