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/non_thread_safe_unittest.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/non_thread_safe_unittest.cc')
-rw-r--r-- | base/non_thread_safe_unittest.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/base/non_thread_safe_unittest.cc b/base/non_thread_safe_unittest.cc index 0603987..1db198b 100644 --- a/base/non_thread_safe_unittest.cc +++ b/base/non_thread_safe_unittest.cc @@ -23,6 +23,10 @@ class NonThreadSafeClass : public NonThreadSafe { DCHECK(CalledOnValidThread()); } + void DetachFromThread() { + NonThreadSafe::DetachFromThread(); + } + private: DISALLOW_COPY_AND_ASSIGN(NonThreadSafeClass); }; @@ -74,6 +78,20 @@ TEST(NonThreadSafeTest, CallsAllowedOnSameThread) { non_thread_safe_class.reset(); } +TEST(NonThreadSafeTest, DetachThenDestructOnDifferentThread) { + scoped_ptr<NonThreadSafeClass> non_thread_safe_class( + new NonThreadSafeClass); + + // Verify that the destructor doesn't assert when called on a different thread + // after a detach. + non_thread_safe_class->DetachFromThread(); + DeleteNonThreadSafeClassOnThread delete_on_thread( + non_thread_safe_class.release()); + + delete_on_thread.Start(); + delete_on_thread.Join(); +} + #if GTEST_HAS_DEATH_TEST TEST(NonThreadSafeDeathTest, MethodNotAllowedOnDifferentThread) { |