OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 #if defined(OS_IOS) || defined(OS_MACOSX) | 222 #if defined(OS_IOS) || defined(OS_MACOSX) |
223 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(MessagePumpMac::Create()) | 223 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(MessagePumpMac::Create()) |
224 #elif defined(OS_NACL) | 224 #elif defined(OS_NACL) |
225 // Currently NaCl doesn't have a UI MessageLoop. | 225 // Currently NaCl doesn't have a UI MessageLoop. |
226 // TODO(abarth): Figure out if we need this. | 226 // TODO(abarth): Figure out if we need this. |
227 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>() | 227 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>() |
228 #else | 228 #else |
229 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI()) | 229 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI()) |
230 #endif | 230 #endif |
231 | 231 |
232 #if defined(OS_MACOSX) | |
233 // Use an OS native runloop on Mac to support timer coalescing. | |
234 #define MESSAGE_PUMP_DEFAULT scoped_ptr<MessagePump>(MessagePumpMac::Create()) | |
Mark Mentovai
2014/06/11 21:59:42
We may want a MessagePumpCFRunLoop instead of a Me
| |
235 #else | |
236 #define MESSAGE_PUMP_DEFAULT scoped_ptr<MessagePump>(new MessagePumpDefault()) | |
237 #endif | |
238 | |
232 if (type == MessageLoop::TYPE_UI) { | 239 if (type == MessageLoop::TYPE_UI) { |
233 if (message_pump_for_ui_factory_) | 240 if (message_pump_for_ui_factory_) |
234 return message_pump_for_ui_factory_(); | 241 return message_pump_for_ui_factory_(); |
235 return MESSAGE_PUMP_UI; | 242 return MESSAGE_PUMP_UI; |
236 } | 243 } |
237 if (type == MessageLoop::TYPE_IO) | 244 if (type == MessageLoop::TYPE_IO) |
238 return scoped_ptr<MessagePump>(new MessagePumpForIO()); | 245 return scoped_ptr<MessagePump>(new MessagePumpForIO()); |
239 | 246 |
240 #if defined(OS_ANDROID) | 247 #if defined(OS_ANDROID) |
241 if (type == MessageLoop::TYPE_JAVA) | 248 if (type == MessageLoop::TYPE_JAVA) |
242 return scoped_ptr<MessagePump>(new MessagePumpForUI()); | 249 return scoped_ptr<MessagePump>(new MessagePumpForUI()); |
243 #endif | 250 #endif |
244 | 251 |
245 DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type); | 252 DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type); |
246 return scoped_ptr<MessagePump>(new MessagePumpDefault()); | 253 return MESSAGE_PUMP_DEFAULT; |
247 } | 254 } |
248 | 255 |
249 void MessageLoop::AddDestructionObserver( | 256 void MessageLoop::AddDestructionObserver( |
250 DestructionObserver* destruction_observer) { | 257 DestructionObserver* destruction_observer) { |
251 DCHECK_EQ(this, current()); | 258 DCHECK_EQ(this, current()); |
252 destruction_observers_.AddObserver(destruction_observer); | 259 destruction_observers_.AddObserver(destruction_observer); |
253 } | 260 } |
254 | 261 |
255 void MessageLoop::RemoveDestructionObserver( | 262 void MessageLoop::RemoveDestructionObserver( |
256 DestructionObserver* destruction_observer) { | 263 DestructionObserver* destruction_observer) { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 persistent, | 740 persistent, |
734 mode, | 741 mode, |
735 controller, | 742 controller, |
736 delegate); | 743 delegate); |
737 } | 744 } |
738 #endif | 745 #endif |
739 | 746 |
740 #endif // !defined(OS_NACL) | 747 #endif // !defined(OS_NACL) |
741 | 748 |
742 } // namespace base | 749 } // namespace base |
OLD | NEW |