| 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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 // Complete the initialization of our Thread object. | 297 // Complete the initialization of our Thread object. |
| 298 PlatformThread::SetName(name_.c_str()); | 298 PlatformThread::SetName(name_.c_str()); |
| 299 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. | 299 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. |
| 300 | 300 |
| 301 // Lazily initialize the |message_loop| so that it can run on this thread. | 301 // Lazily initialize the |message_loop| so that it can run on this thread. |
| 302 DCHECK(message_loop_); | 302 DCHECK(message_loop_); |
| 303 std::unique_ptr<MessageLoop> message_loop(message_loop_); | 303 std::unique_ptr<MessageLoop> message_loop(message_loop_); |
| 304 message_loop_->BindToCurrentThread(); | 304 message_loop_->BindToCurrentThread(); |
| 305 message_loop_->SetTimerSlack(message_loop_timer_slack_); | 305 message_loop_->SetTimerSlack(message_loop_timer_slack_); |
| 306 | 306 |
| 307 #if defined(OS_POSIX) && !defined(OS_NACL) | 307 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_FUCHSIA) |
| 308 // Allow threads running a MessageLoopForIO to use FileDescriptorWatcher API. | 308 // Allow threads running a MessageLoopForIO to use FileDescriptorWatcher API. |
| 309 std::unique_ptr<FileDescriptorWatcher> file_descriptor_watcher; | 309 std::unique_ptr<FileDescriptorWatcher> file_descriptor_watcher; |
| 310 if (MessageLoopForIO::IsCurrent()) { | 310 if (MessageLoopForIO::IsCurrent()) { |
| 311 DCHECK_EQ(message_loop_, MessageLoopForIO::current()); | 311 DCHECK_EQ(message_loop_, MessageLoopForIO::current()); |
| 312 file_descriptor_watcher.reset( | 312 file_descriptor_watcher.reset( |
| 313 new FileDescriptorWatcher(MessageLoopForIO::current())); | 313 new FileDescriptorWatcher(MessageLoopForIO::current())); |
| 314 } | 314 } |
| 315 #endif | 315 #endif |
| 316 | 316 |
| 317 #if defined(OS_WIN) | 317 #if defined(OS_WIN) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 run_loop_ = nullptr; | 362 run_loop_ = nullptr; |
| 363 } | 363 } |
| 364 | 364 |
| 365 void Thread::ThreadQuitHelper() { | 365 void Thread::ThreadQuitHelper() { |
| 366 DCHECK(run_loop_); | 366 DCHECK(run_loop_); |
| 367 run_loop_->QuitWhenIdle(); | 367 run_loop_->QuitWhenIdle(); |
| 368 SetThreadWasQuitProperly(true); | 368 SetThreadWasQuitProperly(true); |
| 369 } | 369 } |
| 370 | 370 |
| 371 } // namespace base | 371 } // namespace base |
| OLD | NEW |