Chromium Code Reviews| 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 edda406897814845268211ef4166300ccb0f91a4..f6c083aad4cff6233385f3e958aed38580ebc7f6 100644 |
| --- a/chrome/browser/profiles/profile_impl_io_data.cc |
| +++ b/chrome/browser/profiles/profile_impl_io_data.cc |
| @@ -76,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)); |
| @@ -107,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(); |
| } |
| @@ -148,16 +136,36 @@ scoped_refptr<ChromeURLRequestContextGetter> |
| ProfileImplIOData::Handle::GetMainRequestContextGetter() 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_); |
| + return main_request_context_getter_; |
| +} |
| - content::NotificationService::current()->Notify( |
| - chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
| - content::Source<Profile>(profile_), |
| - content::NotificationService::NoDetails()); |
| - } |
| +scoped_refptr<ChromeURLRequestContextGetter> |
| +ProfileImplIOData::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, |
| + PrefService* local_state, |
| + IOThread* io_thread) const { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + LazyInitialize(); |
| + 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()); |
| + |
| + 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_; |
| } |
| @@ -186,9 +194,15 @@ 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::Interceptor> |
| + developer_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. |
| @@ -209,7 +223,9 @@ 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()); |
| app_request_context_getter_map_[descriptor] = context; |
| return context; |
| @@ -234,8 +250,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::iterator app_iter = |
|
awong
2012/12/13 01:06:15
const_iterator
pauljensen
2012/12/13 17:58:44
Done.
|
| + 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); |
| @@ -300,8 +318,14 @@ 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::Interceptor> |
| + developer_protocol_handler) const { |
| ChromeURLRequestContext* main_context = main_request_context(); |
| IOThread* const io_thread = profile_params->io_thread; |
| @@ -420,6 +444,11 @@ void ProfileImplIOData::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()); |
| SetUpJobFactory(main_job_factory.get(), |
| profile_params->protocol_handler_interceptor.Pass(), |
| network_delegate(), |
| @@ -493,7 +522,13 @@ ProfileImplIOData::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 { |
| // Copy most state from the main context. |
| AppRequestContext* context = new AppRequestContext(load_time_stats()); |
| context->CopyFrom(main_context); |
| @@ -562,6 +597,11 @@ ProfileImplIOData::InitializeAppRequestContext( |
| // guest process, in which case only web-safe schemes are allowed. |
| 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()); |
| if (!partition_descriptor.in_memory) { |
| SetUpJobFactory(job_factory.get(), protocol_handler_interceptor.Pass(), |
| network_delegate(), |
| @@ -632,11 +672,20 @@ ProfileImplIOData::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; |
| } |
| @@ -678,7 +727,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. |