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 \ |
| 235 scoped_ptr<MessagePump>(new MessagePumpCFRunLoop()) |
| 236 #else |
| 237 #define MESSAGE_PUMP_DEFAULT scoped_ptr<MessagePump>(new MessagePumpDefault()) |
| 238 #endif |
| 239 |
232 if (type == MessageLoop::TYPE_UI) { | 240 if (type == MessageLoop::TYPE_UI) { |
233 if (message_pump_for_ui_factory_) | 241 if (message_pump_for_ui_factory_) |
234 return message_pump_for_ui_factory_(); | 242 return message_pump_for_ui_factory_(); |
235 return MESSAGE_PUMP_UI; | 243 return MESSAGE_PUMP_UI; |
236 } | 244 } |
237 if (type == MessageLoop::TYPE_IO) | 245 if (type == MessageLoop::TYPE_IO) |
238 return scoped_ptr<MessagePump>(new MessagePumpForIO()); | 246 return scoped_ptr<MessagePump>(new MessagePumpForIO()); |
239 | 247 |
240 #if defined(OS_ANDROID) | 248 #if defined(OS_ANDROID) |
241 if (type == MessageLoop::TYPE_JAVA) | 249 if (type == MessageLoop::TYPE_JAVA) |
242 return scoped_ptr<MessagePump>(new MessagePumpForUI()); | 250 return scoped_ptr<MessagePump>(new MessagePumpForUI()); |
243 #endif | 251 #endif |
244 | 252 |
245 DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type); | 253 DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type); |
246 return scoped_ptr<MessagePump>(new MessagePumpDefault()); | 254 return MESSAGE_PUMP_DEFAULT; |
247 } | 255 } |
248 | 256 |
249 void MessageLoop::AddDestructionObserver( | 257 void MessageLoop::AddDestructionObserver( |
250 DestructionObserver* destruction_observer) { | 258 DestructionObserver* destruction_observer) { |
251 DCHECK_EQ(this, current()); | 259 DCHECK_EQ(this, current()); |
252 destruction_observers_.AddObserver(destruction_observer); | 260 destruction_observers_.AddObserver(destruction_observer); |
253 } | 261 } |
254 | 262 |
255 void MessageLoop::RemoveDestructionObserver( | 263 void MessageLoop::RemoveDestructionObserver( |
256 DestructionObserver* destruction_observer) { | 264 DestructionObserver* destruction_observer) { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 persistent, | 741 persistent, |
734 mode, | 742 mode, |
735 controller, | 743 controller, |
736 delegate); | 744 delegate); |
737 } | 745 } |
738 #endif | 746 #endif |
739 | 747 |
740 #endif // !defined(OS_NACL) | 748 #endif // !defined(OS_NACL) |
741 | 749 |
742 } // namespace base | 750 } // namespace base |
OLD | NEW |