Index: media/base/user_input_monitor.h |
diff --git a/media/base/user_input_monitor.h b/media/base/user_input_monitor.h |
index 9eb82f334f833612a0720367c83c4513ba275bef..cb2e5653350889585b57be8cacab1d7d4a668699 100644 |
--- a/media/base/user_input_monitor.h |
+++ b/media/base/user_input_monitor.h |
@@ -5,16 +5,10 @@ |
#ifndef MEDIA_BASE_USER_INPUT_MONITOR_H_ |
#define MEDIA_BASE_USER_INPUT_MONITOR_H_ |
-#include <set> |
- |
-#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
-#include "base/memory/weak_ptr.h" |
#include "base/observer_list.h" |
#include "base/synchronization/lock.h" |
#include "media/base/media_export.h" |
-#include "ui/base/events/event_constants.h" |
-#include "ui/base/keycodes/keyboard_codes.h" |
struct SkIPoint; |
@@ -28,6 +22,8 @@ namespace media { |
// 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 deleted object. |
Mark Mentovai
2013/08/23 20:18:11
access a deleted object.
jiayl
2013/08/23 23:47:58
Done.
|
class MEDIA_EXPORT UserInputMonitor { |
public: |
// The interface to receive mouse movement events. |
@@ -39,17 +35,6 @@ class MEDIA_EXPORT UserInputMonitor { |
protected: |
virtual ~MouseEventListener() {} |
}; |
- // The interface to receive key stroke events. |
- class MEDIA_EXPORT KeyStrokeListener { |
- public: |
- // Called when any key is pressed. Called only once until the key is |
- // released, i.e. holding down a key for a long period will generate one |
- // callback just when the key is pressed down. |
- virtual void OnKeyStroke() = 0; |
- |
- protected: |
- virtual ~KeyStrokeListener() {} |
- }; |
virtual ~UserInputMonitor(); |
@@ -65,8 +50,16 @@ class MEDIA_EXPORT UserInputMonitor { |
// destroyed. |
void AddMouseListener(MouseEventListener* listener); |
void RemoveMouseListener(MouseEventListener* listener); |
- void AddKeyStrokeListener(KeyStrokeListener* listener); |
- void RemoveKeyStrokeListener(KeyStrokeListener* listener); |
+ |
+ // A caller must call EnableKeyPressMonitoring before calling |
+ // GetKeyPressCount(), and call DisableKeyPressMonitoring when it no |
+ // longer needs it. |
+ void EnableKeyPressMonitoring(); |
+ void DisableKeyPressMonitoring(); |
+ |
+ // Returns the number of Keypresses since EnableKeyPressMonitoring is called |
+ // for the first time. |
Mark Mentovai
2013/08/23 20:18:11
This comment is still confusing, because Enable-Di
jiayl
2013/08/23 23:47:58
Done.
|
+ virtual size_t GetKeyPressCount() const = 0; |
protected: |
UserInputMonitor(); |
@@ -74,7 +67,6 @@ class MEDIA_EXPORT UserInputMonitor { |
// Called by the platform-specific sub-classes to propagate the events to the |
// listeners. |
void OnMouseEvent(const SkIPoint& position); |
- void OnKeyboardEvent(ui::EventType event, ui::KeyboardCode key_code); |
private: |
virtual void StartMouseMonitoring() = 0; |
@@ -84,12 +76,8 @@ class MEDIA_EXPORT UserInputMonitor { |
base::Lock lock_; |
ObserverList<MouseEventListener, true> mouse_listeners_; |
- ObserverList<KeyStrokeListener, true> key_stroke_listeners_; |
bool monitoring_mouse_; |
- bool monitoring_keyboard_; |
- // The set of keys currently held down. Used for convering raw keyboard events |
- // into KeyStrokeListener callbacks. |
- std::set<ui::KeyboardCode> pressed_keys_; |
+ size_t key_press_counter_references_; |
DISALLOW_COPY_AND_ASSIGN(UserInputMonitor); |
}; |