- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / device_uma.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_UMA_H_
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_UMA_H_
7
8 #include "base/basictypes.h"
9 #include "base/event_types.h"
10 #include "base/message_loop/message_loop.h"
11
12 template <typename T> struct DefaultSingletonTraits;
13
14 namespace chromeos {
15
16 // A class to record devices' input event details via the UMA system
17 class DeviceUMA : public base::MessageLoopForUI::Observer {
18  public:
19   // Getting instance starts the class automatically if it hasn't been
20   // started before.
21   static DeviceUMA* GetInstance();
22
23   void Stop();
24
25  private:
26   friend struct DefaultSingletonTraits<DeviceUMA>;
27
28   DeviceUMA();
29   virtual ~DeviceUMA();
30
31   // Start and stop observing events.
32   void AddMessageLoopObserver();
33   void RemoveMessageLoopObserver();
34
35   // MessageLoopForUI::Observer overrides.
36   virtual base::EventStatus WillProcessEvent(
37       const base::NativeEvent& event) OVERRIDE;
38   virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
39
40   // Check CrOS touchpad events to see if the metrics gesture is present
41   void CheckTouchpadEvent(const base::NativeEvent& event);
42
43   // Check the incoming events for interesting patterns that we care about.
44   void CheckIncomingEvent(const base::NativeEvent& event);
45
46   bool is_observing_;
47
48   DISALLOW_COPY_AND_ASSIGN(DeviceUMA);
49 };
50
51 }  // namespace chromeos
52
53 #endif  // CHROME_BROWSER_CHROMEOS_DEVICE_UMA_H_