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/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_id_name_manager.h" | 10 #include "base/threading/thread_id_name_manager.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 #ifndef NDEBUG | 167 #ifndef NDEBUG |
168 quit_properly = lazy_tls_bool.Pointer()->Get(); | 168 quit_properly = lazy_tls_bool.Pointer()->Get(); |
169 #endif | 169 #endif |
170 return quit_properly; | 170 return quit_properly; |
171 } | 171 } |
172 | 172 |
173 void Thread::ThreadMain() { | 173 void Thread::ThreadMain() { |
174 { | 174 { |
175 // The message loop for this thread. | 175 // The message loop for this thread. |
176 // Allocated on the heap to centralize any leak reports at this line. | 176 // Allocated on the heap to centralize any leak reports at this line. |
177 scoped_ptr<MessageLoop> message_loop( | 177 scoped_ptr<MessageLoop> message_loop; |
178 new MessageLoop(startup_data_->options.message_loop_type)); | 178 if (startup_data_->options.message_pump) { |
| 179 message_loop.reset(new MessageLoop( |
| 180 scoped_ptr<base::MessagePump>( |
| 181 startup_data_->options.message_pump))); |
| 182 } else { |
| 183 message_loop.reset( |
| 184 new MessageLoop(startup_data_->options.message_loop_type)); |
| 185 } |
179 | 186 |
180 // Complete the initialization of our Thread object. | 187 // Complete the initialization of our Thread object. |
181 thread_id_ = PlatformThread::CurrentId(); | 188 thread_id_ = PlatformThread::CurrentId(); |
182 PlatformThread::SetName(name_.c_str()); | 189 PlatformThread::SetName(name_.c_str()); |
183 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. | 190 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. |
184 message_loop->set_thread_name(name_); | 191 message_loop->set_thread_name(name_); |
185 message_loop_ = message_loop.get(); | 192 message_loop_ = message_loop.get(); |
186 | 193 |
187 #if defined(OS_WIN) | 194 #if defined(OS_WIN) |
188 scoped_ptr<win::ScopedCOMInitializer> com_initializer; | 195 scoped_ptr<win::ScopedCOMInitializer> com_initializer; |
(...skipping 25 matching lines...) Expand all Loading... |
214 | 221 |
215 // Assert that MessageLoop::Quit was called by ThreadQuitHelper. | 222 // Assert that MessageLoop::Quit was called by ThreadQuitHelper. |
216 DCHECK(GetThreadWasQuitProperly()); | 223 DCHECK(GetThreadWasQuitProperly()); |
217 | 224 |
218 // We can't receive messages anymore. | 225 // We can't receive messages anymore. |
219 message_loop_ = NULL; | 226 message_loop_ = NULL; |
220 } | 227 } |
221 } | 228 } |
222 | 229 |
223 } // namespace base | 230 } // namespace base |
OLD | NEW |