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

Side by Side Diff: ui/events/ozone/evdev/touch_noise/touch_noise_finder.cc

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h"
6
7 #include "base/metrics/histogram_macros.h"
8 #include "base/stl_util.h"
9 #include "ui/events/event_utils.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"
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"
14
15 namespace ui {
16
17 TouchNoiseFinder::TouchNoiseFinder() : last_noise_time_(ui::EventTimeForNow()) {
18 filters_.push_back(new FarApartTapsTouchNoiseFilter);
19 filters_.push_back(new HorizontallyAlignedTouchNoiseFilter);
20 filters_.push_back(new SinglePositionTouchNoiseFilter);
21 }
22
23 TouchNoiseFinder::~TouchNoiseFinder() {
24 STLDeleteElements(&filters_);
25 }
26
27 void TouchNoiseFinder::HandleTouches(
28 const std::vector<InProgressTouchEvdev>& touches,
29 base::TimeDelta time) {
30 for (const InProgressTouchEvdev& touch : touches) {
31 if (!touch.was_touching)
32 slots_with_noise_.set(touch.slot, false);
33 }
34
35 bool had_noise = slots_with_noise_.any();
36
37 for (TouchNoiseFilter* filter : filters_)
38 filter->Filter(touches, time, &slots_with_noise_);
39
40 RecordUMA(had_noise, time);
41 }
42
43 bool TouchNoiseFinder::SlotHasNoise(size_t slot) const {
44 return slots_with_noise_.test(slot);
45 }
46
47 void TouchNoiseFinder::RecordUMA(bool had_noise, base::TimeDelta time) {
48 if (slots_with_noise_.any()) {
49 if (!had_noise) {
50 UMA_HISTOGRAM_LONG_TIMES(
51 "Ozone.TouchNoiseFilter.TimeSinceLastNoiseOccurrence",
52 time - last_noise_time_);
53 }
54
55 last_noise_time_ = time;
56 }
57 }
58
59 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698