OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" | 5 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
10 #include "ui/events/ozone/evdev/touch_noise/far_apart_taps_touch_noise_filter.h" | 10 #include "ui/events/ozone/evdev/touch_noise/far_apart_taps_touch_noise_filter.h" |
11 #include "ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_fil
ter.h" | 11 #include "ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_fil
ter.h" |
12 #include "ui/events/ozone/evdev/touch_noise/single_position_touch_noise_filter.h
" | 12 #include "ui/events/ozone/evdev/touch_noise/single_position_touch_noise_filter.h
" |
13 #include "ui/events/ozone/evdev/touch_noise/touch_noise_filter.h" | 13 #include "ui/events/ozone/evdev/touch_noise/touch_noise_filter.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 TouchNoiseFinder::TouchNoiseFinder() : last_noise_time_(ui::EventTimeForNow()) { | 17 TouchNoiseFinder::TouchNoiseFinder() : last_noise_time_(ui::EventTimeForNow()) { |
18 filters_.push_back(new FarApartTapsTouchNoiseFilter); | 18 filters_.push_back(new FarApartTapsTouchNoiseFilter); |
19 filters_.push_back(new HorizontallyAlignedTouchNoiseFilter); | 19 filters_.push_back(new HorizontallyAlignedTouchNoiseFilter); |
20 filters_.push_back(new SinglePositionTouchNoiseFilter); | 20 filters_.push_back(new SinglePositionTouchNoiseFilter); |
21 } | 21 } |
22 | 22 |
23 TouchNoiseFinder::~TouchNoiseFinder() { | 23 TouchNoiseFinder::~TouchNoiseFinder() { |
24 STLDeleteElements(&filters_); | 24 STLDeleteElements(&filters_); |
25 } | 25 } |
26 | 26 |
27 void TouchNoiseFinder::HandleTouches( | 27 void TouchNoiseFinder::HandleTouches( |
28 const std::vector<InProgressTouchEvdev>& touches, | 28 const std::vector<InProgressTouchEvdev>& touches, |
29 base::TimeDelta time) { | 29 base::TimeTicks time) { |
30 for (const InProgressTouchEvdev& touch : touches) { | 30 for (const InProgressTouchEvdev& touch : touches) { |
31 if (!touch.was_touching) | 31 if (!touch.was_touching) |
32 slots_with_noise_.set(touch.slot, false); | 32 slots_with_noise_.set(touch.slot, false); |
33 } | 33 } |
34 | 34 |
35 bool had_noise = slots_with_noise_.any(); | 35 bool had_noise = slots_with_noise_.any(); |
36 | 36 |
37 for (TouchNoiseFilter* filter : filters_) | 37 for (TouchNoiseFilter* filter : filters_) |
38 filter->Filter(touches, time, &slots_with_noise_); | 38 filter->Filter(touches, time, &slots_with_noise_); |
39 | 39 |
40 RecordUMA(had_noise, time); | 40 RecordUMA(had_noise, time); |
41 } | 41 } |
42 | 42 |
43 bool TouchNoiseFinder::SlotHasNoise(size_t slot) const { | 43 bool TouchNoiseFinder::SlotHasNoise(size_t slot) const { |
44 return slots_with_noise_.test(slot); | 44 return slots_with_noise_.test(slot); |
45 } | 45 } |
46 | 46 |
47 void TouchNoiseFinder::RecordUMA(bool had_noise, base::TimeDelta time) { | 47 void TouchNoiseFinder::RecordUMA(bool had_noise, base::TimeTicks time) { |
48 if (slots_with_noise_.any()) { | 48 if (slots_with_noise_.any()) { |
49 if (!had_noise) { | 49 if (!had_noise) { |
50 UMA_HISTOGRAM_LONG_TIMES( | 50 UMA_HISTOGRAM_LONG_TIMES( |
51 "Ozone.TouchNoiseFilter.TimeSinceLastNoiseOccurrence", | 51 "Ozone.TouchNoiseFilter.TimeSinceLastNoiseOccurrence", |
52 time - last_noise_time_); | 52 time - last_noise_time_); |
53 } | 53 } |
54 | 54 |
55 last_noise_time_ = time; | 55 last_noise_time_ = time; |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 } // namespace ui | 59 } // namespace ui |
OLD | NEW |