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