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

Unified Diff: media/base/user_input_monitor.h

Issue 23702008: Adds the UserInputMonitor implementation for Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months 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 | « media/base/keyboard_event_counter.h ('k') | media/base/user_input_monitor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/user_input_monitor.h
diff --git a/media/base/user_input_monitor.h b/media/base/user_input_monitor.h
index 567907c76f8fc2cbad0554e060fff22a13c6dcf9..ab572694ed3351d3e1f648718640d4d76bab03b0 100644
--- a/media/base/user_input_monitor.h
+++ b/media/base/user_input_monitor.h
@@ -5,8 +5,9 @@
#ifndef MEDIA_BASE_USER_INPUT_MONITOR_H_
#define MEDIA_BASE_USER_INPUT_MONITOR_H_
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/observer_list.h"
+#include "base/observer_list_threadsafe.h"
#include "base/synchronization/lock.h"
#include "media/base/media_export.h"
@@ -19,11 +20,8 @@ class SingleThreadTaskRunner;
namespace media {
// Monitors and notifies about mouse movements and keyboard events.
-// Thread safe. The thread on which the listenters are called is not guaranteed.
-// The callers should not perform expensive/blocking tasks in the callback since
-// it might be called on the browser UI/IO threads.
-// The object must outlive the browser UI/IO threads to make sure the callbacks
-// will not access a deleted object.
+// Thread safe. The listeners are called on the thread where the listeners are
+// added.
class MEDIA_EXPORT UserInputMonitor {
public:
// The interface to receive mouse movement events.
@@ -35,6 +33,8 @@ class MEDIA_EXPORT UserInputMonitor {
protected:
virtual ~MouseEventListener() {}
};
+ typedef ObserverListThreadSafe<UserInputMonitor::MouseEventListener>
+ MouseListenerList;
UserInputMonitor();
virtual ~UserInputMonitor();
@@ -66,20 +66,20 @@ class MEDIA_EXPORT UserInputMonitor {
virtual size_t GetKeyPressCount() const = 0;
protected:
- // Called by the platform-specific sub-classes to propagate the events to the
- // listeners.
- void OnMouseEvent(const SkIPoint& position);
+ scoped_refptr<MouseListenerList> mouse_listeners() {
+ return mouse_listeners_;
+ }
private:
- virtual void StartMouseMonitoring() = 0;
- virtual void StopMouseMonitoring() = 0;
virtual void StartKeyboardMonitoring() = 0;
virtual void StopKeyboardMonitoring() = 0;
+ virtual void StartMouseMonitoring() = 0;
+ virtual void StopMouseMonitoring() = 0;
base::Lock lock_;
- ObserverList<MouseEventListener, true> mouse_listeners_;
- bool monitoring_mouse_;
size_t key_press_counter_references_;
+ size_t mouse_listeners_count_;
+ scoped_refptr<MouseListenerList> mouse_listeners_;
DISALLOW_COPY_AND_ASSIGN(UserInputMonitor);
};
« no previous file with comments | « media/base/keyboard_event_counter.h ('k') | media/base/user_input_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698