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

Unified Diff: chrome/browser/profiles/off_the_record_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/off_the_record_profile_io_data.cc
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 dfc9b81d85c57fe6f5db9353c81e74fba86d8061..07c1d5c352f670bac900a01f056670d0062d9c76 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.cc
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc
@@ -84,10 +84,30 @@ OffTheRecordProfileIOData::Handle::GetMainRequestContextGetter() const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
#endif // defined(OS_CHROMEOS)
LazyInitialize();
- if (!main_request_context_getter_) {
- main_request_context_getter_ =
- ChromeURLRequestContextGetter::CreateOffTheRecord(profile_, io_data_);
- }
+ DCHECK(main_request_context_getter_);
+ return main_request_context_getter_;
+}
+
+scoped_refptr<ChromeURLRequestContextGetter>
+OffTheRecordProfileIOData::Handle::CreateMainRequestContextGetter(
+ 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 {
+ // TODO(oshima): Re-enable when ChromeOS only accesses the profile on the UI
+ // thread.
+#if !defined(OS_CHROMEOS)
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+#endif // defined(OS_CHROMEOS)
+ LazyInitialize();
+ DCHECK(!main_request_context_getter_);
+ main_request_context_getter_ =
+ ChromeURLRequestContextGetter::CreateOffTheRecord(
+ profile_, io_data_, blob_protocol_handler.Pass(),
+ file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass());
return main_request_context_getter_;
}
@@ -115,6 +135,28 @@ OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter(
StoragePartitionDescriptor descriptor(partition_path, in_memory);
ChromeURLRequestContextGetterMap::iterator iter =
app_request_context_getter_map_.find(descriptor);
+ DCHECK(iter != app_request_context_getter_map_.end());
awong 2012/12/12 03:44:37 CHECK or DCHECK? If this happens in production, w
pauljensen 2012/12/12 18:39:37 Changed to CHECK.
+ return iter->second;
+}
+
+scoped_refptr<ChromeURLRequestContextGetter>
+OffTheRecordProfileIOData::Handle::CreateIsolatedAppRequestContextGetter(
+ const FilePath& partition_path,
+ bool in_memory,
+ 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::UI));
+ DCHECK(!partition_path.empty());
+ LazyInitialize();
+
+ // Keep a map of request context getters, one per requested app ID.
+ StoragePartitionDescriptor descriptor(partition_path, in_memory);
+ ChromeURLRequestContextGetterMap::iterator iter =
+ app_request_context_getter_map_.find(descriptor);
if (iter != app_request_context_getter_map_.end())
awong 2012/12/12 03:44:37 If we already have a separate GetXXXContextGetter(
pauljensen 2012/12/12 18:39:37 Changed to DCHECK its not already present.
return iter->second;
@@ -124,8 +166,9 @@ OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter(
CreateURLInterceptor());
ChromeURLRequestContextGetter* context =
ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(
- profile_, io_data_, descriptor,
- protocol_handler_interceptor.Pass());
+ profile_, io_data_, descriptor, protocol_handler_interceptor.Pass(),
+ blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass());
app_request_context_getter_map_[descriptor] = context;
return context;
@@ -154,7 +197,13 @@ OffTheRecordProfileIOData::~OffTheRecordProfileIOData() {
}
void OffTheRecordProfileIOData::LazyInitializeInternal(
- ProfileParams* profile_params) const {
+ ProfileParams* profile_params,
+ 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 {
ChromeURLRequestContext* main_context = main_request_context();
IOThread* const io_thread = profile_params->io_thread;
@@ -217,6 +266,11 @@ void OffTheRecordProfileIOData::LazyInitializeInternal(
scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
new net::URLRequestJobFactoryImpl());
+ main_job_factory->SetProtocolHandler(
+ chrome::kBlobScheme, blob_protocol_handler.release());
+ main_job_factory->SetProtocolHandler(
+ chrome::kFileSystemScheme, file_system_protocol_handler.release());
+ main_job_factory->AddInterceptor(developer_protocol_handler.release());
SetUpJobFactoryDefaults(
main_job_factory.get(),
profile_params->protocol_handler_interceptor.Pass(),
@@ -285,7 +339,13 @@ OffTheRecordProfileIOData::InitializeAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
scoped_ptr<net::URLRequestJobFactory::Interceptor>
- 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::Interceptor>
+ developer_protocol_handler) const {
AppRequestContext* context = new AppRequestContext(load_time_stats());
// Copy most state from the main context.
@@ -308,6 +368,11 @@ OffTheRecordProfileIOData::InitializeAppRequestContext(
scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
new net::URLRequestJobFactoryImpl());
+ job_factory->SetProtocolHandler(chrome::kBlobScheme,
+ blob_protocol_handler.release());
+ job_factory->SetProtocolHandler(chrome::kFileSystemScheme,
+ file_system_protocol_handler.release());
+ job_factory->AddInterceptor(developer_protocol_handler.release());
SetUpJobFactoryDefaults(job_factory.get(),
protocol_handler_interceptor.Pass(),
network_delegate(),
@@ -336,11 +401,20 @@ OffTheRecordProfileIOData::AcquireIsolatedAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
scoped_ptr<net::URLRequestJobFactory::Interceptor>
- 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::Interceptor>
+ developer_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());
DCHECK(app_request_context);
return app_request_context;
}

Powered by Google App Engine
This is Rietveld 408576698