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

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

Issue 2577573002: Removes mouse listeners from UserInputMonitor. (Closed)
Patch Set: Fix win by removing std::move. Created 3 years, 11 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 | « media/base/BUILD.gn ('k') | media/base/keyboard_event_counter.cc » ('j') | no next file with comments »
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_KEYBOARD_EVENT_COUNTER_H_ 5 #ifndef MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_
6 #define MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_ 6 #define MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <set> 10 #include <set>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
15 #include "ui/events/event_constants.h" 15 #include "ui/events/event_constants.h"
16 #include "ui/events/keycodes/keyboard_codes.h" 16 #include "ui/events/keycodes/keyboard_codes.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 // This class tracks the total number of keypresses based on the OnKeyboardEvent 20 // This class tracks the total number of keypresses based on the OnKeyboardEvent
21 // calls it receives from the client. 21 // calls it receives from the client.
22 // Multiple key down events for the same key are counted as one keypress until 22 // Multiple key down events for the same key are counted as one keypress until
23 // the same key is released. 23 // the same key is released.
24 class MEDIA_EXPORT KeyboardEventCounter { 24 class MEDIA_EXPORT KeyboardEventCounter {
25 public: 25 public:
26 KeyboardEventCounter(); 26 KeyboardEventCounter();
27 ~KeyboardEventCounter(); 27 ~KeyboardEventCounter();
28 28
29 // Resets the count to 0. Must be called on the same thread as
30 // OnKeyboardEvent.
31 void Reset();
32
33 // Returns the total number of keypresses since its creation or last Reset() 29 // Returns the total number of keypresses since its creation or last Reset()
34 // call. Can be called on any thread. 30 // call. Can be called on any thread.
35 size_t GetKeyPressCount() const; 31 size_t GetKeyPressCount() const;
36 32
37 // The client should call this method on key down or key up events. 33 // The client should call this method on key down or key up events.
38 // Must be called on a single thread. 34 // Must be called on a single thread.
39 void OnKeyboardEvent(ui::EventType event, ui::KeyboardCode key_code); 35 void OnKeyboardEvent(ui::EventType event, ui::KeyboardCode key_code);
40 36
41 private: 37 private:
42 // The set of keys currently held down. 38 // The set of keys currently held down.
43 std::set<ui::KeyboardCode> pressed_keys_; 39 std::set<ui::KeyboardCode> pressed_keys_;
44 40
45 size_t total_key_presses_; 41 size_t total_key_presses_;
46 42
47 DISALLOW_COPY_AND_ASSIGN(KeyboardEventCounter); 43 DISALLOW_COPY_AND_ASSIGN(KeyboardEventCounter);
48 }; 44 };
49 45
50 } // namespace media 46 } // namespace media
51 47
52 #endif // MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_ 48 #endif // MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_
OLDNEW
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/keyboard_event_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698