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

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

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/keyboard_event_counter.h ('k') | media/base/keyboard_event_counter_unittest.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 #include "media/base/keyboard_event_counter.h" 5 #include "media/base/keyboard_event_counter.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 KeyboardEventCounter::KeyboardEventCounter() : total_key_presses_(0) {} 12 KeyboardEventCounter::KeyboardEventCounter() : total_key_presses_(0) {}
13 13
14 KeyboardEventCounter::~KeyboardEventCounter() {} 14 KeyboardEventCounter::~KeyboardEventCounter() {}
15 15
16 void KeyboardEventCounter::Reset() {
17 pressed_keys_.clear();
18 base::subtle::NoBarrier_Store(
19 reinterpret_cast<base::subtle::AtomicWord*>(&total_key_presses_), 0);
20 }
21
22 void KeyboardEventCounter::OnKeyboardEvent(ui::EventType event, 16 void KeyboardEventCounter::OnKeyboardEvent(ui::EventType event,
23 ui::KeyboardCode key_code) { 17 ui::KeyboardCode key_code) {
24 // Updates the pressed keys and the total count of key presses. 18 // Updates the pressed keys and the total count of key presses.
25 if (event == ui::ET_KEY_PRESSED) { 19 if (event == ui::ET_KEY_PRESSED) {
26 if (pressed_keys_.find(key_code) != pressed_keys_.end()) 20 if (pressed_keys_.find(key_code) != pressed_keys_.end())
27 return; 21 return;
28 pressed_keys_.insert(key_code); 22 pressed_keys_.insert(key_code);
29 base::subtle::NoBarrier_AtomicIncrement( 23 base::subtle::NoBarrier_AtomicIncrement(
30 reinterpret_cast<base::subtle::AtomicWord*>(&total_key_presses_), 1); 24 reinterpret_cast<base::subtle::AtomicWord*>(&total_key_presses_), 1);
31 } else { 25 } else {
32 DCHECK_EQ(ui::ET_KEY_RELEASED, event); 26 DCHECK_EQ(ui::ET_KEY_RELEASED, event);
33 pressed_keys_.erase(key_code); 27 pressed_keys_.erase(key_code);
34 } 28 }
35 } 29 }
36 30
37 size_t KeyboardEventCounter::GetKeyPressCount() const { 31 size_t KeyboardEventCounter::GetKeyPressCount() const {
38 return base::subtle::NoBarrier_Load( 32 return base::subtle::NoBarrier_Load(
39 reinterpret_cast<const base::subtle::AtomicWord*>(&total_key_presses_)); 33 reinterpret_cast<const base::subtle::AtomicWord*>(&total_key_presses_));
40 } 34 }
41 35
42 } // namespace media 36 } // namespace media
OLDNEW
« no previous file with comments | « media/base/keyboard_event_counter.h ('k') | media/base/keyboard_event_counter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698