Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/io_thread.cc

Issue 14299011: Remove all but one use of WeakPtrFactory::DetachFromThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify change to IOThread. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 globals_->system_request_context.reset( 908 globals_->system_request_context.reset(
914 ConstructSystemRequestContext(globals_, net_log_)); 909 ConstructSystemRequestContext(globals_, net_log_));
915 910
916 sdch_manager_->set_sdch_fetcher( 911 sdch_manager_->set_sdch_fetcher(
917 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 912 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
918 } 913 }
919 914
920 void IOThread::UpdateDnsClientEnabled() { 915 void IOThread::UpdateDnsClientEnabled() {
921 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); 916 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_);
922 } 917 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698