| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profiles/profile_impl_io_data.h" | 5 #include "chrome/browser/profiles/profile_impl_io_data.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 const FilePath& cookie_path, | 69 const FilePath& cookie_path, |
| 70 const FilePath& server_bound_cert_path, | 70 const FilePath& server_bound_cert_path, |
| 71 const FilePath& cache_path, | 71 const FilePath& cache_path, |
| 72 int cache_max_size, | 72 int cache_max_size, |
| 73 const FilePath& media_cache_path, | 73 const FilePath& media_cache_path, |
| 74 int media_cache_max_size, | 74 int media_cache_max_size, |
| 75 const FilePath& extensions_cookie_path, | 75 const FilePath& extensions_cookie_path, |
| 76 const FilePath& profile_path, | 76 const FilePath& profile_path, |
| 77 const FilePath& infinite_cache_path, | 77 const FilePath& infinite_cache_path, |
| 78 chrome_browser_net::Predictor* predictor, | 78 chrome_browser_net::Predictor* predictor, |
| 79 PrefService* local_state, | |
| 80 IOThread* io_thread, | |
| 81 bool restore_old_session_cookies, | 79 bool restore_old_session_cookies, |
| 82 quota::SpecialStoragePolicy* special_storage_policy) { | 80 quota::SpecialStoragePolicy* special_storage_policy) { |
| 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 84 DCHECK(!io_data_->lazy_params_.get()); | 82 DCHECK(!io_data_->lazy_params_.get()); |
| 85 DCHECK(predictor); | 83 DCHECK(predictor); |
| 86 | 84 |
| 87 LazyParams* lazy_params = new LazyParams; | 85 LazyParams* lazy_params = new LazyParams; |
| 88 | 86 |
| 89 lazy_params->cookie_path = cookie_path; | 87 lazy_params->cookie_path = cookie_path; |
| 90 lazy_params->server_bound_cert_path = server_bound_cert_path; | 88 lazy_params->server_bound_cert_path = server_bound_cert_path; |
| 91 lazy_params->cache_path = cache_path; | 89 lazy_params->cache_path = cache_path; |
| 92 lazy_params->cache_max_size = cache_max_size; | 90 lazy_params->cache_max_size = cache_max_size; |
| 93 lazy_params->media_cache_path = media_cache_path; | 91 lazy_params->media_cache_path = media_cache_path; |
| 94 lazy_params->media_cache_max_size = media_cache_max_size; | 92 lazy_params->media_cache_max_size = media_cache_max_size; |
| 95 lazy_params->extensions_cookie_path = extensions_cookie_path; | 93 lazy_params->extensions_cookie_path = extensions_cookie_path; |
| 96 lazy_params->infinite_cache_path = infinite_cache_path; | 94 lazy_params->infinite_cache_path = infinite_cache_path; |
| 97 lazy_params->restore_old_session_cookies = restore_old_session_cookies; | 95 lazy_params->restore_old_session_cookies = restore_old_session_cookies; |
| 98 lazy_params->special_storage_policy = special_storage_policy; | 96 lazy_params->special_storage_policy = special_storage_policy; |
| 99 | 97 |
| 100 io_data_->lazy_params_.reset(lazy_params); | 98 io_data_->lazy_params_.reset(lazy_params); |
| 101 | 99 |
| 102 // Keep track of profile path and cache sizes separately so we can use them | 100 // Keep track of profile path and cache sizes separately so we can use them |
| 103 // on demand when creating storage isolated URLRequestContextGetters. | 101 // on demand when creating storage isolated URLRequestContextGetters. |
| 104 io_data_->profile_path_ = profile_path; | 102 io_data_->profile_path_ = profile_path; |
| 105 io_data_->app_cache_max_size_ = cache_max_size; | 103 io_data_->app_cache_max_size_ = cache_max_size; |
| 106 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 104 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
| 107 | 105 |
| 108 io_data_->predictor_.reset(predictor); | 106 io_data_->predictor_.reset(predictor); |
| 109 | 107 |
| 110 if (!main_request_context_getter_) { | |
| 111 main_request_context_getter_ = | |
| 112 ChromeURLRequestContextGetter::CreateOriginal( | |
| 113 profile_, io_data_); | |
| 114 } | |
| 115 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), | |
| 116 local_state, | |
| 117 io_thread, | |
| 118 main_request_context_getter_); | |
| 119 | |
| 120 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 108 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
| 121 } | 109 } |
| 122 | 110 |
| 123 base::Callback<ChromeURLDataManagerBackend*(void)> | 111 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 124 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { | 112 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { |
| 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 126 LazyInitialize(); | 114 LazyInitialize(); |
| 127 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, | 115 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, |
| 128 base::Unretained(io_data_)); | 116 base::Unretained(io_data_)); |
| 129 } | 117 } |
| 130 | 118 |
| 131 content::ResourceContext* | 119 content::ResourceContext* |
| 132 ProfileImplIOData::Handle::GetResourceContext() const { | 120 ProfileImplIOData::Handle::GetResourceContext() const { |
| 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 134 LazyInitialize(); | 122 LazyInitialize(); |
| 135 return GetResourceContextNoInit(); | 123 return GetResourceContextNoInit(); |
| 136 } | 124 } |
| 137 | 125 |
| 138 content::ResourceContext* | 126 content::ResourceContext* |
| 139 ProfileImplIOData::Handle::GetResourceContextNoInit() const { | 127 ProfileImplIOData::Handle::GetResourceContextNoInit() const { |
| 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 141 // Don't call LazyInitialize here, since the resource context is created at | 129 // Don't call LazyInitialize here, since the resource context is created at |
| 142 // the beginning of initalization and is used by some members while they're | 130 // the beginning of initalization and is used by some members while they're |
| 143 // being initialized (i.e. AppCacheService). | 131 // being initialized (i.e. AppCacheService). |
| 144 return io_data_->GetResourceContext(); | 132 return io_data_->GetResourceContext(); |
| 145 } | 133 } |
| 146 | 134 |
| 147 scoped_refptr<ChromeURLRequestContextGetter> | 135 scoped_refptr<ChromeURLRequestContextGetter> |
| 148 ProfileImplIOData::Handle::GetMainRequestContextGetter() const { | 136 ProfileImplIOData::Handle::CreateMainRequestContextGetter( |
| 137 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 138 blob_protocol_handler, |
| 139 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 140 file_system_protocol_handler, |
| 141 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 142 developer_protocol_handler, |
| 143 PrefService* local_state, |
| 144 IOThread* io_thread) const { |
| 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 150 LazyInitialize(); | 146 LazyInitialize(); |
| 151 if (!main_request_context_getter_) { | 147 DCHECK(!main_request_context_getter_); |
| 152 main_request_context_getter_ = | 148 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( |
| 153 ChromeURLRequestContextGetter::CreateOriginal( | 149 profile_, io_data_, blob_protocol_handler.Pass(), |
| 154 profile_, io_data_); | 150 file_system_protocol_handler.Pass(), developer_protocol_handler.Pass()); |
| 155 | 151 |
| 156 content::NotificationService::current()->Notify( | 152 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), |
| 157 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 153 local_state, |
| 158 content::Source<Profile>(profile_), | 154 io_thread, |
| 159 content::NotificationService::NoDetails()); | 155 main_request_context_getter_); |
| 160 } | 156 |
| 157 content::NotificationService::current()->Notify( |
| 158 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
| 159 content::Source<Profile>(profile_), |
| 160 content::NotificationService::NoDetails()); |
| 161 return main_request_context_getter_; | 161 return main_request_context_getter_; |
| 162 } | 162 } |
| 163 | 163 |
| 164 scoped_refptr<ChromeURLRequestContextGetter> | 164 scoped_refptr<ChromeURLRequestContextGetter> |
| 165 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { | 165 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { |
| 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 167 LazyInitialize(); | 167 LazyInitialize(); |
| 168 if (!media_request_context_getter_) { | 168 if (!media_request_context_getter_) { |
| 169 media_request_context_getter_ = | 169 media_request_context_getter_ = |
| 170 ChromeURLRequestContextGetter::CreateOriginalForMedia( | 170 ChromeURLRequestContextGetter::CreateOriginalForMedia( |
| 171 profile_, io_data_); | 171 profile_, io_data_); |
| 172 } | 172 } |
| 173 return media_request_context_getter_; | 173 return media_request_context_getter_; |
| 174 } | 174 } |
| 175 | 175 |
| 176 scoped_refptr<ChromeURLRequestContextGetter> | 176 scoped_refptr<ChromeURLRequestContextGetter> |
| 177 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { | 177 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 179 LazyInitialize(); | 179 LazyInitialize(); |
| 180 if (!extensions_request_context_getter_) { | 180 if (!extensions_request_context_getter_) { |
| 181 extensions_request_context_getter_ = | 181 extensions_request_context_getter_ = |
| 182 ChromeURLRequestContextGetter::CreateOriginalForExtensions( | 182 ChromeURLRequestContextGetter::CreateOriginalForExtensions( |
| 183 profile_, io_data_); | 183 profile_, io_data_); |
| 184 } | 184 } |
| 185 return extensions_request_context_getter_; | 185 return extensions_request_context_getter_; |
| 186 } | 186 } |
| 187 | 187 |
| 188 scoped_refptr<ChromeURLRequestContextGetter> | 188 scoped_refptr<ChromeURLRequestContextGetter> |
| 189 ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter( | 189 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( |
| 190 const FilePath& partition_path, | 190 const FilePath& partition_path, |
| 191 bool in_memory) const { | 191 bool in_memory, |
| 192 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 193 blob_protocol_handler, |
| 194 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 195 file_system_protocol_handler, |
| 196 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 197 developer_protocol_handler) const { |
| 192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 193 // Check that the partition_path is not the same as the base profile path. We | 199 // Check that the partition_path is not the same as the base profile path. We |
| 194 // expect isolated partition, which will never go to the default profile path. | 200 // expect isolated partition, which will never go to the default profile path. |
| 195 CHECK(partition_path != profile_->GetPath()); | 201 CHECK(partition_path != profile_->GetPath()); |
| 196 LazyInitialize(); | 202 LazyInitialize(); |
| 197 | 203 |
| 198 // Keep a map of request context getters, one per requested storage partition. | 204 // Keep a map of request context getters, one per requested storage partition. |
| 199 StoragePartitionDescriptor descriptor(partition_path, in_memory); | 205 StoragePartitionDescriptor descriptor(partition_path, in_memory); |
| 200 ChromeURLRequestContextGetterMap::iterator iter = | 206 ChromeURLRequestContextGetterMap::iterator iter = |
| 201 app_request_context_getter_map_.find(descriptor); | 207 app_request_context_getter_map_.find(descriptor); |
| 202 if (iter != app_request_context_getter_map_.end()) | 208 if (iter != app_request_context_getter_map_.end()) |
| 203 return iter->second; | 209 return iter->second; |
| 204 | 210 |
| 205 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 211 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 206 protocol_handler_interceptor( | 212 protocol_handler_interceptor( |
| 207 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> | 213 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> |
| 208 CreateJobInterceptorFactory()); | 214 CreateJobInterceptorFactory()); |
| 209 ChromeURLRequestContextGetter* context = | 215 ChromeURLRequestContextGetter* context = |
| 210 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 216 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| 211 profile_, io_data_, descriptor, | 217 profile_, io_data_, descriptor, |
| 212 protocol_handler_interceptor.Pass()); | 218 protocol_handler_interceptor.Pass(), blob_protocol_handler.Pass(), |
| 219 file_system_protocol_handler.Pass(), |
| 220 developer_protocol_handler.Pass()); |
| 213 app_request_context_getter_map_[descriptor] = context; | 221 app_request_context_getter_map_[descriptor] = context; |
| 214 | 222 |
| 215 return context; | 223 return context; |
| 216 } | 224 } |
| 217 | 225 |
| 218 scoped_refptr<ChromeURLRequestContextGetter> | 226 scoped_refptr<ChromeURLRequestContextGetter> |
| 219 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( | 227 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( |
| 220 const FilePath& partition_path, | 228 const FilePath& partition_path, |
| 221 bool in_memory) const { | 229 bool in_memory) const { |
| 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 223 // We must have a non-default path, or this will act like the default media | 231 // We must have a non-default path, or this will act like the default media |
| 224 // context. | 232 // context. |
| 225 CHECK(partition_path != profile_->GetPath()); | 233 CHECK(partition_path != profile_->GetPath()); |
| 226 LazyInitialize(); | 234 LazyInitialize(); |
| 227 | 235 |
| 228 // Keep a map of request context getters, one per requested storage partition. | 236 // Keep a map of request context getters, one per requested storage partition. |
| 229 StoragePartitionDescriptor descriptor(partition_path, in_memory); | 237 StoragePartitionDescriptor descriptor(partition_path, in_memory); |
| 230 ChromeURLRequestContextGetterMap::iterator iter = | 238 ChromeURLRequestContextGetterMap::iterator iter = |
| 231 isolated_media_request_context_getter_map_.find(descriptor); | 239 isolated_media_request_context_getter_map_.find(descriptor); |
| 232 if (iter != isolated_media_request_context_getter_map_.end()) | 240 if (iter != isolated_media_request_context_getter_map_.end()) |
| 233 return iter->second; | 241 return iter->second; |
| 234 | 242 |
| 235 // Get the app context as the starting point for the media context, so that | 243 // Get the app context as the starting point for the media context, so that |
| 236 // it uses the app's cookie store. | 244 // it uses the app's cookie store. |
| 237 ChromeURLRequestContextGetter* app_context = | 245 ChromeURLRequestContextGetterMap::const_iterator app_iter = |
| 238 GetIsolatedAppRequestContextGetter(partition_path, in_memory); | 246 app_request_context_getter_map_.find(descriptor); |
| 247 DCHECK(app_iter != app_request_context_getter_map_.end()); |
| 248 ChromeURLRequestContextGetter* app_context = app_iter->second; |
| 239 ChromeURLRequestContextGetter* context = | 249 ChromeURLRequestContextGetter* context = |
| 240 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( | 250 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( |
| 241 profile_, app_context, io_data_, descriptor); | 251 profile_, app_context, io_data_, descriptor); |
| 242 isolated_media_request_context_getter_map_[descriptor] = context; | 252 isolated_media_request_context_getter_map_[descriptor] = context; |
| 243 | 253 |
| 244 return context; | 254 return context; |
| 245 } | 255 } |
| 246 | 256 |
| 247 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( | 257 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( |
| 248 base::Time time, | 258 base::Time time, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ProfileImplIOData::ProfileImplIOData() | 304 ProfileImplIOData::ProfileImplIOData() |
| 295 : ProfileIOData(false), | 305 : ProfileIOData(false), |
| 296 http_server_properties_manager_(NULL) {} | 306 http_server_properties_manager_(NULL) {} |
| 297 ProfileImplIOData::~ProfileImplIOData() { | 307 ProfileImplIOData::~ProfileImplIOData() { |
| 298 DestroyResourceContext(); | 308 DestroyResourceContext(); |
| 299 | 309 |
| 300 if (media_request_context_.get()) | 310 if (media_request_context_.get()) |
| 301 media_request_context_->AssertNoURLRequests(); | 311 media_request_context_->AssertNoURLRequests(); |
| 302 } | 312 } |
| 303 | 313 |
| 304 void ProfileImplIOData::LazyInitializeInternal( | 314 void ProfileImplIOData::InitializeInternal( |
| 305 ProfileParams* profile_params) const { | 315 ProfileParams* profile_params, |
| 316 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 317 blob_protocol_handler, |
| 318 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 319 file_system_protocol_handler, |
| 320 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 321 developer_protocol_handler) const { |
| 306 ChromeURLRequestContext* main_context = main_request_context(); | 322 ChromeURLRequestContext* main_context = main_request_context(); |
| 307 | 323 |
| 308 IOThread* const io_thread = profile_params->io_thread; | 324 IOThread* const io_thread = profile_params->io_thread; |
| 309 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 325 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
| 310 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 326 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 311 // Only allow Record Mode if we are in a Debug build or where we are running | 327 // Only allow Record Mode if we are in a Debug build or where we are running |
| 312 // a cycle, and the user has limited control. | 328 // a cycle, and the user has limited control. |
| 313 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && | 329 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && |
| 314 (chrome::kRecordModeEnabled || | 330 (chrome::kRecordModeEnabled || |
| 315 command_line.HasSwitch(switches::kVisitURLs)); | 331 command_line.HasSwitch(switches::kVisitURLs)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 main_context->set_http_transaction_factory(main_cache); | 429 main_context->set_http_transaction_factory(main_cache); |
| 414 | 430 |
| 415 #if !defined(DISABLE_FTP_SUPPORT) | 431 #if !defined(DISABLE_FTP_SUPPORT) |
| 416 ftp_factory_.reset( | 432 ftp_factory_.reset( |
| 417 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 433 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 418 main_context->set_ftp_transaction_factory(ftp_factory_.get()); | 434 main_context->set_ftp_transaction_factory(ftp_factory_.get()); |
| 419 #endif // !defined(DISABLE_FTP_SUPPORT) | 435 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 420 | 436 |
| 421 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 437 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
| 422 new net::URLRequestJobFactoryImpl()); | 438 new net::URLRequestJobFactoryImpl()); |
| 439 main_job_factory->SetProtocolHandler( |
| 440 chrome::kBlobScheme, blob_protocol_handler.release()); |
| 441 main_job_factory->SetProtocolHandler( |
| 442 chrome::kFileSystemScheme, file_system_protocol_handler.release()); |
| 443 main_job_factory->AddInterceptor(developer_protocol_handler.release()); |
| 423 main_job_factory_ = SetUpJobFactoryDefaults( | 444 main_job_factory_ = SetUpJobFactoryDefaults( |
| 424 main_job_factory.Pass(), | 445 main_job_factory.Pass(), |
| 425 profile_params->protocol_handler_interceptor.Pass(), | 446 profile_params->protocol_handler_interceptor.Pass(), |
| 426 network_delegate(), | 447 network_delegate(), |
| 427 main_context->ftp_transaction_factory(), | 448 main_context->ftp_transaction_factory(), |
| 428 main_context->ftp_auth_cache()); | 449 main_context->ftp_auth_cache()); |
| 429 main_context->set_job_factory(main_job_factory_.get()); | 450 main_context->set_job_factory(main_job_factory_.get()); |
| 430 | 451 |
| 431 #if defined(ENABLE_EXTENSIONS) | 452 #if defined(ENABLE_EXTENSIONS) |
| 432 InitializeExtensionsRequestContext(profile_params); | 453 InitializeExtensionsRequestContext(profile_params); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 extensions_context->ftp_transaction_factory(), | 507 extensions_context->ftp_transaction_factory(), |
| 487 extensions_context->ftp_auth_cache()); | 508 extensions_context->ftp_auth_cache()); |
| 488 extensions_context->set_job_factory(extensions_job_factory_.get()); | 509 extensions_context->set_job_factory(extensions_job_factory_.get()); |
| 489 } | 510 } |
| 490 | 511 |
| 491 ChromeURLRequestContext* | 512 ChromeURLRequestContext* |
| 492 ProfileImplIOData::InitializeAppRequestContext( | 513 ProfileImplIOData::InitializeAppRequestContext( |
| 493 ChromeURLRequestContext* main_context, | 514 ChromeURLRequestContext* main_context, |
| 494 const StoragePartitionDescriptor& partition_descriptor, | 515 const StoragePartitionDescriptor& partition_descriptor, |
| 495 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 516 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 496 protocol_handler_interceptor) const { | 517 protocol_handler_interceptor, |
| 518 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 519 blob_protocol_handler, |
| 520 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 521 file_system_protocol_handler, |
| 522 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 523 developer_protocol_handler) const { |
| 497 // Copy most state from the main context. | 524 // Copy most state from the main context. |
| 498 AppRequestContext* context = new AppRequestContext(load_time_stats()); | 525 AppRequestContext* context = new AppRequestContext(load_time_stats()); |
| 499 context->CopyFrom(main_context); | 526 context->CopyFrom(main_context); |
| 500 | 527 |
| 501 FilePath cookie_path = partition_descriptor.path.Append( | 528 FilePath cookie_path = partition_descriptor.path.Append( |
| 502 chrome::kCookieFilename); | 529 chrome::kCookieFilename); |
| 503 FilePath cache_path = partition_descriptor.path.Append(chrome::kCacheDirname); | 530 FilePath cache_path = partition_descriptor.path.Append(chrome::kCacheDirname); |
| 504 | 531 |
| 505 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 532 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 506 // Only allow Record Mode if we are in a Debug build or where we are running | 533 // Only allow Record Mode if we are in a Debug build or where we are running |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); | 578 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); |
| 552 } | 579 } |
| 553 | 580 |
| 554 // Transfer ownership of the cookies and cache to AppRequestContext. | 581 // Transfer ownership of the cookies and cache to AppRequestContext. |
| 555 context->SetCookieStore(cookie_store); | 582 context->SetCookieStore(cookie_store); |
| 556 context->SetHttpTransactionFactory( | 583 context->SetHttpTransactionFactory( |
| 557 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 584 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); |
| 558 | 585 |
| 559 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 586 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 560 new net::URLRequestJobFactoryImpl()); | 587 new net::URLRequestJobFactoryImpl()); |
| 588 job_factory->SetProtocolHandler(chrome::kBlobScheme, |
| 589 blob_protocol_handler.release()); |
| 590 job_factory->SetProtocolHandler(chrome::kFileSystemScheme, |
| 591 file_system_protocol_handler.release()); |
| 592 job_factory->AddInterceptor(developer_protocol_handler.release()); |
| 561 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 593 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
| 562 // Overwrite the job factory that we inherit from the main context so | 594 // Overwrite the job factory that we inherit from the main context so |
| 563 // that we can later provide our own handlers for storage related protocols. | 595 // that we can later provide our own handlers for storage related protocols. |
| 564 // Install all the usual protocol handlers unless we are in a browser plugin | 596 // Install all the usual protocol handlers unless we are in a browser plugin |
| 565 // guest process, in which case only web-safe schemes are allowed. | 597 // guest process, in which case only web-safe schemes are allowed. |
| 566 if (!partition_descriptor.in_memory) { | 598 if (!partition_descriptor.in_memory) { |
| 567 top_job_factory = SetUpJobFactoryDefaults( | 599 top_job_factory = SetUpJobFactoryDefaults( |
| 568 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 600 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
| 569 network_delegate(), | 601 network_delegate(), |
| 570 context->ftp_transaction_factory(), | 602 context->ftp_transaction_factory(), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 ProfileImplIOData::AcquireMediaRequestContext() const { | 661 ProfileImplIOData::AcquireMediaRequestContext() const { |
| 630 DCHECK(media_request_context_.get()); | 662 DCHECK(media_request_context_.get()); |
| 631 return media_request_context_.get(); | 663 return media_request_context_.get(); |
| 632 } | 664 } |
| 633 | 665 |
| 634 ChromeURLRequestContext* | 666 ChromeURLRequestContext* |
| 635 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 667 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 636 ChromeURLRequestContext* main_context, | 668 ChromeURLRequestContext* main_context, |
| 637 const StoragePartitionDescriptor& partition_descriptor, | 669 const StoragePartitionDescriptor& partition_descriptor, |
| 638 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 670 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 639 protocol_handler_interceptor) const { | 671 protocol_handler_interceptor, |
| 672 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 673 blob_protocol_handler, |
| 674 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 675 file_system_protocol_handler, |
| 676 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 677 developer_protocol_handler) const { |
| 640 // We create per-app contexts on demand, unlike the others above. | 678 // We create per-app contexts on demand, unlike the others above. |
| 641 ChromeURLRequestContext* app_request_context = | 679 ChromeURLRequestContext* app_request_context = |
| 642 InitializeAppRequestContext(main_context, partition_descriptor, | 680 InitializeAppRequestContext(main_context, partition_descriptor, |
| 643 protocol_handler_interceptor.Pass()); | 681 protocol_handler_interceptor.Pass(), |
| 682 blob_protocol_handler.Pass(), |
| 683 file_system_protocol_handler.Pass(), |
| 684 developer_protocol_handler.Pass()); |
| 644 DCHECK(app_request_context); | 685 DCHECK(app_request_context); |
| 645 return app_request_context; | 686 return app_request_context; |
| 646 } | 687 } |
| 647 | 688 |
| 648 ChromeURLRequestContext* | 689 ChromeURLRequestContext* |
| 649 ProfileImplIOData::AcquireIsolatedMediaRequestContext( | 690 ProfileImplIOData::AcquireIsolatedMediaRequestContext( |
| 650 ChromeURLRequestContext* app_context, | 691 ChromeURLRequestContext* app_context, |
| 651 const StoragePartitionDescriptor& partition_descriptor) const { | 692 const StoragePartitionDescriptor& partition_descriptor) const { |
| 652 // We create per-app media contexts on demand, unlike the others above. | 693 // We create per-app media contexts on demand, unlike the others above. |
| 653 ChromeURLRequestContext* media_request_context = | 694 ChromeURLRequestContext* media_request_context = |
| 654 InitializeMediaRequestContext(app_context, partition_descriptor); | 695 InitializeMediaRequestContext(app_context, partition_descriptor); |
| 655 DCHECK(media_request_context); | 696 DCHECK(media_request_context); |
| 656 return media_request_context; | 697 return media_request_context; |
| 657 } | 698 } |
| 658 | 699 |
| 659 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( | 700 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( |
| 660 IOThread::Globals* io_thread_globals) const { | 701 IOThread::Globals* io_thread_globals) const { |
| 661 return io_thread_globals->load_time_stats.get(); | 702 return io_thread_globals->load_time_stats.get(); |
| 662 } | 703 } |
| 663 | 704 |
| 664 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 705 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 665 base::Time time, | 706 base::Time time, |
| 666 const base::Closure& completion) { | 707 const base::Closure& completion) { |
| 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 708 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 668 LazyInitialize(); | 709 DCHECK(initialized()); |
| 669 | 710 |
| 670 DCHECK(transport_security_state()); | 711 DCHECK(transport_security_state()); |
| 671 transport_security_state()->DeleteSince(time); // Completes synchronously. | 712 transport_security_state()->DeleteSince(time); // Completes synchronously. |
| 672 DCHECK(http_server_properties_manager_); | 713 DCHECK(http_server_properties_manager_); |
| 673 http_server_properties_manager_->Clear(completion); | 714 http_server_properties_manager_->Clear(completion); |
| 674 } | 715 } |
| OLD | NEW |