Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / events / ozone / evdev / touch_noise / touch_noise_finder.h
blob9c2fbd18bb60ef9e10c36c6fac26857e053b8dc8
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.
5 #ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_NOISE_TOUCH_NOISE_FINDER_H_
6 #define UI_EVENTS_OZONE_EVDEV_TOUCH_NOISE_TOUCH_NOISE_FINDER_H_
8 #include <bitset>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/time/time.h"
13 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
14 #include "ui/events/ozone/evdev/touch_evdev_types.h"
16 namespace ui {
17 class TouchNoiseFilter;
19 // Finds touches which are likely touch noise.
20 class EVENTS_OZONE_EVDEV_EXPORT TouchNoiseFinder {
21 public:
22 TouchNoiseFinder();
23 ~TouchNoiseFinder();
25 // Updates which ABS_MT_SLOTs are noise. |touches| should contain all of the
26 // in-progress touches at |time| (including noisy touches).
27 // |touches| should have at most one entry per ABS_MT_SLOT.
28 void HandleTouches(const std::vector<InProgressTouchEvdev>& touches,
29 base::TimeDelta time);
31 // Returns whether the in-progress touch at ABS_MT_SLOT |slot| is noise.
32 bool SlotHasNoise(size_t slot) const;
34 private:
35 // Records how frequently noisy touches occur to UMA.
36 void RecordUMA(bool had_noise, base::TimeDelta time);
38 friend class TouchEventConverterEvdevTouchNoiseTest;
40 // The slots which are noise.
41 std::bitset<kNumTouchEvdevSlots> slots_with_noise_;
43 // The time of the previous noise occurence in any of the slots.
44 base::TimeDelta last_noise_time_;
46 std::vector<TouchNoiseFilter*> filters_;
48 DISALLOW_COPY_AND_ASSIGN(TouchNoiseFinder);
51 } // namespace ui
53 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_NOISE_TOUCH_NOISE_FINDER_H_