summaryrefslogtreecommitdiffstats
path: root/base/thread.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-14 20:41:34 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-14 20:41:34 +0000
commitf93ff3f54183a9268b536eba606f63060c67dd50 (patch)
tree2863a6d7d16d870cd02257f7d85e4fd778f914e4 /base/thread.cc
parentc5bc140792fcf8074f7a434a19045763e1175744 (diff)
downloadchromium_src-f93ff3f54183a9268b536eba606f63060c67dd50.zip
chromium_src-f93ff3f54183a9268b536eba606f63060c67dd50.tar.gz
chromium_src-f93ff3f54183a9268b536eba606f63060c67dd50.tar.bz2
Add a Thread::CleanUpAfterMessageLoopDestruction() method which gets called after the message loop has been destroyed.
BUG=39723 TEST=ThreadTest.CleanUp Review URL: http://codereview.chromium.org/1593023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread.cc')
-rw-r--r--base/thread.cc47
1 files changed, 25 insertions, 22 deletions
diff --git a/base/thread.cc b/base/thread.cc
index aeaa0a1..05323a2b 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,34 +134,37 @@ void Thread::Run(MessageLoop* message_loop) {
}
void Thread::ThreadMain() {
- // The message loop for this thread.
- MessageLoop message_loop(startup_data_->options.message_loop_type);
+ {
+ // 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;
+ // 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();
+ // 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.
+ startup_data_->event.Signal();
+ // startup_data_ can't be touched anymore since the starting thread is now
+ // unlocked.
- Run(message_loop_);
+ Run(message_loop_);
- // Let the thread do extra cleanup.
- CleanUp();
+ // Let the thread do extra cleanup.
+ CleanUp();
- // Assert that MessageLoop::Quit was called by ThreadQuitTask.
- DCHECK(GetThreadWasQuitProperly());
+ // Assert that MessageLoop::Quit was called by ThreadQuitTask.
+ DCHECK(GetThreadWasQuitProperly());
- // We can't receive messages anymore.
- message_loop_ = NULL;
+ // We can't receive messages anymore.
+ message_loop_ = NULL;
+ }
+ CleanUpAfterMessageLoopDestruction();
thread_id_ = 0;
}