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.h | |
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.h')
-rw-r--r-- | base/thread_checker.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/base/thread_checker.h b/base/thread_checker.h index 4e1d792..60b8474 100644 --- a/base/thread_checker.h +++ b/base/thread_checker.h @@ -7,6 +7,7 @@ #pragma once #include "base/platform_thread.h" +#include "base/scoped_ptr.h" // Before using this class, please consider using NonThreadSafe as it // makes it much easier to determine the nature of your class. @@ -37,8 +38,16 @@ class ThreadChecker { bool CalledOnValidThread() const; + // Changes the thread that is checked for in CalledOnValidThread. This may + // be useful when an object may be created on one thread and then used + // exclusively on another thread. + void DetachFromThread(); + private: - const PlatformThreadId valid_thread_id_; + void EnsureThreadIdAssigned() const; + + // This is mutable so that CalledOnValidThread can set it. + mutable scoped_ptr<PlatformThreadId> valid_thread_id_; }; #else // Do nothing in release mode. @@ -47,6 +56,8 @@ class ThreadChecker { bool CalledOnValidThread() const { return true; } + + void DetachFromThread() {} }; #endif // NDEBUG |