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 057c10a134cb553ee160a87a73ac5bd10583580b..8c65ff33190eadf158578653b2a8d95c4178fdb3 100644 |
--- a/chrome/browser/profiles/off_the_record_profile_io_data.cc |
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc |
@@ -78,17 +78,25 @@ OffTheRecordProfileIOData::Handle::GetResourceContextNoInit() const { |
} |
scoped_refptr<ChromeURLRequestContextGetter> |
-OffTheRecordProfileIOData::Handle::GetMainRequestContextGetter() const { |
+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 { |
mmenke
2013/01/25 18:38:58
nit: Fix indent.
|
// 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(); |
- if (!main_request_context_getter_) { |
- main_request_context_getter_ = |
- ChromeURLRequestContextGetter::CreateOffTheRecord(profile_, io_data_); |
- } |
+ 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_; |
} |
@@ -116,8 +124,27 @@ OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter( |
StoragePartitionDescriptor descriptor(partition_path, in_memory); |
ChromeURLRequestContextGetterMap::iterator iter = |
app_request_context_getter_map_.find(descriptor); |
- if (iter != app_request_context_getter_map_.end()) |
- return iter->second; |
+ CHECK(iter != app_request_context_getter_map_.end()); |
+ 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); |
+ DCHECK_EQ(app_request_context_getter_map_.count(descriptor), 0u); |
scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
protocol_handler_interceptor( |
@@ -125,8 +152,9 @@ OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter( |
CreateJobInterceptorFactory()); |
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,8 +182,14 @@ OffTheRecordProfileIOData::~OffTheRecordProfileIOData() { |
DestroyResourceContext(); |
} |
-void OffTheRecordProfileIOData::LazyInitializeInternal( |
- ProfileParams* profile_params) const { |
+void OffTheRecordProfileIOData::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::Interceptor> |
+ developer_protocol_handler) const { |
ChromeURLRequestContext* main_context = main_request_context(); |
IOThread* const io_thread = profile_params->io_thread; |
@@ -215,6 +249,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()); |
main_job_factory_ = SetUpJobFactoryDefaults( |
main_job_factory.Pass(), |
profile_params->protocol_handler_interceptor.Pass(), |
@@ -281,7 +320,13 @@ OffTheRecordProfileIOData::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::Interceptor> |
+ developer_protocol_handler) const { |
AppRequestContext* context = new AppRequestContext(load_time_stats()); |
// Copy most state from the main context. |
@@ -304,6 +349,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()); |
scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
top_job_factory = SetUpJobFactoryDefaults(job_factory.Pass(), |
protocol_handler_interceptor.Pass(), |
@@ -333,11 +383,20 @@ OffTheRecordProfileIOData::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::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; |
} |