OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 582 } |
583 | 583 |
584 void IOThread::ClearHostCache() { | 584 void IOThread::ClearHostCache() { |
585 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 585 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
586 | 586 |
587 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 587 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
588 if (host_cache) | 588 if (host_cache) |
589 host_cache->clear(); | 589 host_cache->clear(); |
590 } | 590 } |
591 | 591 |
592 MessageLoop* IOThread::message_loop() const { | |
593 return BrowserThread::UnsafeGetBrowserThread( | |
594 BrowserThread::IO)->message_loop(); | |
595 } | |
596 | |
597 net::SSLConfigService* IOThread::GetSSLConfigService() { | 592 net::SSLConfigService* IOThread::GetSSLConfigService() { |
598 return ssl_config_service_manager_->Get(); | 593 return ssl_config_service_manager_->Get(); |
599 } | 594 } |
600 | 595 |
601 void IOThread::InitSystemRequestContext() { | 596 void IOThread::InitSystemRequestContext() { |
602 if (system_url_request_context_getter_) | 597 if (system_url_request_context_getter_) |
603 return; | 598 return; |
604 // If we're in unit_tests, IOThread may not be run. | 599 // If we're in unit_tests, IOThread may not be run. |
605 if (!message_loop()) | 600 if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
606 return; | 601 return; |
607 ChromeProxyConfigService* proxy_config_service = | 602 ChromeProxyConfigService* proxy_config_service = |
608 ProxyServiceFactory::CreateProxyConfigService(); | 603 ProxyServiceFactory::CreateProxyConfigService(); |
609 system_proxy_config_service_.reset(proxy_config_service); | 604 system_proxy_config_service_.reset(proxy_config_service); |
610 if (pref_proxy_config_tracker_.get()) { | 605 if (pref_proxy_config_tracker_.get()) { |
611 pref_proxy_config_tracker_->SetChromeProxyConfigService( | 606 pref_proxy_config_tracker_->SetChromeProxyConfigService( |
612 proxy_config_service); | 607 proxy_config_service); |
613 } | 608 } |
614 system_url_request_context_getter_ = | 609 system_url_request_context_getter_ = |
615 new SystemURLRequestContextGetter(this); | 610 new SystemURLRequestContextGetter(this); |
616 // Safe to post an unretained this pointer, since IOThread is | 611 // Safe to post an unretained this pointer, since IOThread is |
617 // guaranteed to outlive the IO BrowserThread. | 612 // guaranteed to outlive the IO BrowserThread. |
618 message_loop()->PostTask( | 613 BrowserThread::PostTask( |
619 FROM_HERE, base::Bind(&IOThread::InitSystemRequestContextOnIOThread, | 614 BrowserThread::IO, |
620 base::Unretained(this))); | 615 FROM_HERE, |
| 616 base::Bind(&IOThread::InitSystemRequestContextOnIOThread, |
| 617 base::Unretained(this))); |
621 } | 618 } |
622 | 619 |
623 void IOThread::InitSystemRequestContextOnIOThread() { | 620 void IOThread::InitSystemRequestContextOnIOThread() { |
624 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 621 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
625 DCHECK(!globals_->system_proxy_service.get()); | 622 DCHECK(!globals_->system_proxy_service.get()); |
626 DCHECK(system_proxy_config_service_.get()); | 623 DCHECK(system_proxy_config_service_.get()); |
627 | 624 |
628 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 625 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
629 globals_->system_proxy_service.reset( | 626 globals_->system_proxy_service.reset( |
630 ProxyServiceFactory::CreateProxyService( | 627 ProxyServiceFactory::CreateProxyService( |
(...skipping 17 matching lines...) Expand all Loading... |
648 system_params.network_delegate = globals_->system_network_delegate.get(); | 645 system_params.network_delegate = globals_->system_network_delegate.get(); |
649 system_params.net_log = net_log_; | 646 system_params.net_log = net_log_; |
650 globals_->system_http_transaction_factory.reset( | 647 globals_->system_http_transaction_factory.reset( |
651 new net::HttpNetworkLayer( | 648 new net::HttpNetworkLayer( |
652 new net::HttpNetworkSession(system_params))); | 649 new net::HttpNetworkSession(system_params))); |
653 globals_->system_ftp_transaction_factory.reset( | 650 globals_->system_ftp_transaction_factory.reset( |
654 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 651 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
655 globals_->system_request_context = | 652 globals_->system_request_context = |
656 ConstructSystemRequestContext(globals_, net_log_); | 653 ConstructSystemRequestContext(globals_, net_log_); |
657 } | 654 } |
OLD | NEW |