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

Side by Side Diff: media/base/user_input_monitor.h

Issue 22801007: Adds the UserInputMonitor implementation for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/base/user_input_monitor.cc » ('j') | media/base/user_input_monitor_mac.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef MEDIA_BASE_USER_INPUT_MONITOR_H_ 5 #ifndef MEDIA_BASE_USER_INPUT_MONITOR_H_
6 #define MEDIA_BASE_USER_INPUT_MONITOR_H_ 6 #define MEDIA_BASE_USER_INPUT_MONITOR_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 12 #include "base/observer_list.h"
14 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
15 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
16 #include "ui/base/events/event_constants.h" 15 #include "ui/base/events/event_constants.h"
17 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
18 17
19 struct SkIPoint; 18 struct SkIPoint;
20 19
21 namespace base { 20 namespace base {
22 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
23 } // namespace base 22 } // namespace base
24 23
25 namespace media { 24 namespace media {
26 25
27 // Monitors and notifies about mouse movements and keyboard events. 26 // Monitors and notifies about mouse movements and keyboard events.
28 // Thread safe. The thread on which the listenters are called is not guaranteed. 27 // Thread safe. The thread on which the listenters are called is not guaranteed.
29 // The callers should not perform expensive/blocking tasks in the callback since 28 // The callers should not perform expensive/blocking tasks in the callback since
30 // it might be called on the browser UI/IO threads. 29 // it might be called on the browser UI/IO threads.
30 // The object must outlive the browser UI/IO threads to make sure the callbacks
31 // will not access deleted object.
31 class MEDIA_EXPORT UserInputMonitor { 32 class MEDIA_EXPORT UserInputMonitor {
32 public: 33 public:
33 // The interface to receive mouse movement events. 34 // The interface to receive mouse movement events.
34 class MEDIA_EXPORT MouseEventListener { 35 class MEDIA_EXPORT MouseEventListener {
35 public: 36 public:
36 // |position| is the new mouse position. 37 // |position| is the new mouse position.
37 virtual void OnMouseMoved(const SkIPoint& position) = 0; 38 virtual void OnMouseMoved(const SkIPoint& position) = 0;
38 39
39 protected: 40 protected:
40 virtual ~MouseEventListener() {} 41 virtual ~MouseEventListener() {}
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 virtual void StartKeyboardMonitoring() = 0; 83 virtual void StartKeyboardMonitoring() = 0;
83 virtual void StopKeyboardMonitoring() = 0; 84 virtual void StopKeyboardMonitoring() = 0;
84 85
85 base::Lock lock_; 86 base::Lock lock_;
86 ObserverList<MouseEventListener, true> mouse_listeners_; 87 ObserverList<MouseEventListener, true> mouse_listeners_;
87 ObserverList<KeyStrokeListener, true> key_stroke_listeners_; 88 ObserverList<KeyStrokeListener, true> key_stroke_listeners_;
88 bool monitoring_mouse_; 89 bool monitoring_mouse_;
89 bool monitoring_keyboard_; 90 bool monitoring_keyboard_;
90 // The set of keys currently held down. Used for convering raw keyboard events 91 // The set of keys currently held down. Used for convering raw keyboard events
91 // into KeyStrokeListener callbacks. 92 // into KeyStrokeListener callbacks.
92 std::set<ui::KeyboardCode> pressed_keys_; 93 std::set<int> pressed_keys_;
93 94
94 DISALLOW_COPY_AND_ASSIGN(UserInputMonitor); 95 DISALLOW_COPY_AND_ASSIGN(UserInputMonitor);
95 }; 96 };
96 97
97 } // namespace media 98 } // namespace media
98 99
99 #endif // MEDIA_BASE_USER_INPUT_MONITOR_H_ 100 #endif // MEDIA_BASE_USER_INPUT_MONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/user_input_monitor.cc » ('j') | media/base/user_input_monitor_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698