Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / accelerometer / accelerometer_reader.h
blob8ec4ec85f7893ecef02a82c1d38b1ef811c0c7b9
1 // Copyright 2014 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 CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/observer_list_threadsafe.h"
10 #include "chromeos/accelerometer/accelerometer_types.h"
11 #include "chromeos/chromeos_export.h"
13 template <typename T>
14 struct DefaultSingletonTraits;
16 namespace base {
17 class SequencedTaskRunner;
20 namespace chromeos {
22 class AccelerometerFileReader;
24 // Reads an accelerometer device and reports data back to an
25 // AccelerometerDelegate.
26 class CHROMEOS_EXPORT AccelerometerReader {
27 public:
28 // The time to wait between reading the accelerometer.
29 static const int kDelayBetweenReadsMs;
31 // An interface to receive data from the AccelerometerReader.
32 class Observer {
33 public:
34 virtual void OnAccelerometerUpdated(
35 scoped_refptr<const AccelerometerUpdate> update) = 0;
37 protected:
38 virtual ~Observer() {}
41 static AccelerometerReader* GetInstance();
43 void Initialize(
44 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner);
46 // Add/Remove observers.
47 void AddObserver(Observer* observer);
48 void RemoveObserver(Observer* observer);
50 protected:
51 AccelerometerReader();
52 virtual ~AccelerometerReader();
54 private:
55 friend struct DefaultSingletonTraits<AccelerometerReader>;
57 // Worker that will run on the base::SequencedTaskRunner provided to
58 // Initialize. It will determine accelerometer configuration, read the data,
59 // and notify observers.
60 scoped_refptr<AccelerometerFileReader> accelerometer_file_reader_;
62 DISALLOW_COPY_AND_ASSIGN(AccelerometerReader);
65 } // namespace chromeos
67 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_