| 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 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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::GetMainRequestContextGetter() const { |
| 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 150 LazyInitialize(); | 138 LazyInitialize(); |
| 151 if (!main_request_context_getter_) { | 139 DCHECK(main_request_context_getter_); |
| 152 main_request_context_getter_ = | |
| 153 ChromeURLRequestContextGetter::CreateOriginal( | |
| 154 profile_, io_data_); | |
| 155 | |
| 156 content::NotificationService::current()->Notify( | |
| 157 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | |
| 158 content::Source<Profile>(profile_), | |
| 159 content::NotificationService::NoDetails()); | |
| 160 } | |
| 161 return main_request_context_getter_; | 140 return main_request_context_getter_; |
| 162 } | 141 } |
| 163 | 142 |
| 143 scoped_refptr<ChromeURLRequestContextGetter> |
| 144 ProfileImplIOData::Handle::CreateMainRequestContextGetter( |
| 145 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 146 blob_protocol_handler, |
| 147 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 148 file_system_protocol_handler, |
| 149 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 150 developer_protocol_handler, |
| 151 PrefService* local_state, |
| 152 IOThread* io_thread) const { |
| 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 154 LazyInitialize(); |
| 155 DCHECK(!main_request_context_getter_); |
| 156 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( |
| 157 profile_, io_data_, blob_protocol_handler.Pass(), |
| 158 file_system_protocol_handler.Pass(), developer_protocol_handler.Pass()); |
| 159 |
| 160 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), |
| 161 local_state, |
| 162 io_thread, |
| 163 main_request_context_getter_); |
| 164 |
| 165 content::NotificationService::current()->Notify( |
| 166 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
| 167 content::Source<Profile>(profile_), |
| 168 content::NotificationService::NoDetails()); |
| 169 return main_request_context_getter_; |
| 170 } |
| 171 |
| 164 scoped_refptr<ChromeURLRequestContextGetter> | 172 scoped_refptr<ChromeURLRequestContextGetter> |
| 165 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { | 173 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { |
| 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 167 LazyInitialize(); | 175 LazyInitialize(); |
| 168 if (!media_request_context_getter_) { | 176 if (!media_request_context_getter_) { |
| 169 media_request_context_getter_ = | 177 media_request_context_getter_ = |
| 170 ChromeURLRequestContextGetter::CreateOriginalForMedia( | 178 ChromeURLRequestContextGetter::CreateOriginalForMedia( |
| 171 profile_, io_data_); | 179 profile_, io_data_); |
| 172 } | 180 } |
| 173 return media_request_context_getter_; | 181 return media_request_context_getter_; |
| 174 } | 182 } |
| 175 | 183 |
| 176 scoped_refptr<ChromeURLRequestContextGetter> | 184 scoped_refptr<ChromeURLRequestContextGetter> |
| 177 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { | 185 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 179 LazyInitialize(); | 187 LazyInitialize(); |
| 180 if (!extensions_request_context_getter_) { | 188 if (!extensions_request_context_getter_) { |
| 181 extensions_request_context_getter_ = | 189 extensions_request_context_getter_ = |
| 182 ChromeURLRequestContextGetter::CreateOriginalForExtensions( | 190 ChromeURLRequestContextGetter::CreateOriginalForExtensions( |
| 183 profile_, io_data_); | 191 profile_, io_data_); |
| 184 } | 192 } |
| 185 return extensions_request_context_getter_; | 193 return extensions_request_context_getter_; |
| 186 } | 194 } |
| 187 | 195 |
| 188 scoped_refptr<ChromeURLRequestContextGetter> | 196 scoped_refptr<ChromeURLRequestContextGetter> |
| 189 ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter( | 197 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( |
| 190 const FilePath& partition_path, | 198 const FilePath& partition_path, |
| 191 bool in_memory) const { | 199 bool in_memory, |
| 200 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 201 blob_protocol_handler, |
| 202 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 203 file_system_protocol_handler, |
| 204 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 205 developer_protocol_handler) const { |
| 192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 193 // Check that the partition_path is not the same as the base profile path. We | 207 // 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. | 208 // expect isolated partition, which will never go to the default profile path. |
| 195 CHECK(partition_path != profile_->GetPath()); | 209 CHECK(partition_path != profile_->GetPath()); |
| 196 LazyInitialize(); | 210 LazyInitialize(); |
| 197 | 211 |
| 198 // Keep a map of request context getters, one per requested storage partition. | 212 // Keep a map of request context getters, one per requested storage partition. |
| 199 StoragePartitionDescriptor descriptor(partition_path, in_memory); | 213 StoragePartitionDescriptor descriptor(partition_path, in_memory); |
| 200 ChromeURLRequestContextGetterMap::iterator iter = | 214 ChromeURLRequestContextGetterMap::iterator iter = |
| 201 app_request_context_getter_map_.find(descriptor); | 215 app_request_context_getter_map_.find(descriptor); |
| 202 if (iter != app_request_context_getter_map_.end()) | 216 if (iter != app_request_context_getter_map_.end()) |
| 203 return iter->second; | 217 return iter->second; |
| 204 | 218 |
| 205 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 219 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 206 protocol_handler_interceptor( | 220 protocol_handler_interceptor( |
| 207 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> | 221 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> |
| 208 CreateURLInterceptor()); | 222 CreateURLInterceptor()); |
| 209 ChromeURLRequestContextGetter* context = | 223 ChromeURLRequestContextGetter* context = |
| 210 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 224 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| 211 profile_, io_data_, descriptor, | 225 profile_, io_data_, descriptor, |
| 212 protocol_handler_interceptor.Pass()); | 226 protocol_handler_interceptor.Pass(), blob_protocol_handler.Pass(), |
| 227 file_system_protocol_handler.Pass(), |
| 228 developer_protocol_handler.Pass()); |
| 213 app_request_context_getter_map_[descriptor] = context; | 229 app_request_context_getter_map_[descriptor] = context; |
| 214 | 230 |
| 215 return context; | 231 return context; |
| 216 } | 232 } |
| 217 | 233 |
| 218 scoped_refptr<ChromeURLRequestContextGetter> | 234 scoped_refptr<ChromeURLRequestContextGetter> |
| 219 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( | 235 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( |
| 220 const FilePath& partition_path, | 236 const FilePath& partition_path, |
| 221 bool in_memory) const { | 237 bool in_memory) const { |
| 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 223 // We must have a non-default path, or this will act like the default media | 239 // We must have a non-default path, or this will act like the default media |
| 224 // context. | 240 // context. |
| 225 CHECK(partition_path != profile_->GetPath()); | 241 CHECK(partition_path != profile_->GetPath()); |
| 226 LazyInitialize(); | 242 LazyInitialize(); |
| 227 | 243 |
| 228 // Keep a map of request context getters, one per requested storage partition. | 244 // Keep a map of request context getters, one per requested storage partition. |
| 229 StoragePartitionDescriptor descriptor(partition_path, in_memory); | 245 StoragePartitionDescriptor descriptor(partition_path, in_memory); |
| 230 ChromeURLRequestContextGetterMap::iterator iter = | 246 ChromeURLRequestContextGetterMap::iterator iter = |
| 231 isolated_media_request_context_getter_map_.find(descriptor); | 247 isolated_media_request_context_getter_map_.find(descriptor); |
| 232 if (iter != isolated_media_request_context_getter_map_.end()) | 248 if (iter != isolated_media_request_context_getter_map_.end()) |
| 233 return iter->second; | 249 return iter->second; |
| 234 | 250 |
| 235 // Get the app context as the starting point for the media context, so that | 251 // Get the app context as the starting point for the media context, so that |
| 236 // it uses the app's cookie store. | 252 // it uses the app's cookie store. |
| 237 ChromeURLRequestContextGetter* app_context = | 253 ChromeURLRequestContextGetterMap::const_iterator app_iter = |
| 238 GetIsolatedAppRequestContextGetter(partition_path, in_memory); | 254 app_request_context_getter_map_.find(descriptor); |
| 255 DCHECK(app_iter != app_request_context_getter_map_.end()); |
| 256 ChromeURLRequestContextGetter* app_context = app_iter->second; |
| 239 ChromeURLRequestContextGetter* context = | 257 ChromeURLRequestContextGetter* context = |
| 240 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( | 258 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( |
| 241 profile_, app_context, io_data_, descriptor); | 259 profile_, app_context, io_data_, descriptor); |
| 242 isolated_media_request_context_getter_map_[descriptor] = context; | 260 isolated_media_request_context_getter_map_[descriptor] = context; |
| 243 | 261 |
| 244 return context; | 262 return context; |
| 245 } | 263 } |
| 246 | 264 |
| 247 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( | 265 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( |
| 248 base::Time time, | 266 base::Time time, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ProfileImplIOData::ProfileImplIOData() | 312 ProfileImplIOData::ProfileImplIOData() |
| 295 : ProfileIOData(false), | 313 : ProfileIOData(false), |
| 296 http_server_properties_manager_(NULL) {} | 314 http_server_properties_manager_(NULL) {} |
| 297 ProfileImplIOData::~ProfileImplIOData() { | 315 ProfileImplIOData::~ProfileImplIOData() { |
| 298 DestroyResourceContext(); | 316 DestroyResourceContext(); |
| 299 | 317 |
| 300 if (media_request_context_.get()) | 318 if (media_request_context_.get()) |
| 301 media_request_context_->AssertNoURLRequests(); | 319 media_request_context_->AssertNoURLRequests(); |
| 302 } | 320 } |
| 303 | 321 |
| 304 void ProfileImplIOData::LazyInitializeInternal( | 322 void ProfileImplIOData::InitializeInternal( |
| 305 ProfileParams* profile_params) const { | 323 ProfileParams* profile_params, |
| 324 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 325 blob_protocol_handler, |
| 326 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 327 file_system_protocol_handler, |
| 328 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 329 developer_protocol_handler) const { |
| 306 ChromeURLRequestContext* main_context = main_request_context(); | 330 ChromeURLRequestContext* main_context = main_request_context(); |
| 307 | 331 |
| 308 IOThread* const io_thread = profile_params->io_thread; | 332 IOThread* const io_thread = profile_params->io_thread; |
| 309 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 333 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
| 310 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 334 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 311 // Only allow Record Mode if we are in a Debug build or where we are running | 335 // 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. | 336 // a cycle, and the user has limited control. |
| 313 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && | 337 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && |
| 314 (chrome::kRecordModeEnabled || | 338 (chrome::kRecordModeEnabled || |
| 315 command_line.HasSwitch(switches::kVisitURLs)); | 339 command_line.HasSwitch(switches::kVisitURLs)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 ftp_factory_.reset( | 440 ftp_factory_.reset( |
| 417 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 441 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 418 main_context->set_ftp_transaction_factory(ftp_factory_.get()); | 442 main_context->set_ftp_transaction_factory(ftp_factory_.get()); |
| 419 #endif // !defined(DISABLE_FTP_SUPPORT) | 443 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 420 | 444 |
| 421 main_context->set_chrome_url_data_manager_backend( | 445 main_context->set_chrome_url_data_manager_backend( |
| 422 chrome_url_data_manager_backend()); | 446 chrome_url_data_manager_backend()); |
| 423 | 447 |
| 424 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 448 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
| 425 new net::URLRequestJobFactoryImpl()); | 449 new net::URLRequestJobFactoryImpl()); |
| 450 main_job_factory->SetProtocolHandler( |
| 451 chrome::kBlobScheme, blob_protocol_handler.release()); |
| 452 main_job_factory->SetProtocolHandler( |
| 453 chrome::kFileSystemScheme, file_system_protocol_handler.release()); |
| 454 main_job_factory->AddInterceptor(developer_protocol_handler.release()); |
| 426 SetUpJobFactoryDefaults(main_job_factory.get(), | 455 SetUpJobFactoryDefaults(main_job_factory.get(), |
| 427 profile_params->protocol_handler_interceptor.Pass(), | 456 profile_params->protocol_handler_interceptor.Pass(), |
| 428 network_delegate(), | 457 network_delegate(), |
| 429 main_context->ftp_transaction_factory(), | 458 main_context->ftp_transaction_factory(), |
| 430 main_context->ftp_auth_cache()); | 459 main_context->ftp_auth_cache()); |
| 431 main_job_factory_ = main_job_factory.Pass(); | 460 main_job_factory_ = main_job_factory.Pass(); |
| 432 main_context->set_job_factory(main_job_factory_.get()); | 461 main_context->set_job_factory(main_job_factory_.get()); |
| 433 | 462 |
| 434 #if defined(ENABLE_EXTENSIONS) | 463 #if defined(ENABLE_EXTENSIONS) |
| 435 InitializeExtensionsRequestContext(profile_params); | 464 InitializeExtensionsRequestContext(profile_params); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 extensions_context->ftp_auth_cache()); | 519 extensions_context->ftp_auth_cache()); |
| 491 extensions_job_factory_ = extensions_job_factory.Pass(); | 520 extensions_job_factory_ = extensions_job_factory.Pass(); |
| 492 extensions_context->set_job_factory(extensions_job_factory_.get()); | 521 extensions_context->set_job_factory(extensions_job_factory_.get()); |
| 493 } | 522 } |
| 494 | 523 |
| 495 ChromeURLRequestContext* | 524 ChromeURLRequestContext* |
| 496 ProfileImplIOData::InitializeAppRequestContext( | 525 ProfileImplIOData::InitializeAppRequestContext( |
| 497 ChromeURLRequestContext* main_context, | 526 ChromeURLRequestContext* main_context, |
| 498 const StoragePartitionDescriptor& partition_descriptor, | 527 const StoragePartitionDescriptor& partition_descriptor, |
| 499 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 528 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 500 protocol_handler_interceptor) const { | 529 protocol_handler_interceptor, |
| 530 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 531 blob_protocol_handler, |
| 532 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 533 file_system_protocol_handler, |
| 534 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 535 developer_protocol_handler) const { |
| 501 // Copy most state from the main context. | 536 // Copy most state from the main context. |
| 502 AppRequestContext* context = new AppRequestContext(load_time_stats()); | 537 AppRequestContext* context = new AppRequestContext(load_time_stats()); |
| 503 context->CopyFrom(main_context); | 538 context->CopyFrom(main_context); |
| 504 | 539 |
| 505 FilePath cookie_path = partition_descriptor.path.Append( | 540 FilePath cookie_path = partition_descriptor.path.Append( |
| 506 chrome::kCookieFilename); | 541 chrome::kCookieFilename); |
| 507 FilePath cache_path = partition_descriptor.path.Append(chrome::kCacheDirname); | 542 FilePath cache_path = partition_descriptor.path.Append(chrome::kCacheDirname); |
| 508 | 543 |
| 509 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 544 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 510 // Only allow Record Mode if we are in a Debug build or where we are running | 545 // Only allow Record Mode if we are in a Debug build or where we are running |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 context->SetCookieStore(cookie_store); | 594 context->SetCookieStore(cookie_store); |
| 560 context->SetHttpTransactionFactory( | 595 context->SetHttpTransactionFactory( |
| 561 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 596 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); |
| 562 | 597 |
| 563 // Overwrite the job factory that we inherit from the main context so | 598 // Overwrite the job factory that we inherit from the main context so |
| 564 // that we can later provide our own handlers for storage related protocols. | 599 // that we can later provide our own handlers for storage related protocols. |
| 565 // Install all the usual protocol handlers unless we are in a browser plugin | 600 // Install all the usual protocol handlers unless we are in a browser plugin |
| 566 // guest process, in which case only web-safe schemes are allowed. | 601 // guest process, in which case only web-safe schemes are allowed. |
| 567 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 602 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 568 new net::URLRequestJobFactoryImpl()); | 603 new net::URLRequestJobFactoryImpl()); |
| 604 job_factory->SetProtocolHandler(chrome::kBlobScheme, |
| 605 blob_protocol_handler.release()); |
| 606 job_factory->SetProtocolHandler(chrome::kFileSystemScheme, |
| 607 file_system_protocol_handler.release()); |
| 608 job_factory->AddInterceptor(developer_protocol_handler.release()); |
| 569 if (!partition_descriptor.in_memory) { | 609 if (!partition_descriptor.in_memory) { |
| 570 SetUpJobFactoryDefaults( | 610 SetUpJobFactoryDefaults( |
| 571 job_factory.get(), protocol_handler_interceptor.Pass(), | 611 job_factory.get(), protocol_handler_interceptor.Pass(), |
| 572 network_delegate(), | 612 network_delegate(), |
| 573 context->ftp_transaction_factory(), | 613 context->ftp_transaction_factory(), |
| 574 context->ftp_auth_cache()); | 614 context->ftp_auth_cache()); |
| 575 } | 615 } |
| 576 context->SetJobFactory(job_factory.PassAs<net::URLRequestJobFactory>()); | 616 context->SetJobFactory(job_factory.PassAs<net::URLRequestJobFactory>()); |
| 577 | 617 |
| 578 return context; | 618 return context; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 ProfileImplIOData::AcquireMediaRequestContext() const { | 670 ProfileImplIOData::AcquireMediaRequestContext() const { |
| 631 DCHECK(media_request_context_.get()); | 671 DCHECK(media_request_context_.get()); |
| 632 return media_request_context_.get(); | 672 return media_request_context_.get(); |
| 633 } | 673 } |
| 634 | 674 |
| 635 ChromeURLRequestContext* | 675 ChromeURLRequestContext* |
| 636 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 676 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 637 ChromeURLRequestContext* main_context, | 677 ChromeURLRequestContext* main_context, |
| 638 const StoragePartitionDescriptor& partition_descriptor, | 678 const StoragePartitionDescriptor& partition_descriptor, |
| 639 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 679 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 640 protocol_handler_interceptor) const { | 680 protocol_handler_interceptor, |
| 681 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 682 blob_protocol_handler, |
| 683 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 684 file_system_protocol_handler, |
| 685 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 686 developer_protocol_handler) const { |
| 641 // We create per-app contexts on demand, unlike the others above. | 687 // We create per-app contexts on demand, unlike the others above. |
| 642 ChromeURLRequestContext* app_request_context = | 688 ChromeURLRequestContext* app_request_context = |
| 643 InitializeAppRequestContext(main_context, partition_descriptor, | 689 InitializeAppRequestContext(main_context, partition_descriptor, |
| 644 protocol_handler_interceptor.Pass()); | 690 protocol_handler_interceptor.Pass(), |
| 691 blob_protocol_handler.Pass(), |
| 692 file_system_protocol_handler.Pass(), |
| 693 developer_protocol_handler.Pass()); |
| 645 DCHECK(app_request_context); | 694 DCHECK(app_request_context); |
| 646 return app_request_context; | 695 return app_request_context; |
| 647 } | 696 } |
| 648 | 697 |
| 649 ChromeURLRequestContext* | 698 ChromeURLRequestContext* |
| 650 ProfileImplIOData::AcquireIsolatedMediaRequestContext( | 699 ProfileImplIOData::AcquireIsolatedMediaRequestContext( |
| 651 ChromeURLRequestContext* app_context, | 700 ChromeURLRequestContext* app_context, |
| 652 const StoragePartitionDescriptor& partition_descriptor) const { | 701 const StoragePartitionDescriptor& partition_descriptor) const { |
| 653 // We create per-app media contexts on demand, unlike the others above. | 702 // We create per-app media contexts on demand, unlike the others above. |
| 654 ChromeURLRequestContext* media_request_context = | 703 ChromeURLRequestContext* media_request_context = |
| 655 InitializeMediaRequestContext(app_context, partition_descriptor); | 704 InitializeMediaRequestContext(app_context, partition_descriptor); |
| 656 DCHECK(media_request_context); | 705 DCHECK(media_request_context); |
| 657 return media_request_context; | 706 return media_request_context; |
| 658 } | 707 } |
| 659 | 708 |
| 660 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( | 709 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( |
| 661 IOThread::Globals* io_thread_globals) const { | 710 IOThread::Globals* io_thread_globals) const { |
| 662 return io_thread_globals->load_time_stats.get(); | 711 return io_thread_globals->load_time_stats.get(); |
| 663 } | 712 } |
| 664 | 713 |
| 665 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 714 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 666 base::Time time, | 715 base::Time time, |
| 667 const base::Closure& completion) { | 716 const base::Closure& completion) { |
| 668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 717 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 669 LazyInitialize(); | 718 DCHECK(initialized()); |
| 670 | 719 |
| 671 DCHECK(transport_security_state()); | 720 DCHECK(transport_security_state()); |
| 672 transport_security_state()->DeleteSince(time); // Completes synchronously. | 721 transport_security_state()->DeleteSince(time); // Completes synchronously. |
| 673 DCHECK(http_server_properties_manager_); | 722 DCHECK(http_server_properties_manager_); |
| 674 http_server_properties_manager_->Clear(completion); | 723 http_server_properties_manager_->Clear(completion); |
| 675 } | 724 } |
| OLD | NEW |