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

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

Issue 22801007: Adds the UserInputMonitor implementation for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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/keyboard_event_counter.h ('k') | media/base/user_input_monitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "media/base/keyboard_event_counter.h"
6
7 #include "base/atomicops.h"
8 #include "base/logging.h"
9
10 namespace media {
11
12 KeyboardEventCounter::KeyboardEventCounter() : total_key_presses_(0) {}
13
14 KeyboardEventCounter::~KeyboardEventCounter() {}
15
16 void KeyboardEventCounter::Reset() {
17 pressed_keys_.clear();
18 total_key_presses_ = 0;
19 }
20
21 void KeyboardEventCounter::OnKeyboardEvent(ui::EventType event,
22 ui::KeyboardCode key_code) {
23 // Updates the pressed keys and the total count of key presses.
24 if (event == ui::ET_KEY_PRESSED) {
25 if (pressed_keys_.find(key_code) != pressed_keys_.end())
26 return;
27 pressed_keys_.insert(key_code);
28 base::subtle::NoBarrier_AtomicIncrement(
29 reinterpret_cast<base::subtle::AtomicWord*>(&total_key_presses_), 1);
30 } else {
31 DCHECK_EQ(ui::ET_KEY_RELEASED, event);
32 pressed_keys_.erase(key_code);
33 }
34 }
35
36 size_t KeyboardEventCounter::GetKeyPressCount() const {
37 return base::subtle::NoBarrier_Load(
38 reinterpret_cast<const base::subtle::AtomicWord*>(&total_key_presses_));
39 }
40
41 } // namespace media
OLDNEW
« no previous file with comments | « media/base/keyboard_event_counter.h ('k') | media/base/user_input_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698