| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/thread.h" | 5 #include "base/thread.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/thread_local.h" | 9 #include "base/thread_local.h" |
| 10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 // We should only be called on the same thread that started us. | 125 // We should only be called on the same thread that started us. |
| 126 DCHECK_NE(thread_id_, PlatformThread::CurrentId()); | 126 DCHECK_NE(thread_id_, PlatformThread::CurrentId()); |
| 127 | 127 |
| 128 // We had better have a message loop at this point! If we do not, then it | 128 // We had better have a message loop at this point! If we do not, then it |
| 129 // most likely means that the thread terminated unexpectedly, probably due | 129 // most likely means that the thread terminated unexpectedly, probably due |
| 130 // to someone calling Quit() on our message loop directly. | 130 // to someone calling Quit() on our message loop directly. |
| 131 DCHECK(message_loop_); | 131 DCHECK(message_loop_); |
| 132 | 132 |
| 133 message_loop_->PostTask(FROM_HERE, new ThreadQuitTask()); | 133 message_loop_->PostTask(FROM_HERE, new ThreadQuitTask()); |
| 134 |
| 135 // The thread can't receive messages anymore. |
| 136 message_loop_ = NULL; |
| 134 } | 137 } |
| 135 | 138 |
| 136 void Thread::ThreadMain() { | 139 void Thread::ThreadMain() { |
| 137 // The message loop for this thread. | 140 // The message loop for this thread. |
| 138 MessageLoop message_loop(startup_data_->options.message_loop_type); | 141 MessageLoop message_loop(startup_data_->options.message_loop_type); |
| 139 | 142 |
| 140 // Complete the initialization of our Thread object. | 143 // Complete the initialization of our Thread object. |
| 141 thread_id_ = PlatformThread::CurrentId(); | 144 thread_id_ = PlatformThread::CurrentId(); |
| 142 PlatformThread::SetName(name_.c_str()); | 145 PlatformThread::SetName(name_.c_str()); |
| 143 message_loop.set_thread_name(name_); | 146 message_loop.set_thread_name(name_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 156 CleanUp(); | 159 CleanUp(); |
| 157 | 160 |
| 158 // Assert that MessageLoop::Quit was called by ThreadQuitTask. | 161 // Assert that MessageLoop::Quit was called by ThreadQuitTask. |
| 159 DCHECK(GetThreadWasQuitProperly()); | 162 DCHECK(GetThreadWasQuitProperly()); |
| 160 | 163 |
| 161 // We can't receive messages anymore. | 164 // We can't receive messages anymore. |
| 162 message_loop_ = NULL; | 165 message_loop_ = NULL; |
| 163 } | 166 } |
| 164 | 167 |
| 165 } // namespace base | 168 } // namespace base |
| OLD | NEW |