| OLD | NEW |
| 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> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // Resets the count to 0. Must be called on the same thread as | 29 // Resets the count to 0. Must be called on the same thread as |
| 30 // OnKeyboardEvent. | 30 // OnKeyboardEvent. |
| 31 void Reset(); | 31 void Reset(); |
| 32 | 32 |
| 33 // Returns the total number of keypresses since its creation or last Reset() | 33 // Returns the total number of keypresses since its creation or last Reset() |
| 34 // call. Can be called on any thread. | 34 // call. Can be called on any thread. |
| 35 size_t GetKeyPressCount() const; | 35 size_t GetKeyPressCount() const; |
| 36 | 36 |
| 37 // The client should call this method on key down or key up events. | 37 // The client should call this method on key down or key up events. |
| 38 // Must be called on a single thread. | 38 // Must be called on a single thread. |
| 39 void OnKeyboardEvent(ui::EventType event, ui::KeyboardCode key_code); | 39 void OnKeyboardEvent(bool down, ui::KeyboardCode key_code); |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // The set of keys currently held down. | 42 // The set of keys currently held down. |
| 43 std::set<ui::KeyboardCode> pressed_keys_; | 43 std::set<ui::KeyboardCode> pressed_keys_; |
| 44 | 44 |
| 45 size_t total_key_presses_; | 45 size_t total_key_presses_; |
| 46 | 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(KeyboardEventCounter); | 47 DISALLOW_COPY_AND_ASSIGN(KeyboardEventCounter); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace media | 50 } // namespace media |
| 51 | 51 |
| 52 #endif // MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_ | 52 #endif // MEDIA_BASE_KEYBOARD_EVENT_COUNTER_H_ |
| OLD | NEW |