Chromium Code Reviews| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_.is_null()) { | 115 if (!thread_.is_null()) { |
| 116 // AutoThread only destroys itself when there are no outstanding references | |
| 117 // to its task runner. Therefore it is guaranteed that the join is | |
| 118 // non-blocking as its task runner will always be empty at shutdown. | |
|
Wez
2014/10/17 17:57:59
This guarantee actually doesn't hold if you do the
kelvinp
2014/10/20 00:21:16
Done.
| |
| 119 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
|
Wez
2014/10/17 17:57:59
I'd recommend making this change in a separate CL,
kelvinp
2014/10/20 00:21:16
I have already added jam on this CL.
| |
| 116 base::PlatformThread::Join(thread_); | 120 base::PlatformThread::Join(thread_); |
| 117 } | 121 } |
| 118 } | 122 } |
| 119 | 123 |
| 120 scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType( | 124 scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType( |
| 121 base::MessageLoop::Type type) { | 125 base::MessageLoop::Type type) { |
| 122 DCHECK(thread_.is_null()); | 126 DCHECK(thread_.is_null()); |
| 123 #if defined(OS_WIN) | 127 #if defined(OS_WIN) |
| 124 DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessageLoop::TYPE_UI); | 128 DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessageLoop::TYPE_UI); |
| 125 #endif | 129 #endif |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 CreateComInitializer(com_init_type_)); | 209 CreateComInitializer(com_init_type_)); |
| 206 #endif | 210 #endif |
| 207 | 211 |
| 208 message_loop.Run(); | 212 message_loop.Run(); |
| 209 | 213 |
| 210 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. | 214 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. |
| 211 DCHECK(was_quit_properly_); | 215 DCHECK(was_quit_properly_); |
| 212 } | 216 } |
| 213 | 217 |
| 214 } // namespace base | 218 } // namespace base |
| OLD | NEW |