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"
14 struct DefaultSingletonTraits
;
17 class SequencedTaskRunner
;
22 class AccelerometerFileReader
;
24 // Reads an accelerometer device and reports data back to an
25 // AccelerometerDelegate.
26 class CHROMEOS_EXPORT AccelerometerReader
{
28 // The time to wait between reading the accelerometer.
29 static const int kDelayBetweenReadsMs
;
31 // An interface to receive data from the AccelerometerReader.
34 virtual void OnAccelerometerUpdated(
35 scoped_refptr
<const AccelerometerUpdate
> update
) = 0;
38 virtual ~Observer() {}
41 static AccelerometerReader
* GetInstance();
44 scoped_refptr
<base::SequencedTaskRunner
> sequenced_task_runner
);
46 // Add/Remove observers.
47 void AddObserver(Observer
* observer
);
48 void RemoveObserver(Observer
* observer
);
51 AccelerometerReader();
52 virtual ~AccelerometerReader();
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_