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

Unified Diff: chrome/browser/profiles/profile_impl_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: sync (r179907) Created 7 years, 11 months 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_impl_io_data.cc
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index 8b24c9e570078904328897395456fe51efa5c633..50172b0ac7002e4b733f1b4ff1b0a3889e6fe21e 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -37,6 +37,7 @@
#include "net/base/server_bound_cert_service.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_cache.h"
+#include "net/url_request/protocol_intercept_job_factory.h"
#include "net/url_request/url_request_job_factory_impl.h"
#include "webkit/quota/special_storage_policy.h"
@@ -75,8 +76,6 @@ void ProfileImplIOData::Handle::Init(
const FilePath& profile_path,
const FilePath& infinite_cache_path,
chrome_browser_net::Predictor* predictor,
- PrefService* local_state,
- IOThread* io_thread,
bool restore_old_session_cookies,
quota::SpecialStoragePolicy* special_storage_policy) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -106,16 +105,6 @@ void ProfileImplIOData::Handle::Init(
io_data_->predictor_.reset(predictor);
- if (!main_request_context_getter_) {
- main_request_context_getter_ =
- ChromeURLRequestContextGetter::CreateOriginal(
- profile_, io_data_);
- }
- io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(),
- local_state,
- io_thread,
- main_request_context_getter_);
-
io_data_->InitializeMetricsEnabledStateOnUIThread();
}
@@ -136,19 +125,36 @@ ProfileImplIOData::Handle::GetResourceContextNoInit() const {
}
scoped_refptr<ChromeURLRequestContextGetter>
-ProfileImplIOData::Handle::GetMainRequestContextGetter() const {
+ProfileImplIOData::Handle::CreateMainRequestContextGetter(
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler,
+ PrefService* local_state,
+ IOThread* io_thread) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
LazyInitialize();
- if (!main_request_context_getter_) {
- main_request_context_getter_ =
- ChromeURLRequestContextGetter::CreateOriginal(
- profile_, io_data_);
+ DCHECK(!main_request_context_getter_);
+ main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal(
+ profile_, io_data_, blob_protocol_handler.Pass(),
+ file_system_protocol_handler.Pass(), developer_protocol_handler.Pass(),
+ chrome_protocol_handler.Pass(), chrome_devtools_protocol_handler.Pass());
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
- content::Source<Profile>(profile_),
- content::NotificationService::NoDetails());
- }
+ io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(),
+ local_state,
+ io_thread,
+ main_request_context_getter_);
+
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
+ content::Source<Profile>(profile_),
+ content::NotificationService::NoDetails());
return main_request_context_getter_;
}
@@ -177,9 +183,19 @@ ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const {
}
scoped_refptr<ChromeURLRequestContextGetter>
-ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter(
+ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter(
const FilePath& partition_path,
- bool in_memory) const {
+ bool in_memory,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Check that the partition_path is not the same as the base profile path. We
// expect isolated partition, which will never go to the default profile path.
@@ -200,7 +216,10 @@ ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter(
ChromeURLRequestContextGetter* context =
ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(
profile_, io_data_, descriptor,
- protocol_handler_interceptor.Pass());
+ protocol_handler_interceptor.Pass(), blob_protocol_handler.Pass(),
+ file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
+ chrome_devtools_protocol_handler.Pass());
app_request_context_getter_map_[descriptor] = context;
return context;
@@ -225,8 +244,10 @@ ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter(
// Get the app context as the starting point for the media context, so that
// it uses the app's cookie store.
- ChromeURLRequestContextGetter* app_context =
- GetIsolatedAppRequestContextGetter(partition_path, in_memory);
+ ChromeURLRequestContextGetterMap::const_iterator app_iter =
+ app_request_context_getter_map_.find(descriptor);
+ DCHECK(app_iter != app_request_context_getter_map_.end());
+ ChromeURLRequestContextGetter* app_context = app_iter->second;
ChromeURLRequestContextGetter* context =
ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia(
profile_, app_context, io_data_, descriptor);
@@ -292,8 +313,18 @@ ProfileImplIOData::~ProfileImplIOData() {
media_request_context_->AssertNoURLRequests();
}
-void ProfileImplIOData::LazyInitializeInternal(
- ProfileParams* profile_params) const {
+void ProfileImplIOData::InitializeInternal(
+ ProfileParams* profile_params,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) const {
ChromeURLRequestContext* main_context = main_request_context();
IOThread* const io_thread = profile_params->io_thread;
@@ -411,12 +442,27 @@ void ProfileImplIOData::LazyInitializeInternal(
scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
new net::URLRequestJobFactoryImpl());
+ bool set_protocol = main_job_factory->SetProtocolHandler(
+ chrome::kBlobScheme, blob_protocol_handler.release());
+ DCHECK(set_protocol);
+ set_protocol = main_job_factory->SetProtocolHandler(
+ chrome::kFileSystemScheme, file_system_protocol_handler.release());
+ DCHECK(set_protocol);
+ set_protocol = main_job_factory->SetProtocolHandler(
+ chrome::kChromeUIScheme, chrome_protocol_handler.release());
+ DCHECK(set_protocol);
+ set_protocol = main_job_factory->SetProtocolHandler(
+ chrome::kChromeDevToolsScheme,
+ chrome_devtools_protocol_handler.release());
+ DCHECK(set_protocol);
main_job_factory_ = SetUpJobFactoryDefaults(
main_job_factory.Pass(),
profile_params->protocol_handler_interceptor.Pass(),
network_delegate(),
main_context->ftp_transaction_factory(),
main_context->ftp_auth_cache());
+ main_job_factory_.reset(new net::ProtocolInterceptJobFactory(
+ main_job_factory_.Pass(), developer_protocol_handler.Pass()));
main_context->set_job_factory(main_job_factory_.get());
#if defined(ENABLE_EXTENSIONS)
@@ -484,7 +530,17 @@ ProfileImplIOData::InitializeAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor) const {
+ protocol_handler_interceptor,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) const {
// Copy most state from the main context.
AppRequestContext* context = new AppRequestContext(load_time_stats());
context->CopyFrom(main_context);
@@ -549,6 +605,19 @@ ProfileImplIOData::InitializeAppRequestContext(
scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
new net::URLRequestJobFactoryImpl());
+ bool set_protocol = job_factory->SetProtocolHandler(
+ chrome::kBlobScheme, blob_protocol_handler.release());
+ DCHECK(set_protocol);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kFileSystemScheme, file_system_protocol_handler.release());
+ DCHECK(set_protocol);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kChromeUIScheme, chrome_protocol_handler.release());
+ DCHECK(set_protocol);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kChromeDevToolsScheme,
+ chrome_devtools_protocol_handler.release());
+ DCHECK(set_protocol);
scoped_ptr<net::URLRequestJobFactory> top_job_factory;
// Overwrite the job factory that we inherit from the main context so
// that we can later provide our own handlers for storage related protocols.
@@ -563,6 +632,8 @@ ProfileImplIOData::InitializeAppRequestContext(
} else {
top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>();
}
+ top_job_factory.reset(new net::ProtocolInterceptJobFactory(
+ top_job_factory.Pass(), developer_protocol_handler.Pass()));
context->SetJobFactory(top_job_factory.Pass());
return context;
@@ -627,11 +698,26 @@ ProfileImplIOData::AcquireIsolatedAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor) const {
+ protocol_handler_interceptor,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) const {
// We create per-app contexts on demand, unlike the others above.
ChromeURLRequestContext* app_request_context =
InitializeAppRequestContext(main_context, partition_descriptor,
- protocol_handler_interceptor.Pass());
+ protocol_handler_interceptor.Pass(),
+ blob_protocol_handler.Pass(),
+ file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass(),
+ chrome_protocol_handler.Pass(),
+ chrome_devtools_protocol_handler.Pass());
DCHECK(app_request_context);
return app_request_context;
}
@@ -656,7 +742,7 @@ void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread(
base::Time time,
const base::Closure& completion) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- LazyInitialize();
+ DCHECK(initialized());
DCHECK(transport_security_state());
transport_security_state()->DeleteSince(time); // Completes synchronously.

Powered by Google App Engine
This is Rietveld 408576698