| 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 // Note that since we are at BrowserThread::Init time, the UI thread | 577 // Note that since we are at BrowserThread::Init time, the UI thread |
| 578 // is blocked waiting for the thread to start. Therefore, posting | 578 // is blocked waiting for the thread to start. Therefore, posting |
| 579 // this task to the main thread's message loop here is guaranteed to | 579 // this task to the main thread's message loop here is guaranteed to |
| 580 // get it onto the message loop while the IOThread object still | 580 // get it onto the message loop while the IOThread object still |
| 581 // exists. However, the message might not be processed on the UI | 581 // exists. However, the message might not be processed on the UI |
| 582 // thread until after IOThread is gone, so use a weak pointer. | 582 // thread until after IOThread is gone, so use a weak pointer. |
| 583 BrowserThread::PostTask(BrowserThread::UI, | 583 BrowserThread::PostTask(BrowserThread::UI, |
| 584 FROM_HERE, | 584 FROM_HERE, |
| 585 base::Bind(&IOThread::InitSystemRequestContext, | 585 base::Bind(&IOThread::InitSystemRequestContext, |
| 586 weak_factory_.GetWeakPtr())); | 586 weak_factory_.GetWeakPtr())); |
| 587 | |
| 588 // We constructed the weak pointer on the IO thread but it will be | |
| 589 // used on the UI thread. Call this to avoid a thread checker | |
| 590 // error. | |
| 591 weak_factory_.DetachFromThread(); | |
| 592 } | 587 } |
| 593 | 588 |
| 594 void IOThread::CleanUp() { | 589 void IOThread::CleanUp() { |
| 595 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); | 590 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); |
| 596 | 591 |
| 597 delete sdch_manager_; | 592 delete sdch_manager_; |
| 598 sdch_manager_ = NULL; | 593 sdch_manager_ = NULL; |
| 599 | 594 |
| 600 #if defined(USE_NSS) || defined(OS_IOS) | 595 #if defined(USE_NSS) || defined(OS_IOS) |
| 601 net::ShutdownNSSHttpIO(); | 596 net::ShutdownNSSHttpIO(); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 globals_->system_request_context.reset( | 906 globals_->system_request_context.reset( |
| 912 ConstructSystemRequestContext(globals_, net_log_)); | 907 ConstructSystemRequestContext(globals_, net_log_)); |
| 913 | 908 |
| 914 sdch_manager_->set_sdch_fetcher( | 909 sdch_manager_->set_sdch_fetcher( |
| 915 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 910 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
| 916 } | 911 } |
| 917 | 912 |
| 918 void IOThread::UpdateDnsClientEnabled() { | 913 void IOThread::UpdateDnsClientEnabled() { |
| 919 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); | 914 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); |
| 920 } | 915 } |
| OLD | NEW |