| 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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 SSLConfigServiceManager::CreateDefaultManager(local_state, NULL)); | 372 SSLConfigServiceManager::CreateDefaultManager(local_state, NULL)); |
| 373 | 373 |
| 374 BrowserThread::SetDelegate(BrowserThread::IO, this); | 374 BrowserThread::SetDelegate(BrowserThread::IO, this); |
| 375 } | 375 } |
| 376 | 376 |
| 377 IOThread::~IOThread() { | 377 IOThread::~IOThread() { |
| 378 // This isn't needed for production code, but in tests, IOThread may | 378 // This isn't needed for production code, but in tests, IOThread may |
| 379 // be multiply constructed. | 379 // be multiply constructed. |
| 380 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 380 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
| 381 | 381 |
| 382 if (pref_proxy_config_tracker_.get()) | 382 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 383 pref_proxy_config_tracker_->DetachFromPrefService(); | |
| 384 DCHECK(!globals_); | 383 DCHECK(!globals_); |
| 385 } | 384 } |
| 386 | 385 |
| 387 IOThread::Globals* IOThread::globals() { | 386 IOThread::Globals* IOThread::globals() { |
| 388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 389 return globals_; | 388 return globals_; |
| 390 } | 389 } |
| 391 | 390 |
| 392 ChromeNetLog* IOThread::net_log() { | 391 ChromeNetLog* IOThread::net_log() { |
| 393 return net_log_; | 392 return net_log_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 528 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 530 | 529 |
| 531 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); | 530 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); |
| 532 globals_->throttler_manager->set_net_log(net_log_); | 531 globals_->throttler_manager->set_net_log(net_log_); |
| 533 // Always done in production, disabled only for unit tests. | 532 // Always done in production, disabled only for unit tests. |
| 534 globals_->throttler_manager->set_enable_thread_checks(true); | 533 globals_->throttler_manager->set_enable_thread_checks(true); |
| 535 | 534 |
| 536 globals_->proxy_script_fetcher_context.reset( | 535 globals_->proxy_script_fetcher_context.reset( |
| 537 ConstructProxyScriptFetcherContext(globals_, net_log_)); | 536 ConstructProxyScriptFetcherContext(globals_, net_log_)); |
| 538 | 537 |
| 538 system_proxy_config_service_.reset( |
| 539 ProxyServiceFactory::CreateProxyConfigService(true)); |
| 539 sdch_manager_ = new net::SdchManager(); | 540 sdch_manager_ = new net::SdchManager(); |
| 540 | 541 |
| 541 #if defined(OS_MACOSX) && !defined(OS_IOS) | 542 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 542 // Start observing Keychain events. This needs to be done on the UI thread, | 543 // Start observing Keychain events. This needs to be done on the UI thread, |
| 543 // as Keychain services requires a CFRunLoop. | 544 // as Keychain services requires a CFRunLoop. |
| 544 BrowserThread::PostTask(BrowserThread::UI, | 545 BrowserThread::PostTask(BrowserThread::UI, |
| 545 FROM_HERE, | 546 FROM_HERE, |
| 546 base::Bind(&ObserveKeychainEvents)); | 547 base::Bind(&ObserveKeychainEvents)); |
| 547 #endif | 548 #endif |
| 548 | 549 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 // in about:net-internals. | 668 // in about:net-internals. |
| 668 ClearHostCache(); | 669 ClearHostCache(); |
| 669 } | 670 } |
| 670 | 671 |
| 671 void IOThread::InitSystemRequestContext() { | 672 void IOThread::InitSystemRequestContext() { |
| 672 if (system_url_request_context_getter_) | 673 if (system_url_request_context_getter_) |
| 673 return; | 674 return; |
| 674 // If we're in unit_tests, IOThread may not be run. | 675 // If we're in unit_tests, IOThread may not be run. |
| 675 if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 676 if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
| 676 return; | 677 return; |
| 677 bool wait_for_first_update = (pref_proxy_config_tracker_.get() != NULL); | 678 pref_proxy_config_tracker_->SetChromeProxyConfigService( |
| 678 ChromeProxyConfigService* proxy_config_service = | 679 system_proxy_config_service_.get()); |
| 679 ProxyServiceFactory::CreateProxyConfigService(wait_for_first_update); | |
| 680 system_proxy_config_service_.reset(proxy_config_service); | |
| 681 if (pref_proxy_config_tracker_.get()) { | |
| 682 pref_proxy_config_tracker_->SetChromeProxyConfigService( | |
| 683 proxy_config_service); | |
| 684 } | |
| 685 system_url_request_context_getter_ = | 680 system_url_request_context_getter_ = |
| 686 new SystemURLRequestContextGetter(this); | 681 new SystemURLRequestContextGetter(this); |
| 687 // Safe to post an unretained this pointer, since IOThread is | 682 // Safe to post an unretained this pointer, since IOThread is |
| 688 // guaranteed to outlive the IO BrowserThread. | 683 // guaranteed to outlive the IO BrowserThread. |
| 689 BrowserThread::PostTask( | 684 BrowserThread::PostTask( |
| 690 BrowserThread::IO, | 685 BrowserThread::IO, |
| 691 FROM_HERE, | 686 FROM_HERE, |
| 692 base::Bind(&IOThread::InitSystemRequestContextOnIOThread, | 687 base::Bind(&IOThread::InitSystemRequestContextOnIOThread, |
| 693 base::Unretained(this))); | 688 base::Unretained(this))); |
| 694 } | 689 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 new net::HttpNetworkLayer( | 725 new net::HttpNetworkLayer( |
| 731 new net::HttpNetworkSession(system_params))); | 726 new net::HttpNetworkSession(system_params))); |
| 732 globals_->system_ftp_transaction_factory.reset( | 727 globals_->system_ftp_transaction_factory.reset( |
| 733 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 728 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 734 globals_->system_request_context.reset( | 729 globals_->system_request_context.reset( |
| 735 ConstructSystemRequestContext(globals_, net_log_)); | 730 ConstructSystemRequestContext(globals_, net_log_)); |
| 736 | 731 |
| 737 sdch_manager_->set_sdch_fetcher( | 732 sdch_manager_->set_sdch_fetcher( |
| 738 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 733 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
| 739 } | 734 } |
| 735 |
| 736 void IOThread::StartTearDown() { |
| 737 globals_->system_proxy_service->StartTearDown(); |
| 738 } |
| 739 |
| OLD | NEW |