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

Side by Side Diff: chromeos/accelerometer/accelerometer_reader.h

Issue 571283006: Revert of Use chromeos accelerometer reader and support only lid accelerometer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ 5 #ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ 6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
7 7
8 #include <vector>
9
8 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
10 #include "base/observer_list.h" 12 #include "base/observer_list.h"
11 #include "chromeos/chromeos_export.h" 13 #include "chromeos/chromeos_export.h"
12 #include "ui/accelerometer/accelerometer_types.h" 14 #include "ui/accelerometer/accelerometer_types.h"
13 15
14 namespace base { 16 namespace base {
15 class TaskRunner; 17 class TaskRunner;
16 } 18 }
17 19
18 namespace chromeos { 20 namespace chromeos {
19 21
20 // Reads an accelerometer device and reports data back to an 22 // Reads an accelerometer device and reports data back to an
21 // AccelerometerDelegate. 23 // AccelerometerDelegate.
22 class CHROMEOS_EXPORT AccelerometerReader { 24 class CHROMEOS_EXPORT AccelerometerReader {
23 public: 25 public:
24 // Configuration structure for accelerometer device. 26 // Configuration structure for accelerometer device.
25 struct ConfigurationData { 27 struct ConfigurationData {
26 ConfigurationData(); 28 ConfigurationData();
27 ~ConfigurationData(); 29 ~ConfigurationData();
28 30
29 // Number of accelerometers on device. 31 // Scale of accelerometers (i.e. raw value * 1.0f / scale = G's).
30 size_t count; 32 unsigned int base_scale;
31 33 unsigned int lid_scale;
32 // Length of accelerometer updates.
33 size_t length;
34
35 // Which accelerometers are present on device.
36 bool has[ui::ACCELEROMETER_SOURCE_COUNT];
37
38 // Scale of accelerometers (i.e. raw value * scale = m/s^2).
39 float scale[ui::ACCELEROMETER_SOURCE_COUNT][3];
40 34
41 // Index of each accelerometer axis in data stream. 35 // Index of each accelerometer axis in data stream.
42 int index[ui::ACCELEROMETER_SOURCE_COUNT][3]; 36 std::vector<unsigned int> index;
43 }; 37 };
44 typedef base::RefCountedData<ConfigurationData> Configuration; 38 typedef base::RefCountedData<ConfigurationData> Configuration;
45 typedef base::RefCountedData<char[12]> Reading; 39 typedef base::RefCountedData<char[12]> Reading;
46 40
47 // An interface to receive data from the AccelerometerReader. 41 // An interface to receive data from the AccelerometerReader.
48 class Delegate { 42 class Delegate {
49 public: 43 public:
50 virtual void HandleAccelerometerUpdate( 44 virtual void HandleAccelerometerUpdate(
51 const ui::AccelerometerUpdate& update) = 0; 45 const ui::AccelerometerUpdate& update) = 0;
52 }; 46 };
(...skipping 29 matching lines...) Expand all
82 scoped_refptr<Configuration> configuration_; 76 scoped_refptr<Configuration> configuration_;
83 77
84 base::WeakPtrFactory<AccelerometerReader> weak_factory_; 78 base::WeakPtrFactory<AccelerometerReader> weak_factory_;
85 79
86 DISALLOW_COPY_AND_ASSIGN(AccelerometerReader); 80 DISALLOW_COPY_AND_ASSIGN(AccelerometerReader);
87 }; 81 };
88 82
89 } // namespace chromeos 83 } // namespace chromeos
90 84
91 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ 85 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698