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