Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2399)

Unified Diff: base/message_loop/message_loop.cc

Issue 66193007: Implementation of MessagePump for Mojo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge 2 trunk Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/message_loop/message_loop_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop.cc
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 6d3d59c5e95129170e8186167d463a821c710701..e03572675aa8528a04034463e9c25cb35b2a98f7 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -146,49 +146,7 @@ MessageLoop::MessageLoop(Type type)
run_loop_(NULL) {
Init();
-// TODO(rvargas): Get rid of the OS guards.
-#if defined(OS_WIN)
-#define MESSAGE_PUMP_UI new MessagePumpForUI()
-#define MESSAGE_PUMP_IO new MessagePumpForIO()
-#elif defined(OS_IOS)
-#define MESSAGE_PUMP_UI MessagePumpMac::Create()
-#define MESSAGE_PUMP_IO new MessagePumpIOSForIO()
-#elif defined(OS_MACOSX)
-#define MESSAGE_PUMP_UI MessagePumpMac::Create()
-#define MESSAGE_PUMP_IO new MessagePumpLibevent()
-#elif defined(OS_NACL)
-// Currently NaCl doesn't have a UI MessageLoop.
-// TODO(abarth): Figure out if we need this.
-#define MESSAGE_PUMP_UI NULL
-// ipc_channel_nacl.cc uses a worker thread to do socket reads currently, and
-// doesn't require extra support for watching file descriptors.
-#define MESSAGE_PUMP_IO new MessagePumpDefault()
-#elif defined(OS_POSIX) // POSIX but not MACOSX.
-#define MESSAGE_PUMP_UI new MessagePumpForUI()
-#define MESSAGE_PUMP_IO new MessagePumpLibevent()
-#else
-#error Not implemented
-#endif
-
- if (type_ == TYPE_UI) {
- if (message_pump_for_ui_factory_)
- pump_.reset(message_pump_for_ui_factory_());
- else
- pump_.reset(MESSAGE_PUMP_UI);
- } else if (type_ == TYPE_IO) {
- pump_.reset(MESSAGE_PUMP_IO);
-#if defined(TOOLKIT_GTK)
- } else if (type_ == TYPE_GPU) {
- pump_.reset(new MessagePumpX11());
-#endif
-#if defined(OS_ANDROID)
- } else if (type_ == TYPE_JAVA) {
- pump_.reset(MESSAGE_PUMP_UI);
-#endif
- } else {
- DCHECK_EQ(TYPE_DEFAULT, type_);
- pump_.reset(new MessagePumpDefault());
- }
+ pump_.reset(CreateMessagePumpForType(type));
}
MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump)
@@ -264,6 +222,51 @@ bool MessageLoop::InitMessagePumpForUIFactory(MessagePumpFactory* factory) {
return true;
}
+// static
+MessagePump* MessageLoop::CreateMessagePumpForType(Type type) {
+// TODO(rvargas): Get rid of the OS guards.
+#if defined(OS_WIN)
+#define MESSAGE_PUMP_UI new MessagePumpForUI()
+#define MESSAGE_PUMP_IO new MessagePumpForIO()
+#elif defined(OS_IOS)
+#define MESSAGE_PUMP_UI MessagePumpMac::Create()
+#define MESSAGE_PUMP_IO new MessagePumpIOSForIO()
+#elif defined(OS_MACOSX)
+#define MESSAGE_PUMP_UI MessagePumpMac::Create()
+#define MESSAGE_PUMP_IO new MessagePumpLibevent()
+#elif defined(OS_NACL)
+// Currently NaCl doesn't have a UI MessageLoop.
+// TODO(abarth): Figure out if we need this.
+#define MESSAGE_PUMP_UI NULL
+// ipc_channel_nacl.cc uses a worker thread to do socket reads currently, and
+// doesn't require extra support for watching file descriptors.
+#define MESSAGE_PUMP_IO new MessagePumpDefault()
+#elif defined(OS_POSIX) // POSIX but not MACOSX.
+#define MESSAGE_PUMP_UI new MessagePumpForUI()
+#define MESSAGE_PUMP_IO new MessagePumpLibevent()
+#else
+#error Not implemented
+#endif
+
+ if (type == MessageLoop::TYPE_UI) {
+ if (message_pump_for_ui_factory_)
+ return message_pump_for_ui_factory_();
+ return MESSAGE_PUMP_UI;
+ }
+ if (type == MessageLoop::TYPE_IO)
+ return MESSAGE_PUMP_IO;
+#if defined(TOOLKIT_GTK)
+ if (type == MessageLoop::TYPE_GPU)
+ return new MessagePumpX11();
+#endif
+#if defined(OS_ANDROID)
+ if (type == MessageLoop::TYPE_JAVA)
+ return MESSAGE_PUMP_UI;
+#endif
+ DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
+ return new MessagePumpDefault();
+}
+
void MessageLoop::AddDestructionObserver(
DestructionObserver* destruction_observer) {
DCHECK_EQ(this, current());
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/message_loop/message_loop_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698