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