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

Side by Side Diff: ash/keyboard_uma_event_filter.cc

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
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 "ash/keyboard_uma_event_filter.h" 5 #include "ash/keyboard_uma_event_filter.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 9
10 namespace { 10 namespace {
(...skipping 12 matching lines...) Expand all
23 KeyboardUMAEventFilter::~KeyboardUMAEventFilter() {} 23 KeyboardUMAEventFilter::~KeyboardUMAEventFilter() {}
24 24
25 void KeyboardUMAEventFilter::OnKeyEvent(ui::KeyEvent* event) { 25 void KeyboardUMAEventFilter::OnKeyEvent(ui::KeyEvent* event) {
26 // This is a rough approximation, so assume that each key release is the 26 // This is a rough approximation, so assume that each key release is the
27 // result of a typed key. 27 // result of a typed key.
28 if (event->type() != ui::ET_KEY_RELEASED) 28 if (event->type() != ui::ET_KEY_RELEASED)
29 return; 29 return;
30 30
31 // Reset the timer on non-character keystrokes. 31 // Reset the timer on non-character keystrokes.
32 if (!isprint(event->GetCharacter())) { 32 if (!isprint(event->GetCharacter())) {
33 last_keystroke_time_ = base::TimeDelta(); 33 last_keystroke_time_ = base::TimeTicks();
34 return; 34 return;
35 } 35 }
36 36
37 if (last_keystroke_time_.ToInternalValue() == 0) { 37 if (last_keystroke_time_.ToInternalValue() == 0) {
38 last_keystroke_time_ = event->time_stamp(); 38 last_keystroke_time_ = event->time_stamp();
39 return; 39 return;
40 } 40 }
41 41
42 base::TimeDelta delta = event->time_stamp() - last_keystroke_time_; 42 base::TimeDelta delta = event->time_stamp() - last_keystroke_time_;
43 if (delta < base::TimeDelta::FromSeconds(kKeystrokeThresholdInSeconds)) 43 if (delta < base::TimeDelta::FromSeconds(kKeystrokeThresholdInSeconds))
44 UMA_HISTOGRAM_TIMES("Keyboard.KeystrokeDeltas", delta); 44 UMA_HISTOGRAM_TIMES("Keyboard.KeystrokeDeltas", delta);
45 45
46 last_keystroke_time_ = event->time_stamp(); 46 last_keystroke_time_ = event->time_stamp();
47 } 47 }
48 48
49 } // namespace ash 49 } // namespace ash
OLDNEW
« no previous file with comments | « ash/keyboard_uma_event_filter.h ('k') | ash/shelf/shelf_button_pressed_metric_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698