summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-06 04:51:21 +0000
committerrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-06 04:51:21 +0000
commitc335f480be26b7bea785ed96501e89272069fa47 (patch)
tree4d223fb7842f249c23031dca4295e05ae1207c9e
parentd33e05ceff2ae365e47e1e1a8f36592d2fb10526 (diff)
downloadchromium_src-c335f480be26b7bea785ed96501e89272069fa47.zip
chromium_src-c335f480be26b7bea785ed96501e89272069fa47.tar.gz
chromium_src-c335f480be26b7bea785ed96501e89272069fa47.tar.bz2
Add a message pump for ChromeOS Embedded.
A message pump implementation for embedded ChromeOS. BUG=180666 Review URL: https://chromiumcodereview.appspot.com/12546010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192703 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/accelerators/nested_dispatcher_controller_unittest.cc4
-rw-r--r--base/base.gyp5
-rw-r--r--base/base.gypi12
-rw-r--r--base/message_loop.h6
-rw-r--r--base/message_pump_linux.cc62
-rw-r--r--base/message_pump_linux.h55
-rw-r--r--build/build_config.h2
-rw-r--r--build/common.gypi23
-rw-r--r--ui/aura/env.cc2
9 files changed, 164 insertions, 7 deletions
diff --git a/ash/accelerators/nested_dispatcher_controller_unittest.cc b/ash/accelerators/nested_dispatcher_controller_unittest.cc
index 4e42d6b..3cf1721 100644
--- a/ash/accelerators/nested_dispatcher_controller_unittest.cc
+++ b/ash/accelerators/nested_dispatcher_controller_unittest.cc
@@ -35,13 +35,13 @@ class MockDispatcher : public MessageLoop::Dispatcher {
int num_key_events_dispatched() { return num_key_events_dispatched_; }
-#if defined(OS_WIN) || defined(USE_X11)
+#if defined(OS_WIN) || defined(USE_X11) || defined(USE_MESSAGEPUMP_LINUX)
virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE {
if (ui::EventTypeFromNative(event) == ui::ET_KEY_RELEASED)
num_key_events_dispatched_++;
return !ui::IsNoopEvent(event);
}
-#endif // defined(OS_WIN) || defined(USE_X11)
+#endif
private:
int num_key_events_dispatched_;
diff --git a/base/base.gyp b/base/base.gyp
index a8f2832..1c54c8e 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -741,6 +741,11 @@
'message_pump_glib_unittest.cc',
]
}],
+ ['use_messagepump_linux == 1', {
+ 'sources!': [
+ 'message_pump_glib_unittest.cc',
+ ]
+ }],
# This is needed to trigger the dll copy step on windows.
# TODO(mark): This should not be necessary.
['OS == "win"', {
diff --git a/base/base.gypi b/base/base.gypi
index 9f1dc84..5609171 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -291,6 +291,8 @@
'message_pump.h',
'message_pump_android.cc',
'message_pump_android.h',
+ 'message_pump_linux.cc',
+ 'message_pump_linux.h',
'message_pump_default.cc',
'message_pump_default.h',
'message_pump_win.cc',
@@ -730,6 +732,16 @@
'string16.cc',
],
},],
+ ['<(use_messagepump_linux) == 1', {
+ 'sources!': [
+ 'message_pump_glib.cc',
+ 'message_pump_aurax11.cc',
+ ]
+ }, { # use_message_pump_linux!=1
+ 'sources!': [
+ 'message_pump_linux.cc',
+ ],
+ }],
['OS == "linux" and >(nacl_untrusted_build)==0', {
'sources!': [
'files/file_path_watcher_kqueue.cc',
diff --git a/base/message_loop.h b/base/message_loop.h
index 0de51ab..dbe75a5 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -34,6 +34,8 @@
#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
#include "base/message_pump_aurax11.h"
+#elif defined(USE_MESSAGEPUMP_LINUX) && !defined(OS_NACL)
+#include "base/message_pump_linux.h"
#else
#include "base/message_pump_gtk.h"
#endif
@@ -573,6 +575,7 @@ class BASE_EXPORT MessageLoopForUI : public MessageLoop {
// events to the Java message loop.
void Start();
#elif !defined(OS_MACOSX)
+
// Please see message_pump_win/message_pump_glib for definitions of these
// methods.
void AddObserver(Observer* observer);
@@ -589,6 +592,9 @@ class BASE_EXPORT MessageLoopForUI : public MessageLoop {
#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
friend class base::MessagePumpAuraX11;
#endif
+#if defined(USE_MESSAGEPUMP_LINUX) && !defined(OS_NACL)
+ friend class base::MessagePumpLinux;
+#endif
// TODO(rvargas): Make this platform independent.
base::MessagePumpForUI* pump_ui() {
diff --git a/base/message_pump_linux.cc b/base/message_pump_linux.cc
new file mode 100644
index 0000000..6735e18
--- /dev/null
+++ b/base/message_pump_linux.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/message_pump_linux.h"
+
+#include "base/logging.h"
+#include "base/message_loop.h"
+
+namespace base {
+
+MessagePumpLinux::MessagePumpLinux()
+ : MessagePumpLibevent() {
+}
+
+MessagePumpLinux::~MessagePumpLinux() {
+}
+
+void MessagePumpLinux::AddObserver(MessagePumpObserver* /* observer */) {
+ NOTIMPLEMENTED();
+}
+
+void MessagePumpLinux::RemoveObserver(MessagePumpObserver* /* observer */) {
+ NOTIMPLEMENTED();
+}
+
+// static
+MessagePumpLinux* MessagePumpLinux::Current() {
+ MessageLoopForUI* loop = MessageLoopForUI::current();
+ return static_cast<MessagePumpLinux*>(loop->pump_ui());
+}
+
+void MessagePumpLinux::AddDispatcherForRootWindow(
+ MessagePumpDispatcher* dispatcher) {
+ // Only one root window is supported.
+ DCHECK(dispatcher_.size() == 0);
+ dispatcher_.insert(dispatcher_.begin(),dispatcher);
+}
+
+void MessagePumpLinux::RemoveDispatcherForRootWindow(
+ MessagePumpDispatcher* dispatcher) {
+ DCHECK(dispatcher_.size() == 1);
+ dispatcher_.pop_back();
+}
+
+bool MessagePumpLinux::Dispatch(const base::NativeEvent& dev) {
+ // fprintf(stderr, "MessagePumpLinux::Dispatch... got event\n");
+ if (dispatcher_.size() > 0)
+ return dispatcher_[0]->Dispatch(dev);
+ else
+ return true;
+}
+
+// This code assumes that the caller tracks the lifetime of the |dispatcher|.
+void MessagePumpLinux::RunWithDispatcher(
+ Delegate* delegate, MessagePumpDispatcher* dispatcher) {
+ dispatcher_.push_back(dispatcher);
+ Run(delegate);
+ dispatcher_.pop_back();
+}
+
+} // namespace base
diff --git a/base/message_pump_linux.h b/base/message_pump_linux.h
new file mode 100644
index 0000000..0973849
--- /dev/null
+++ b/base/message_pump_linux.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_MESSAGE_PUMP_LINUX_H_
+#define BASE_MESSAGE_PUMP_LINUX_H_
+
+
+#include "base/message_pump.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "base/message_pump_dispatcher.h"
+#include "base/message_pump_libevent.h"
+#include "base/message_pump_observer.h"
+#include "base/observer_list.h"
+
+namespace base {
+
+// This class implements a message-pump for processing events from input devices
+// Refer to MessagePump for further documentation.
+class BASE_EXPORT MessagePumpLinux : public MessagePumpLibevent,
+ public MessagePumpDispatcher {
+ public:
+ MessagePumpLinux();
+ virtual ~MessagePumpLinux();
+
+ // Returns the UI message pump.
+ static MessagePumpLinux* Current();
+
+ // Add/Remove the root window dispatcher.
+ void AddDispatcherForRootWindow(MessagePumpDispatcher* dispatcher);
+ void RemoveDispatcherForRootWindow(MessagePumpDispatcher* dispatcher);
+
+ void RunWithDispatcher(Delegate* delegate, MessagePumpDispatcher* dispatcher);
+
+ // Add / remove an Observer, which will start receiving notifications
+ // immediately.
+ void AddObserver(MessagePumpObserver* observer);
+ void RemoveObserver(MessagePumpObserver* observer);
+
+ // Overridden from MessagePumpDispatcher.
+ virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
+
+ private:
+ std::vector<MessagePumpDispatcher*> dispatcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(MessagePumpLinux);
+};
+
+typedef MessagePumpLinux MessagePumpForUI;
+
+} // namespace base
+
+#endif // BASE_MESSAGE_PUMP_LINUX_H_
diff --git a/build/build_config.h b/build/build_config.h
index 7b56dd5..97eb397 100644
--- a/build/build_config.h
+++ b/build/build_config.h
@@ -69,7 +69,7 @@
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
- !defined(OS_NACL)
+ !defined(OS_NACL) && !defined(USE_MESSAGEPUMP_LINUX)
#define USE_X11 1 // Use X for graphics.
#endif
diff --git a/build/common.gypi b/build/common.gypi
index 9aa5b1e..0fe8b73 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -26,12 +26,18 @@
# Whether or not we are building the Ash shell.
'use_ash%': 0,
+
+ # Whether or not we are using the embedded messagepump.
+ 'use_messagepump_linux%': 0,
},
# Copy conditionally-set variables out one scope.
'chromeos%': '<(chromeos)',
'use_aura%': '<(use_aura)',
'use_ash%': '<(use_ash)',
+ # Whether or not we are using the /dev/input/event* message pump.
+ 'use_messagepump_linux%': '<(use_messagepump_linux)',
+
# Whether we are using Views Toolkit
'toolkit_views%': 0,
@@ -91,6 +97,7 @@
'chromeos%': '<(chromeos)',
'use_aura%': '<(use_aura)',
'use_ash%': '<(use_ash)',
+ 'use_messagepump_linux%': '<(use_messagepump_linux)',
'use_openssl%': '<(use_openssl)',
'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',
@@ -171,6 +178,7 @@
'toolkit_uses_gtk%': '<(toolkit_uses_gtk)',
'use_aura%': '<(use_aura)',
'use_ash%': '<(use_ash)',
+ 'use_messagepump_linux%': '<(use_messagepump_linux)',
'use_openssl%': '<(use_openssl)',
'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',
@@ -423,13 +431,18 @@
'use_nss%': 0,
}],
- # Flags to use X11 on non-Mac POSIX platforms
+ # Flags to use X11 on non-Mac POSIX platforms.
+ ['OS=="win" or OS=="mac" or OS=="ios" or OS=="android" or use_messagepump_linux==1', {
+ 'use_x11%': 0,
+ }, {
+ 'use_x11%': 1,
+ }],
+
+ # Flags to use glib on non-Mac POSIX platforms.
['OS=="win" or OS=="mac" or OS=="ios" or OS=="android"', {
'use_glib%': 0,
- 'use_x11%': 0,
}, {
'use_glib%': 1,
- 'use_x11%': 1,
}],
# We always use skia text rendering in Aura on Windows, since GDI
@@ -675,6 +688,7 @@
'os_bsd%': '<(os_bsd)',
'os_posix%': '<(os_posix)',
'use_glib%': '<(use_glib)',
+ 'use_messagepump_linux%': '<(use_messagepump_linux)',
'toolkit_uses_gtk%': '<(toolkit_uses_gtk)',
'use_x11%': '<(use_x11)',
'use_gnome_keyring%': '<(use_gnome_keyring)',
@@ -1747,6 +1761,9 @@
['use_ash==1', {
'defines': ['USE_ASH=1'],
}],
+ ['use_messagepump_linux==1', {
+ 'defines': ['USE_MESSAGEPUMP_LINUX=1'],
+ }],
['use_default_render_theme==1', {
'defines': ['USE_DEFAULT_RENDER_THEME=1'],
}],
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
index 9f36f49..86dbf57 100644
--- a/ui/aura/env.cc
+++ b/ui/aura/env.cc
@@ -82,7 +82,7 @@ void Env::RootWindowActivated(RootWindow* root_window) {
// Env, private:
void Env::Init() {
-#if !defined(USE_X11)
+#if !defined(USE_X11) && !defined(USE_MESSAGEPUMP_LINUX)
dispatcher_.reset(CreateDispatcher());
#endif
#if defined(USE_X11)