OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/dynamic_annotations.h" | 7 #include "base/dynamic_annotations.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/thread_local.h" | 10 #include "base/thread_local.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 { | 137 { |
138 // The message loop for this thread. | 138 // The message loop for this thread. |
139 MessageLoop message_loop(startup_data_->options.message_loop_type); | 139 MessageLoop message_loop(startup_data_->options.message_loop_type); |
140 | 140 |
141 // Complete the initialization of our Thread object. | 141 // Complete the initialization of our Thread object. |
142 thread_id_ = PlatformThread::CurrentId(); | 142 thread_id_ = PlatformThread::CurrentId(); |
143 PlatformThread::SetName(name_.c_str()); | 143 PlatformThread::SetName(name_.c_str()); |
144 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. | 144 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. |
145 message_loop.set_thread_name(name_); | 145 message_loop.set_thread_name(name_); |
146 message_loop_ = &message_loop; | 146 message_loop_ = &message_loop; |
| 147 message_loop_proxy_ = MessageLoopProxy::CreateForCurrentThread(); |
147 | 148 |
148 // Let the thread do extra initialization. | 149 // Let the thread do extra initialization. |
149 // Let's do this before signaling we are started. | 150 // Let's do this before signaling we are started. |
150 Init(); | 151 Init(); |
151 | 152 |
152 startup_data_->event.Signal(); | 153 startup_data_->event.Signal(); |
153 // startup_data_ can't be touched anymore since the starting thread is now | 154 // startup_data_ can't be touched anymore since the starting thread is now |
154 // unlocked. | 155 // unlocked. |
155 | 156 |
156 Run(message_loop_); | 157 Run(message_loop_); |
157 | 158 |
158 // Let the thread do extra cleanup. | 159 // Let the thread do extra cleanup. |
159 CleanUp(); | 160 CleanUp(); |
160 | 161 |
161 // Assert that MessageLoop::Quit was called by ThreadQuitTask. | 162 // Assert that MessageLoop::Quit was called by ThreadQuitTask. |
162 DCHECK(GetThreadWasQuitProperly()); | 163 DCHECK(GetThreadWasQuitProperly()); |
163 | 164 |
164 // We can't receive messages anymore. | 165 // We can't receive messages anymore. |
165 message_loop_ = NULL; | 166 message_loop_ = NULL; |
| 167 message_loop_proxy_ = NULL; |
166 } | 168 } |
167 CleanUpAfterMessageLoopDestruction(); | 169 CleanUpAfterMessageLoopDestruction(); |
168 thread_id_ = 0; | 170 thread_id_ = 0; |
169 } | 171 } |
170 | 172 |
171 } // namespace base | 173 } // namespace base |
OLD | NEW |