Chromium Code Reviews| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 ftp_factory_.reset( | 413 ftp_factory_.reset( |
| 414 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 414 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 415 main_context->set_ftp_transaction_factory(ftp_factory_.get()); | 415 main_context->set_ftp_transaction_factory(ftp_factory_.get()); |
| 416 #endif // !defined(DISABLE_FTP_SUPPORT) | 416 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 417 | 417 |
| 418 main_context->set_chrome_url_data_manager_backend( | 418 main_context->set_chrome_url_data_manager_backend( |
| 419 chrome_url_data_manager_backend()); | 419 chrome_url_data_manager_backend()); |
| 420 | 420 |
| 421 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 421 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
| 422 new net::URLRequestJobFactoryImpl()); | 422 new net::URLRequestJobFactoryImpl()); |
| 423 SetUpJobFactory(main_job_factory.get(), | 423 main_job_factory_ = SetUpJobFactory( |
| 424 profile_params->protocol_handler_interceptor.Pass(), | 424 main_job_factory.Pass(), |
| 425 network_delegate(), | 425 profile_params->protocol_handler_interceptor.Pass(), |
| 426 main_context->ftp_transaction_factory(), | 426 network_delegate(), |
| 427 main_context->ftp_auth_cache()); | 427 main_context->ftp_transaction_factory(), |
| 428 main_job_factory_ = main_job_factory.Pass(); | 428 main_context->ftp_auth_cache()); |
| 429 main_context->set_job_factory(main_job_factory_.get()); | 429 main_context->set_job_factory(main_job_factory_.get()); |
| 430 | 430 |
| 431 #if defined(ENABLE_EXTENSIONS) | 431 #if defined(ENABLE_EXTENSIONS) |
| 432 InitializeExtensionsRequestContext(profile_params); | 432 InitializeExtensionsRequestContext(profile_params); |
| 433 #endif | 433 #endif |
| 434 | 434 |
| 435 // Create a media request context based on the main context, but using a | 435 // Create a media request context based on the main context, but using a |
| 436 // media cache. It shares the same job factory as the main context. | 436 // media cache. It shares the same job factory as the main context. |
| 437 StoragePartitionDescriptor details(profile_path_, false); | 437 StoragePartitionDescriptor details(profile_path_, false); |
| 438 media_request_context_.reset(InitializeMediaRequestContext(main_context, | 438 media_request_context_.reset(InitializeMediaRequestContext(main_context, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 #endif // !defined(DISABLE_FTP_SUPPORT) | 472 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 473 | 473 |
| 474 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 474 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
| 475 new net::URLRequestJobFactoryImpl()); | 475 new net::URLRequestJobFactoryImpl()); |
| 476 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 476 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
| 477 // Without a network_delegate, this protocol handler will never | 477 // Without a network_delegate, this protocol handler will never |
| 478 // handle file: requests, but as a side effect it makes | 478 // handle file: requests, but as a side effect it makes |
| 479 // job_factory::IsHandledProtocol return true, which prevents attempts to | 479 // job_factory::IsHandledProtocol return true, which prevents attempts to |
| 480 // handle the protocol externally. We pass NULL in to | 480 // handle the protocol externally. We pass NULL in to |
| 481 // SetUpJobFactory() to get this effect. | 481 // SetUpJobFactory() to get this effect. |
| 482 SetUpJobFactory(extensions_job_factory.get(), | 482 extensions_job_factory_ = SetUpJobFactory( |
| 483 scoped_ptr<net::URLRequestJobFactoryImpl::Interceptor>(NULL), | 483 extensions_job_factory.Pass(), |
| 484 NULL, | 484 scoped_ptr<net::URLRequestJobFactoryImpl::Interceptor>(NULL), |
| 485 extensions_context->ftp_transaction_factory(), | 485 NULL, |
| 486 extensions_context->ftp_auth_cache()); | 486 extensions_context->ftp_transaction_factory(), |
| 487 extensions_job_factory_ = extensions_job_factory.Pass(); | 487 extensions_context->ftp_auth_cache()); |
| 488 | |
| 488 extensions_context->set_job_factory(extensions_job_factory_.get()); | 489 extensions_context->set_job_factory(extensions_job_factory_.get()); |
| 489 } | 490 } |
| 490 | 491 |
| 491 ChromeURLRequestContext* | 492 ChromeURLRequestContext* |
| 492 ProfileImplIOData::InitializeAppRequestContext( | 493 ProfileImplIOData::InitializeAppRequestContext( |
| 493 ChromeURLRequestContext* main_context, | 494 ChromeURLRequestContext* main_context, |
| 494 const StoragePartitionDescriptor& partition_descriptor, | 495 const StoragePartitionDescriptor& partition_descriptor, |
| 495 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 496 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 496 protocol_handler_interceptor) const { | 497 protocol_handler_interceptor) const { |
| 497 // Copy most state from the main context. | 498 // Copy most state from the main context. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 // first. | 551 // first. |
| 551 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); | 552 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); |
| 552 } | 553 } |
| 553 | 554 |
| 554 // Transfer ownership of the cookies and cache to AppRequestContext. | 555 // Transfer ownership of the cookies and cache to AppRequestContext. |
| 555 context->SetCookieStore(cookie_store); | 556 context->SetCookieStore(cookie_store); |
| 556 context->SetHttpTransactionFactory( | 557 context->SetHttpTransactionFactory( |
| 557 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 558 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); |
| 558 | 559 |
| 559 // Overwrite the job factory that we inherit from the main context so | 560 // Overwrite the job factory that we inherit from the main context so |
| 560 // that we can later provide our own handles for storage related protocols. | 561 // that we can later provide our own handles for storage related protocols. |
|
willchan no longer on Chromium
2012/12/11 19:14:38
s/handles/handlers/
| |
| 561 // Install all the usual protocol handlers unless we are in a browser plugin | 562 // Install all the usual protocol handlers unless we are in a browser plugin |
| 562 // guest process, in which case only web-safe schemes are allowed. | 563 // guest process, in which case only web-safe schemes are allowed. |
| 563 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 564 scoped_ptr<net::URLRequestJobFactoryImpl> base_job_factory( |
| 564 new net::URLRequestJobFactoryImpl()); | 565 new net::URLRequestJobFactoryImpl()); |
| 566 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | |
| 565 if (!partition_descriptor.in_memory) { | 567 if (!partition_descriptor.in_memory) { |
| 566 SetUpJobFactory(job_factory.get(), protocol_handler_interceptor.Pass(), | 568 top_job_factory = SetUpJobFactory(base_job_factory.Pass(), |
|
willchan no longer on Chromium
2012/12/11 19:14:38
Now that you're returning it, perhas we should ren
| |
| 567 network_delegate(), | 569 protocol_handler_interceptor.Pass(), |
| 568 context->ftp_transaction_factory(), | 570 network_delegate(), |
| 569 context->ftp_auth_cache()); | 571 context->ftp_transaction_factory(), |
| 572 context->ftp_auth_cache()); | |
| 573 } else { | |
| 574 top_job_factory = base_job_factory.PassAs<net::URLRequestJobFactory>(); | |
| 570 } | 575 } |
| 571 context->SetJobFactory(job_factory.PassAs<net::URLRequestJobFactory>()); | 576 context->SetJobFactory(top_job_factory.Pass()); |
| 572 | 577 |
| 573 return context; | 578 return context; |
| 574 } | 579 } |
| 575 | 580 |
| 576 ChromeURLRequestContext* | 581 ChromeURLRequestContext* |
| 577 ProfileImplIOData::InitializeMediaRequestContext( | 582 ProfileImplIOData::InitializeMediaRequestContext( |
| 578 ChromeURLRequestContext* original_context, | 583 ChromeURLRequestContext* original_context, |
| 579 const StoragePartitionDescriptor& partition_descriptor) const { | 584 const StoragePartitionDescriptor& partition_descriptor) const { |
| 580 // If this is for a in_memory partition, we can simply use the original | 585 // If this is for a in_memory partition, we can simply use the original |
| 581 // context (like off-the-record mode). | 586 // context (like off-the-record mode). |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 InitializeMediaRequestContext(app_context, partition_descriptor); | 655 InitializeMediaRequestContext(app_context, partition_descriptor); |
| 651 DCHECK(media_request_context); | 656 DCHECK(media_request_context); |
| 652 return media_request_context; | 657 return media_request_context; |
| 653 } | 658 } |
| 654 | 659 |
| 655 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( | 660 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( |
| 656 IOThread::Globals* io_thread_globals) const { | 661 IOThread::Globals* io_thread_globals) const { |
| 657 return io_thread_globals->load_time_stats.get(); | 662 return io_thread_globals->load_time_stats.get(); |
| 658 } | 663 } |
| 659 | 664 |
| 660 void ProfileImplIOData::SetUpJobFactory( | 665 scoped_ptr<net::URLRequestJobFactory> ProfileImplIOData::SetUpJobFactory( |
| 661 net::URLRequestJobFactoryImpl* job_factory, | 666 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, |
| 662 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 667 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 663 protocol_handler_interceptor, | 668 protocol_handler_interceptor, |
| 664 net::NetworkDelegate* network_delegate, | 669 net::NetworkDelegate* network_delegate, |
| 665 net::FtpTransactionFactory* ftp_transaction_factory, | 670 net::FtpTransactionFactory* ftp_transaction_factory, |
| 666 net::FtpAuthCache* ftp_auth_cache) const { | 671 net::FtpAuthCache* ftp_auth_cache) const { |
| 667 SetUpJobFactoryDefaults(job_factory, protocol_handler_interceptor.Pass(), | |
| 668 network_delegate, ftp_transaction_factory, | |
| 669 ftp_auth_cache); | |
| 670 | |
| 671 job_factory->AddInterceptor( | |
| 672 new chrome_browser_net::ConnectInterceptor(predictor_.get())); | |
| 673 job_factory->AddInterceptor( | 672 job_factory->AddInterceptor( |
| 674 new DoubleGetExperimentInterceptor(NULL)); | 673 new DoubleGetExperimentInterceptor(NULL)); |
| 674 scoped_ptr<net::URLRequestJobFactory> top_job_factory = | |
| 675 SetUpJobFactoryDefaults(job_factory.Pass(), | |
|
willchan no longer on Chromium
2012/12/11 19:14:38
Ditto here. Maybe this should be CreateDefaultJobF
| |
| 676 protocol_handler_interceptor.Pass(), | |
| 677 network_delegate, ftp_transaction_factory, | |
| 678 ftp_auth_cache); | |
| 679 return chrome_browser_net::ConnectInterceptor::CreateURLRequestJobFactory( | |
| 680 top_job_factory.Pass(), predictor_.get()); | |
| 675 } | 681 } |
| 676 | 682 |
| 677 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 683 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 678 base::Time time, | 684 base::Time time, |
| 679 const base::Closure& completion) { | 685 const base::Closure& completion) { |
| 680 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 681 LazyInitialize(); | 687 LazyInitialize(); |
| 682 | 688 |
| 683 DCHECK(transport_security_state()); | 689 DCHECK(transport_security_state()); |
| 684 transport_security_state()->DeleteSince(time); // Completes synchronously. | 690 transport_security_state()->DeleteSince(time); // Completes synchronously. |
| 685 DCHECK(http_server_properties_manager_); | 691 DCHECK(http_server_properties_manager_); |
| 686 http_server_properties_manager_->Clear(completion); | 692 http_server_properties_manager_->Clear(completion); |
| 687 } | 693 } |
| OLD | NEW |