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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 void AutoThread::QuitThread( | 158 void AutoThread::QuitThread( |
159 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 159 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
160 if (!task_runner->BelongsToCurrentThread()) { | 160 if (!task_runner->BelongsToCurrentThread()) { |
161 task_runner->PostTask(FROM_HERE, base::Bind(&AutoThread::QuitThread, | 161 task_runner->PostTask(FROM_HERE, base::Bind(&AutoThread::QuitThread, |
162 base::Unretained(this), | 162 base::Unretained(this), |
163 task_runner)); | 163 task_runner)); |
164 return; | 164 return; |
165 } | 165 } |
166 | 166 |
167 base::MessageLoop::current()->Quit(); | 167 base::MessageLoop::current()->QuitWhenIdle(); |
168 was_quit_properly_ = true; | 168 was_quit_properly_ = true; |
169 | 169 |
170 if (joiner_.get()) { | 170 if (joiner_.get()) { |
171 joiner_->PostTask( | 171 joiner_->PostTask( |
172 FROM_HERE, | 172 FROM_HERE, |
173 base::Bind(&AutoThread::JoinAndDeleteThread, base::Unretained(this))); | 173 base::Bind(&AutoThread::JoinAndDeleteThread, base::Unretained(this))); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 void AutoThread::JoinAndDeleteThread() { | 177 void AutoThread::JoinAndDeleteThread() { |
(...skipping 22 matching lines...) Expand all Loading... |
200 // unlocked. | 200 // unlocked. |
201 | 201 |
202 #if defined(OS_WIN) | 202 #if defined(OS_WIN) |
203 // Initialize COM on the thread, if requested. | 203 // Initialize COM on the thread, if requested. |
204 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer( | 204 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer( |
205 CreateComInitializer(com_init_type_)); | 205 CreateComInitializer(com_init_type_)); |
206 #endif | 206 #endif |
207 | 207 |
208 message_loop.Run(); | 208 message_loop.Run(); |
209 | 209 |
210 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. | 210 // Assert that MessageLoop::QuitWhenIdle was called by AutoThread::QuitThread. |
211 DCHECK(was_quit_properly_); | 211 DCHECK(was_quit_properly_); |
212 } | 212 } |
213 | 213 |
214 } // namespace base | 214 } // namespace base |
OLD | NEW |