| 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 "remoting/base/auto_thread.h" | 5 #include "remoting/base/auto_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/third_party/dynamic_annotations/dynamic_annotations.h" | 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 thread_(0), | 105 thread_(0), |
| 106 name_(name), | 106 name_(name), |
| 107 was_quit_properly_(false), | 107 was_quit_properly_(false), |
| 108 joiner_(joiner) { | 108 joiner_(joiner) { |
| 109 } | 109 } |
| 110 | 110 |
| 111 AutoThread::~AutoThread() { | 111 AutoThread::~AutoThread() { |
| 112 DCHECK(!startup_data_); | 112 DCHECK(!startup_data_); |
| 113 | 113 |
| 114 // Wait for the thread to exit. | 114 // Wait for the thread to exit. |
| 115 if (thread_) { | 115 if (!thread_.isNull()) { |
| 116 base::PlatformThread::Join(thread_); | 116 base::PlatformThread::Join(thread_); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType( | 120 scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType( |
| 121 base::MessageLoop::Type type) { | 121 base::MessageLoop::Type type) { |
| 122 DCHECK(!thread_); | 122 DCHECK(thread_.isNull()); |
| 123 #if defined(OS_WIN) | 123 #if defined(OS_WIN) |
| 124 DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessageLoop::TYPE_UI); | 124 DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessageLoop::TYPE_UI); |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 StartupData startup_data(type); | 127 StartupData startup_data(type); |
| 128 startup_data_ = &startup_data; | 128 startup_data_ = &startup_data; |
| 129 | 129 |
| 130 if (!base::PlatformThread::Create(0, this, &thread_)) { | 130 if (!base::PlatformThread::Create(0, this, &thread_)) { |
| 131 DLOG(ERROR) << "failed to create thread"; | 131 DLOG(ERROR) << "failed to create thread"; |
| 132 startup_data_ = NULL; | 132 startup_data_ = NULL; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 CreateComInitializer(com_init_type_)); | 204 CreateComInitializer(com_init_type_)); |
| 205 #endif | 205 #endif |
| 206 | 206 |
| 207 message_loop.Run(); | 207 message_loop.Run(); |
| 208 | 208 |
| 209 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. | 209 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. |
| 210 DCHECK(was_quit_properly_); | 210 DCHECK(was_quit_properly_); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace base | 213 } // namespace base |
| OLD | NEW |