| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 #elif defined(OS_MACOSX) | 212 #elif defined(OS_MACOSX) |
| 213 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(MessagePumpMac::Create()) | 213 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(MessagePumpMac::Create()) |
| 214 #define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpLibevent()) | 214 #define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpLibevent()) |
| 215 #elif defined(OS_NACL) | 215 #elif defined(OS_NACL) |
| 216 // Currently NaCl doesn't have a UI MessageLoop. | 216 // Currently NaCl doesn't have a UI MessageLoop. |
| 217 // TODO(abarth): Figure out if we need this. | 217 // TODO(abarth): Figure out if we need this. |
| 218 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>() | 218 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>() |
| 219 // ipc_channel_nacl.cc uses a worker thread to do socket reads currently, and | 219 // ipc_channel_nacl.cc uses a worker thread to do socket reads currently, and |
| 220 // doesn't require extra support for watching file descriptors. | 220 // doesn't require extra support for watching file descriptors. |
| 221 #define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpDefault()) | 221 #define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpDefault()) |
| 222 #elif defined(USE_OZONE) |
| 223 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpLibevent()) |
| 224 #define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpLibevent()) |
| 222 #elif defined(OS_POSIX) // POSIX but not MACOSX. | 225 #elif defined(OS_POSIX) // POSIX but not MACOSX. |
| 223 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI()) | 226 #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI()) |
| 224 #define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpLibevent()) | 227 #define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpLibevent()) |
| 225 #else | 228 #else |
| 226 #error Not implemented | 229 #error Not implemented |
| 227 #endif | 230 #endif |
| 228 | 231 |
| 229 if (type == MessageLoop::TYPE_UI) { | 232 if (type == MessageLoop::TYPE_UI) { |
| 230 if (message_pump_for_ui_factory_) | 233 if (message_pump_for_ui_factory_) |
| 231 return message_pump_for_ui_factory_(); | 234 return message_pump_for_ui_factory_(); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 static_cast<MessagePumpForUI*>(pump_.get())->Start(this); | 662 static_cast<MessagePumpForUI*>(pump_.get())->Start(this); |
| 660 } | 663 } |
| 661 #endif | 664 #endif |
| 662 | 665 |
| 663 #if defined(OS_IOS) | 666 #if defined(OS_IOS) |
| 664 void MessageLoopForUI::Attach() { | 667 void MessageLoopForUI::Attach() { |
| 665 static_cast<MessagePumpUIApplication*>(pump_.get())->Attach(this); | 668 static_cast<MessagePumpUIApplication*>(pump_.get())->Attach(this); |
| 666 } | 669 } |
| 667 #endif | 670 #endif |
| 668 | 671 |
| 669 #if !defined(OS_NACL) && (defined(TOOLKIT_GTK) || defined(USE_OZONE) || \ | 672 #if !defined(OS_NACL) && (defined(TOOLKIT_GTK) || \ |
| 670 defined(OS_WIN) || defined(USE_X11)) | 673 defined(OS_WIN) || defined(USE_X11)) |
| 671 void MessageLoopForUI::AddObserver(Observer* observer) { | 674 void MessageLoopForUI::AddObserver(Observer* observer) { |
| 672 pump_ui()->AddObserver(observer); | 675 pump_ui()->AddObserver(observer); |
| 673 } | 676 } |
| 674 | 677 |
| 675 void MessageLoopForUI::RemoveObserver(Observer* observer) { | 678 void MessageLoopForUI::RemoveObserver(Observer* observer) { |
| 676 pump_ui()->RemoveObserver(observer); | 679 pump_ui()->RemoveObserver(observer); |
| 677 } | 680 } |
| 678 #endif // !defined(OS_MACOSX) && !defined(OS_NACL) && !defined(OS_ANDROID) | 681 #endif // !defined(OS_MACOSX) && !defined(OS_NACL) && !defined(OS_ANDROID) |
| 679 | 682 |
| 683 #if defined(USE_OZONE) |
| 684 bool MessageLoopForUI::WatchFileDescriptor( |
| 685 int fd, |
| 686 bool persistent, |
| 687 MessagePumpLibevent::Mode mode, |
| 688 MessagePumpLibevent::FileDescriptorWatcher *controller, |
| 689 MessagePumpLibevent::Watcher *delegate) { |
| 690 return pump_libevent()->WatchFileDescriptor( |
| 691 fd, |
| 692 persistent, |
| 693 mode, |
| 694 controller, |
| 695 delegate); |
| 696 } |
| 697 #endif |
| 698 |
| 680 //------------------------------------------------------------------------------ | 699 //------------------------------------------------------------------------------ |
| 681 // MessageLoopForIO | 700 // MessageLoopForIO |
| 682 | 701 |
| 683 #if defined(OS_WIN) | 702 #if defined(OS_WIN) |
| 684 | 703 |
| 685 void MessageLoopForIO::RegisterIOHandler(HANDLE file, IOHandler* handler) { | 704 void MessageLoopForIO::RegisterIOHandler(HANDLE file, IOHandler* handler) { |
| 686 pump_io()->RegisterIOHandler(file, handler); | 705 pump_io()->RegisterIOHandler(file, handler); |
| 687 } | 706 } |
| 688 | 707 |
| 689 bool MessageLoopForIO::RegisterJobObject(HANDLE job, IOHandler* handler) { | 708 bool MessageLoopForIO::RegisterJobObject(HANDLE job, IOHandler* handler) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 720 fd, | 739 fd, |
| 721 persistent, | 740 persistent, |
| 722 mode, | 741 mode, |
| 723 controller, | 742 controller, |
| 724 delegate); | 743 delegate); |
| 725 } | 744 } |
| 726 | 745 |
| 727 #endif | 746 #endif |
| 728 | 747 |
| 729 } // namespace base | 748 } // namespace base |
| OLD | NEW |