Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_ | |
| 6 #define MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include "base/synchronization/lock.h" | |
|
Mark Mentovai
2013/08/23 20:18:11
Blank line before this.
jiayl
2013/08/23 23:47:58
Done.
| |
| 10 #include "ui/base/events/event_constants.h" | |
| 11 #include "ui/base/keycodes/keyboard_codes.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 // This class tracks the total number key presses based on the OnKeyboardEvent | |
|
Mark Mentovai
2013/08/23 20:18:11
total number of keypresses
jiayl
2013/08/23 23:47:58
Done.
| |
| 16 // calls it receives from the client. | |
| 17 // Multiple key down events for the same key is counted as one keypress until | |
|
Mark Mentovai
2013/08/23 20:18:11
is → are
jiayl
2013/08/23 23:47:58
Done.
| |
| 18 // the same key is released. | |
| 19 // Thread safe. | |
| 20 class KeyboardEventCounter { | |
| 21 public: | |
| 22 KeyboardEventCounter(); | |
| 23 ~KeyboardEventCounter(); | |
| 24 | |
| 25 // Resets the count to 0. | |
| 26 void Reset(); | |
| 27 // Returns the total number of keypresses since its creation or last Reset() | |
|
Mark Mentovai
2013/08/23 20:18:11
Put blank lines before the comments that introduce
jiayl
2013/08/23 23:47:58
Done.
| |
| 28 // call. | |
| 29 size_t GetKeyPressCount() const; | |
| 30 // The client should call this method on key down or key up events. | |
| 31 void OnKeyboardEvent(ui::EventType event, ui::KeyboardCode key_code); | |
| 32 | |
| 33 private: | |
| 34 // "mutable" for GetKeyPressCount(). | |
| 35 mutable base::Lock lock_; | |
| 36 // The set of keys currently held down. | |
| 37 std::set<int> pressed_keys_; | |
|
Mark Mentovai
2013/08/23 20:18:11
ui::KeyboardCode, not int?
jiayl
2013/08/23 23:47:58
Done.
| |
| 38 size_t total_key_presses_; | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(KeyboardEventCounter); | |
| 41 }; | |
| 42 | |
| 43 } // namespace media | |
| 44 | |
| 45 #endif // MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_ | |
| OLD | NEW |