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

Unified Diff: chrome/browser/profiles/profile_io_data.cc

Issue 11308362: Add StoragePartition's ProtocolHandlers at URLRequestContext construction time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move ShellResourceContext into .cc file Created 8 years 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 side-by-side diff with in-line comments
Download patch
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..73e09f8557c09f1cfc3aa3d9ed3e194ef01025af 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -365,19 +365,13 @@ content::ResourceContext* ProfileIOData::GetResourceContext() const {
ChromeURLDataManagerBackend*
ProfileIOData::GetChromeURLDataManagerBackend() const {
- LazyInitialize();
+ DCHECK(initialized_);
return chrome_url_data_manager_backend_.get();
}
ChromeURLRequestContext*
-ProfileIOData::GetMainRequestContext() const {
- LazyInitialize();
- return main_request_context_.get();
-}
-
-ChromeURLRequestContext*
ProfileIOData::GetMediaRequestContext() const {
- LazyInitialize();
+ DCHECK(initialized_);
ChromeURLRequestContext* context =
AcquireMediaRequestContext();
DCHECK(context);
@@ -386,7 +380,7 @@ ProfileIOData::GetMediaRequestContext() const {
ChromeURLRequestContext*
ProfileIOData::GetExtensionsRequestContext() const {
- LazyInitialize();
+ DCHECK(initialized_);
return extensions_request_context_.get();
}
@@ -395,15 +389,22 @@ 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);
@@ -414,7 +415,7 @@ 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,15 @@ std::string ProfileIOData::GetSSLSessionCacheShard() {
return StringPrintf("profile/%u", ssl_session_cache_instance++);
}
-void ProfileIOData::LazyInitialize() const {
+ChromeURLRequestContext* ProfileIOData::GetMainRequestContext(
+ 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,10 +592,15 @@ void ProfileIOData::LazyInitialize() const {
profile_params_->resource_prefetch_predictor_observer_.release());
}
- LazyInitializeInternal(profile_params_.get());
+ LazyInitializeInternal(profile_params_.get(),
+ blob_protocol_handler.Pass(),
+ file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass());
profile_params_.reset();
initialized_ = true;
+
+ return main_request_context_.get();
}
void ProfileIOData::ApplyProfileParamsToContext(

Powered by Google App Engine
This is Rietveld 408576698