OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/thread.h" | 5 #include "base/threading/thread.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 id_event_.Signal(); | 224 id_event_.Signal(); |
225 | 225 |
226 // Complete the initialization of our Thread object. | 226 // Complete the initialization of our Thread object. |
227 PlatformThread::SetName(name_.c_str()); | 227 PlatformThread::SetName(name_.c_str()); |
228 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. | 228 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. |
229 | 229 |
230 // Lazily initialize the message_loop so that it can run on this thread. | 230 // Lazily initialize the message_loop so that it can run on this thread. |
231 DCHECK(message_loop_); | 231 DCHECK(message_loop_); |
232 std::unique_ptr<MessageLoop> message_loop(message_loop_); | 232 std::unique_ptr<MessageLoop> message_loop(message_loop_); |
233 message_loop_->BindToCurrentThread(); | 233 message_loop_->BindToCurrentThread(); |
234 message_loop_->set_thread_name(name_); | |
235 message_loop_->SetTimerSlack(message_loop_timer_slack_); | 234 message_loop_->SetTimerSlack(message_loop_timer_slack_); |
236 | 235 |
237 #if defined(OS_WIN) | 236 #if defined(OS_WIN) |
238 std::unique_ptr<win::ScopedCOMInitializer> com_initializer; | 237 std::unique_ptr<win::ScopedCOMInitializer> com_initializer; |
239 if (com_status_ != NONE) { | 238 if (com_status_ != NONE) { |
240 com_initializer.reset((com_status_ == STA) ? | 239 com_initializer.reset((com_status_ == STA) ? |
241 new win::ScopedCOMInitializer() : | 240 new win::ScopedCOMInitializer() : |
242 new win::ScopedCOMInitializer(win::ScopedCOMInitializer::kMTA)); | 241 new win::ScopedCOMInitializer(win::ScopedCOMInitializer::kMTA)); |
243 } | 242 } |
244 #endif | 243 #endif |
(...skipping 28 matching lines...) Expand all Loading... |
273 // allow this. | 272 // allow this. |
274 DCHECK(GetThreadWasQuitProperly()); | 273 DCHECK(GetThreadWasQuitProperly()); |
275 } | 274 } |
276 | 275 |
277 // We can't receive messages anymore. | 276 // We can't receive messages anymore. |
278 // (The message loop is destructed at the end of this block) | 277 // (The message loop is destructed at the end of this block) |
279 message_loop_ = nullptr; | 278 message_loop_ = nullptr; |
280 } | 279 } |
281 | 280 |
282 } // namespace base | 281 } // namespace base |
OLD | NEW |