diff options
author | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 20:17:33 +0000 |
---|---|---|
committer | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 20:17:33 +0000 |
commit | 8ff672519df7fb4bfe32c4bf4639b383edfe45b9 (patch) | |
tree | 5d1d29c7876d2bcc287a552587a7e1dc04615271 /base/thread_checker.cc | |
parent | ccdf73e09a56a183b94a4a679041765f0bbaa2b5 (diff) | |
download | chromium_src-8ff672519df7fb4bfe32c4bf4639b383edfe45b9.zip chromium_src-8ff672519df7fb4bfe32c4bf4639b383edfe45b9.tar.gz chromium_src-8ff672519df7fb4bfe32c4bf4639b383edfe45b9.tar.bz2 |
Make ~GoogleURLChangeNotifier happen on the I/O thread.
Also change the test code to allow for its destruction.
One key problem was that the object containing WeakPtr is created on the UI
thread but then always used on the I/O thread like everything else that hangs
off of ResourceMessageFilter. The solution was to allow WeakPtr to detach
from its thread (and automatically re-attach the next time the thread is
checked).
BUG=38475
TEST=base_unittest --gtest_filter=NonThread*:ThreadChecker*
unit_tests --gtest_filter=SearchProviderInstallData*
Review URL: http://codereview.chromium.org/3627001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread_checker.cc')
-rw-r--r-- | base/thread_checker.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/base/thread_checker.cc b/base/thread_checker.cc index 124b76c..7a41a448 100644 --- a/base/thread_checker.cc +++ b/base/thread_checker.cc @@ -6,11 +6,24 @@ // This code is only done in debug builds. #ifndef NDEBUG -ThreadChecker::ThreadChecker() : valid_thread_id_(PlatformThread::CurrentId()) { + +ThreadChecker::ThreadChecker() { + EnsureThreadIdAssigned(); } bool ThreadChecker::CalledOnValidThread() const { - return valid_thread_id_ == PlatformThread::CurrentId(); + EnsureThreadIdAssigned(); + return *valid_thread_id_ == PlatformThread::CurrentId(); +} + +void ThreadChecker::DetachFromThread() { + valid_thread_id_.reset(); +} + +void ThreadChecker::EnsureThreadIdAssigned() const { + if (valid_thread_id_.get()) + return; + valid_thread_id_.reset(new PlatformThreadId(PlatformThread::CurrentId())); } #endif // NDEBUG |