| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return io_data_->GetResourceContext(); | 124 return io_data_->GetResourceContext(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 scoped_refptr<ChromeURLRequestContextGetter> | 127 scoped_refptr<ChromeURLRequestContextGetter> |
| 128 ProfileImplIOData::Handle::CreateMainRequestContextGetter( | 128 ProfileImplIOData::Handle::CreateMainRequestContextGetter( |
| 129 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 129 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 130 blob_protocol_handler, | 130 blob_protocol_handler, |
| 131 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 131 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 132 file_system_protocol_handler, | 132 file_system_protocol_handler, |
| 133 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 133 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 134 developer_protocol_handler, | |
| 135 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 136 chrome_protocol_handler, | 134 chrome_protocol_handler, |
| 137 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 135 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 138 chrome_devtools_protocol_handler, | 136 chrome_devtools_protocol_handler, |
| 139 PrefService* local_state, | 137 PrefService* local_state, |
| 140 IOThread* io_thread) const { | 138 IOThread* io_thread) const { |
| 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 142 LazyInitialize(); | 140 LazyInitialize(); |
| 143 DCHECK(!main_request_context_getter_); | 141 DCHECK(!main_request_context_getter_); |
| 144 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( | 142 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( |
| 145 profile_, io_data_, blob_protocol_handler.Pass(), | 143 profile_, io_data_, blob_protocol_handler.Pass(), |
| 146 file_system_protocol_handler.Pass(), developer_protocol_handler.Pass(), | 144 file_system_protocol_handler.Pass(), chrome_protocol_handler.Pass(), |
| 147 chrome_protocol_handler.Pass(), chrome_devtools_protocol_handler.Pass()); | 145 chrome_devtools_protocol_handler.Pass()); |
| 148 | 146 |
| 149 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), | 147 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), |
| 150 local_state, | 148 local_state, |
| 151 io_thread, | 149 io_thread, |
| 152 main_request_context_getter_); | 150 main_request_context_getter_); |
| 153 | 151 |
| 154 content::NotificationService::current()->Notify( | 152 content::NotificationService::current()->Notify( |
| 155 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 153 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
| 156 content::Source<Profile>(profile_), | 154 content::Source<Profile>(profile_), |
| 157 content::NotificationService::NoDetails()); | 155 content::NotificationService::NoDetails()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 184 | 182 |
| 185 scoped_refptr<ChromeURLRequestContextGetter> | 183 scoped_refptr<ChromeURLRequestContextGetter> |
| 186 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( | 184 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( |
| 187 const base::FilePath& partition_path, | 185 const base::FilePath& partition_path, |
| 188 bool in_memory, | 186 bool in_memory, |
| 189 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 187 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 190 blob_protocol_handler, | 188 blob_protocol_handler, |
| 191 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 189 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 192 file_system_protocol_handler, | 190 file_system_protocol_handler, |
| 193 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 191 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 194 developer_protocol_handler, | |
| 195 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 196 chrome_protocol_handler, | 192 chrome_protocol_handler, |
| 197 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 193 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 198 chrome_devtools_protocol_handler) const { | 194 chrome_devtools_protocol_handler) const { |
| 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 200 // Check that the partition_path is not the same as the base profile path. We | 196 // Check that the partition_path is not the same as the base profile path. We |
| 201 // expect isolated partition, which will never go to the default profile path. | 197 // expect isolated partition, which will never go to the default profile path. |
| 202 CHECK(partition_path != profile_->GetPath()); | 198 CHECK(partition_path != profile_->GetPath()); |
| 203 LazyInitialize(); | 199 LazyInitialize(); |
| 204 | 200 |
| 205 // Keep a map of request context getters, one per requested storage partition. | 201 // Keep a map of request context getters, one per requested storage partition. |
| 206 StoragePartitionDescriptor descriptor(partition_path, in_memory); | 202 StoragePartitionDescriptor descriptor(partition_path, in_memory); |
| 207 ChromeURLRequestContextGetterMap::iterator iter = | 203 ChromeURLRequestContextGetterMap::iterator iter = |
| 208 app_request_context_getter_map_.find(descriptor); | 204 app_request_context_getter_map_.find(descriptor); |
| 209 if (iter != app_request_context_getter_map_.end()) | 205 if (iter != app_request_context_getter_map_.end()) |
| 210 return iter->second; | 206 return iter->second; |
| 211 | 207 |
| 212 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 208 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 213 protocol_handler_interceptor( | 209 protocol_handler_interceptor( |
| 214 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> | 210 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> |
| 215 CreateJobInterceptorFactory()); | 211 CreateJobInterceptorFactory()); |
| 216 ChromeURLRequestContextGetter* context = | 212 ChromeURLRequestContextGetter* context = |
| 217 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 213 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| 218 profile_, io_data_, descriptor, | 214 profile_, io_data_, descriptor, |
| 219 protocol_handler_interceptor.Pass(), blob_protocol_handler.Pass(), | 215 protocol_handler_interceptor.Pass(), blob_protocol_handler.Pass(), |
| 220 file_system_protocol_handler.Pass(), | 216 file_system_protocol_handler.Pass(), chrome_protocol_handler.Pass(), |
| 221 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), | |
| 222 chrome_devtools_protocol_handler.Pass()); | 217 chrome_devtools_protocol_handler.Pass()); |
| 223 app_request_context_getter_map_[descriptor] = context; | 218 app_request_context_getter_map_[descriptor] = context; |
| 224 | 219 |
| 225 return context; | 220 return context; |
| 226 } | 221 } |
| 227 | 222 |
| 228 scoped_refptr<ChromeURLRequestContextGetter> | 223 scoped_refptr<ChromeURLRequestContextGetter> |
| 229 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( | 224 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( |
| 230 const base::FilePath& partition_path, | 225 const base::FilePath& partition_path, |
| 231 bool in_memory) const { | 226 bool in_memory) const { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 media_request_context_->AssertNoURLRequests(); | 308 media_request_context_->AssertNoURLRequests(); |
| 314 } | 309 } |
| 315 | 310 |
| 316 void ProfileImplIOData::InitializeInternal( | 311 void ProfileImplIOData::InitializeInternal( |
| 317 ProfileParams* profile_params, | 312 ProfileParams* profile_params, |
| 318 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 313 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 319 blob_protocol_handler, | 314 blob_protocol_handler, |
| 320 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 315 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 321 file_system_protocol_handler, | 316 file_system_protocol_handler, |
| 322 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 317 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 323 developer_protocol_handler, | |
| 324 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 325 chrome_protocol_handler, | 318 chrome_protocol_handler, |
| 326 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 319 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 327 chrome_devtools_protocol_handler) const { | 320 chrome_devtools_protocol_handler) const { |
| 328 ChromeURLRequestContext* main_context = main_request_context(); | 321 ChromeURLRequestContext* main_context = main_request_context(); |
| 329 | 322 |
| 330 IOThread* const io_thread = profile_params->io_thread; | 323 IOThread* const io_thread = profile_params->io_thread; |
| 331 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 324 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
| 332 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 325 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 333 // Only allow Record Mode if we are in a Debug build or where we are running | 326 // Only allow Record Mode if we are in a Debug build or where we are running |
| 334 // a cycle, and the user has limited control. | 327 // a cycle, and the user has limited control. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 set_protocol = main_job_factory->SetProtocolHandler( | 447 set_protocol = main_job_factory->SetProtocolHandler( |
| 455 chrome::kChromeDevToolsScheme, | 448 chrome::kChromeDevToolsScheme, |
| 456 chrome_devtools_protocol_handler.release()); | 449 chrome_devtools_protocol_handler.release()); |
| 457 DCHECK(set_protocol); | 450 DCHECK(set_protocol); |
| 458 main_job_factory_ = SetUpJobFactoryDefaults( | 451 main_job_factory_ = SetUpJobFactoryDefaults( |
| 459 main_job_factory.Pass(), | 452 main_job_factory.Pass(), |
| 460 profile_params->protocol_handler_interceptor.Pass(), | 453 profile_params->protocol_handler_interceptor.Pass(), |
| 461 network_delegate(), | 454 network_delegate(), |
| 462 main_context->ftp_transaction_factory(), | 455 main_context->ftp_transaction_factory(), |
| 463 main_context->ftp_auth_cache()); | 456 main_context->ftp_auth_cache()); |
| 464 main_job_factory_.reset(new net::ProtocolInterceptJobFactory( | |
| 465 main_job_factory_.Pass(), developer_protocol_handler.Pass())); | |
| 466 main_context->set_job_factory(main_job_factory_.get()); | 457 main_context->set_job_factory(main_job_factory_.get()); |
| 467 | 458 |
| 468 #if defined(ENABLE_EXTENSIONS) | 459 #if defined(ENABLE_EXTENSIONS) |
| 469 InitializeExtensionsRequestContext(profile_params); | 460 InitializeExtensionsRequestContext(profile_params); |
| 470 #endif | 461 #endif |
| 471 | 462 |
| 472 // Create a media request context based on the main context, but using a | 463 // Create a media request context based on the main context, but using a |
| 473 // media cache. It shares the same job factory as the main context. | 464 // media cache. It shares the same job factory as the main context. |
| 474 StoragePartitionDescriptor details(profile_path_, false); | 465 StoragePartitionDescriptor details(profile_path_, false); |
| 475 media_request_context_.reset(InitializeMediaRequestContext(main_context, | 466 media_request_context_.reset(InitializeMediaRequestContext(main_context, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 ProfileImplIOData::InitializeAppRequestContext( | 520 ProfileImplIOData::InitializeAppRequestContext( |
| 530 ChromeURLRequestContext* main_context, | 521 ChromeURLRequestContext* main_context, |
| 531 const StoragePartitionDescriptor& partition_descriptor, | 522 const StoragePartitionDescriptor& partition_descriptor, |
| 532 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 523 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 533 protocol_handler_interceptor, | 524 protocol_handler_interceptor, |
| 534 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 525 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 535 blob_protocol_handler, | 526 blob_protocol_handler, |
| 536 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 527 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 537 file_system_protocol_handler, | 528 file_system_protocol_handler, |
| 538 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 529 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 539 developer_protocol_handler, | |
| 540 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 541 chrome_protocol_handler, | 530 chrome_protocol_handler, |
| 542 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 531 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 543 chrome_devtools_protocol_handler) const { | 532 chrome_devtools_protocol_handler) const { |
| 544 // Copy most state from the main context. | 533 // Copy most state from the main context. |
| 545 AppRequestContext* context = new AppRequestContext(load_time_stats()); | 534 AppRequestContext* context = new AppRequestContext(load_time_stats()); |
| 546 context->CopyFrom(main_context); | 535 context->CopyFrom(main_context); |
| 547 | 536 |
| 548 base::FilePath cookie_path = partition_descriptor.path.Append( | 537 base::FilePath cookie_path = partition_descriptor.path.Append( |
| 549 chrome::kCookieFilename); | 538 chrome::kCookieFilename); |
| 550 base::FilePath cache_path = | 539 base::FilePath cache_path = |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 // guest process, in which case only web-safe schemes are allowed. | 615 // guest process, in which case only web-safe schemes are allowed. |
| 627 if (!partition_descriptor.in_memory) { | 616 if (!partition_descriptor.in_memory) { |
| 628 top_job_factory = SetUpJobFactoryDefaults( | 617 top_job_factory = SetUpJobFactoryDefaults( |
| 629 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 618 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
| 630 network_delegate(), | 619 network_delegate(), |
| 631 context->ftp_transaction_factory(), | 620 context->ftp_transaction_factory(), |
| 632 context->ftp_auth_cache()); | 621 context->ftp_auth_cache()); |
| 633 } else { | 622 } else { |
| 634 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); | 623 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); |
| 635 } | 624 } |
| 636 top_job_factory.reset(new net::ProtocolInterceptJobFactory( | |
| 637 top_job_factory.Pass(), developer_protocol_handler.Pass())); | |
| 638 context->SetJobFactory(top_job_factory.Pass()); | 625 context->SetJobFactory(top_job_factory.Pass()); |
| 639 | 626 |
| 640 return context; | 627 return context; |
| 641 } | 628 } |
| 642 | 629 |
| 643 ChromeURLRequestContext* | 630 ChromeURLRequestContext* |
| 644 ProfileImplIOData::InitializeMediaRequestContext( | 631 ProfileImplIOData::InitializeMediaRequestContext( |
| 645 ChromeURLRequestContext* original_context, | 632 ChromeURLRequestContext* original_context, |
| 646 const StoragePartitionDescriptor& partition_descriptor) const { | 633 const StoragePartitionDescriptor& partition_descriptor) const { |
| 647 // If this is for a in_memory partition, we can simply use the original | 634 // If this is for a in_memory partition, we can simply use the original |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 685 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 699 ChromeURLRequestContext* main_context, | 686 ChromeURLRequestContext* main_context, |
| 700 const StoragePartitionDescriptor& partition_descriptor, | 687 const StoragePartitionDescriptor& partition_descriptor, |
| 701 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 688 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 702 protocol_handler_interceptor, | 689 protocol_handler_interceptor, |
| 703 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 690 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 704 blob_protocol_handler, | 691 blob_protocol_handler, |
| 705 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 692 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 706 file_system_protocol_handler, | 693 file_system_protocol_handler, |
| 707 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 694 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 708 developer_protocol_handler, | |
| 709 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 710 chrome_protocol_handler, | 695 chrome_protocol_handler, |
| 711 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 696 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 712 chrome_devtools_protocol_handler) const { | 697 chrome_devtools_protocol_handler) const { |
| 713 // We create per-app contexts on demand, unlike the others above. | 698 // We create per-app contexts on demand, unlike the others above. |
| 714 ChromeURLRequestContext* app_request_context = | 699 ChromeURLRequestContext* app_request_context = |
| 715 InitializeAppRequestContext(main_context, partition_descriptor, | 700 InitializeAppRequestContext(main_context, partition_descriptor, |
| 716 protocol_handler_interceptor.Pass(), | 701 protocol_handler_interceptor.Pass(), |
| 717 blob_protocol_handler.Pass(), | 702 blob_protocol_handler.Pass(), |
| 718 file_system_protocol_handler.Pass(), | 703 file_system_protocol_handler.Pass(), |
| 719 developer_protocol_handler.Pass(), | |
| 720 chrome_protocol_handler.Pass(), | 704 chrome_protocol_handler.Pass(), |
| 721 chrome_devtools_protocol_handler.Pass()); | 705 chrome_devtools_protocol_handler.Pass()); |
| 722 DCHECK(app_request_context); | 706 DCHECK(app_request_context); |
| 723 return app_request_context; | 707 return app_request_context; |
| 724 } | 708 } |
| 725 | 709 |
| 726 ChromeURLRequestContext* | 710 ChromeURLRequestContext* |
| 727 ProfileImplIOData::AcquireIsolatedMediaRequestContext( | 711 ProfileImplIOData::AcquireIsolatedMediaRequestContext( |
| 728 ChromeURLRequestContext* app_context, | 712 ChromeURLRequestContext* app_context, |
| 729 const StoragePartitionDescriptor& partition_descriptor) const { | 713 const StoragePartitionDescriptor& partition_descriptor) const { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 743 base::Time time, | 727 base::Time time, |
| 744 const base::Closure& completion) { | 728 const base::Closure& completion) { |
| 745 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 729 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 746 DCHECK(initialized()); | 730 DCHECK(initialized()); |
| 747 | 731 |
| 748 DCHECK(transport_security_state()); | 732 DCHECK(transport_security_state()); |
| 749 transport_security_state()->DeleteSince(time); // Completes synchronously. | 733 transport_security_state()->DeleteSince(time); // Completes synchronously. |
| 750 DCHECK(http_server_properties_manager_); | 734 DCHECK(http_server_properties_manager_); |
| 751 http_server_properties_manager_->Clear(completion); | 735 http_server_properties_manager_->Clear(completion); |
| 752 } | 736 } |
| OLD | NEW |