diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 15:45:38 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 15:45:38 +0000 |
commit | bf64d1e5c95a7fa9e65395747d2d4da65de0040a (patch) | |
tree | c348ac9d116c26ab1c5de93d42f295a2f6611ee8 /base/thread.cc | |
parent | 42b15f33e277b41b5f0d90b1a07967528d0440e7 (diff) | |
download | chromium_src-bf64d1e5c95a7fa9e65395747d2d4da65de0040a.zip chromium_src-bf64d1e5c95a7fa9e65395747d2d4da65de0040a.tar.gz chromium_src-bf64d1e5c95a7fa9e65395747d2d4da65de0040a.tar.bz2 |
Reverting this CL as it causes chrome frame net tests to crash at exit. The crash happens because the IPC channel proxy
code relies on the listener threads message loop being around. This change destroys the message loop when it goes out
of scope leading to the crash.
Revert 44323 - Don't call Thread::CleanUp() before the MessageLoop destruction observers have run.
This is consistent with the comment for Thread::CleanUp(), which says it runs after the message loop has "stopped".
Certain consumers depend on this ordering to avoid accessing variables which are deleted by Thread::CleanUp().
BUG=39723
TEST=ThreadTest.CleanUp
Review URL: http://codereview.chromium.org/1540002
TBR=eroman@chromium.org
Review URL: http://codereview.chromium.org/1528034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread.cc')
-rw-r--r-- | base/thread.cc | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/base/thread.cc b/base/thread.cc index e916f2c..aeaa0a1 100644 --- a/base/thread.cc +++ b/base/thread.cc @@ -35,7 +35,7 @@ struct Thread::StartupData { event(false, false) {} }; -Thread::Thread(const char* name) +Thread::Thread(const char *name) : stopping_(false), startup_data_(NULL), thread_(0), @@ -134,30 +134,25 @@ void Thread::Run(MessageLoop* message_loop) { } void Thread::ThreadMain() { - { - // The message loop for this thread. - MessageLoop message_loop(startup_data_->options.message_loop_type); - - // Complete the initialization of our Thread object. - thread_id_ = PlatformThread::CurrentId(); - PlatformThread::SetName(name_.c_str()); - ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. - message_loop.set_thread_name(name_); - message_loop_ = &message_loop; - - // Let the thread do extra initialization. - // Let's do this before signaling we are started. - Init(); - - startup_data_->event.Signal(); - // startup_data_ can't be touched anymore since the starting thread is now - // unlocked. - - Run(message_loop_); - // Destroy |message_loop| upon leaving this scope. - } + // The message loop for this thread. + MessageLoop message_loop(startup_data_->options.message_loop_type); - message_loop_ = NULL; + // Complete the initialization of our Thread object. + thread_id_ = PlatformThread::CurrentId(); + PlatformThread::SetName(name_.c_str()); + ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. + message_loop.set_thread_name(name_); + message_loop_ = &message_loop; + + // Let the thread do extra initialization. + // Let's do this before signaling we are started. + Init(); + + startup_data_->event.Signal(); + // startup_data_ can't be touched anymore since the starting thread is now + // unlocked. + + Run(message_loop_); // Let the thread do extra cleanup. CleanUp(); @@ -166,6 +161,7 @@ void Thread::ThreadMain() { DCHECK(GetThreadWasQuitProperly()); // We can't receive messages anymore. + message_loop_ = NULL; thread_id_ = 0; } |