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

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

Issue 2474163003: Remove stl_util's deletion function use from ui/. (Closed)
Patch Set: braces Created 4 years, 1 month 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 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/memory/ptr_util.h"
7 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.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(base::MakeUnique<FarApartTapsTouchNoiseFilter>());
19 filters_.push_back(new HorizontallyAlignedTouchNoiseFilter); 19 filters_.push_back(base::MakeUnique<HorizontallyAlignedTouchNoiseFilter>());
20 filters_.push_back(new SinglePositionTouchNoiseFilter); 20 filters_.push_back(base::MakeUnique<SinglePositionTouchNoiseFilter>());
21 } 21 }
22 22
23 TouchNoiseFinder::~TouchNoiseFinder() { 23 TouchNoiseFinder::~TouchNoiseFinder() {
24 base::STLDeleteElements(&filters_);
25 } 24 }
26 25
27 void TouchNoiseFinder::HandleTouches( 26 void TouchNoiseFinder::HandleTouches(
28 const std::vector<InProgressTouchEvdev>& touches, 27 const std::vector<InProgressTouchEvdev>& touches,
29 base::TimeTicks time) { 28 base::TimeTicks time) {
30 for (const InProgressTouchEvdev& touch : touches) { 29 for (const InProgressTouchEvdev& touch : touches) {
31 if (!touch.was_touching) 30 if (!touch.was_touching)
32 slots_with_noise_.set(touch.slot, false); 31 slots_with_noise_.set(touch.slot, false);
33 } 32 }
34 33
35 bool had_noise = slots_with_noise_.any(); 34 bool had_noise = slots_with_noise_.any();
36 35
37 for (TouchNoiseFilter* filter : filters_) 36 for (const auto& filter : filters_)
38 filter->Filter(touches, time, &slots_with_noise_); 37 filter->Filter(touches, time, &slots_with_noise_);
39 38
40 RecordUMA(had_noise, time); 39 RecordUMA(had_noise, time);
41 } 40 }
42 41
43 bool TouchNoiseFinder::SlotHasNoise(size_t slot) const { 42 bool TouchNoiseFinder::SlotHasNoise(size_t slot) const {
44 return slots_with_noise_.test(slot); 43 return slots_with_noise_.test(slot);
45 } 44 }
46 45
47 void TouchNoiseFinder::RecordUMA(bool had_noise, base::TimeTicks time) { 46 void TouchNoiseFinder::RecordUMA(bool had_noise, base::TimeTicks time) {
48 if (slots_with_noise_.any()) { 47 if (slots_with_noise_.any()) {
49 if (!had_noise) { 48 if (!had_noise) {
50 UMA_HISTOGRAM_LONG_TIMES( 49 UMA_HISTOGRAM_LONG_TIMES(
51 "Ozone.TouchNoiseFilter.TimeSinceLastNoiseOccurrence", 50 "Ozone.TouchNoiseFilter.TimeSinceLastNoiseOccurrence",
52 time - last_noise_time_); 51 time - last_noise_time_);
53 } 52 }
54 53
55 last_noise_time_ = time; 54 last_noise_time_ = time;
56 } 55 }
57 } 56 }
58 57
59 } // namespace ui 58 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_noise/touch_noise_finder.h ('k') | ui/wm/core/transient_window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698