Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ | |
| 6 #define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/synchronization/lock.h" | |
| 11 #include "content/common/content_export.h" | |
| 12 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" | |
| 13 #include "content/public/browser/sensor_manager_delegate_chromeos.h" | |
| 14 | |
| 15 template <typename T> | |
| 16 struct DefaultSingletonTraits; | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 class SensorManagerChromeOSTest; | |
|
timvolodine
2014/11/28 17:46:06
no need for this?
jonross
2014/12/02 16:13:36
Currently used for calling OnAccelerationIncluding
timvolodine
2014/12/03 13:19:55
I think you can drop this line, you already have a
| |
| 21 class SensorManagerDelegateChromeOS; | |
| 22 | |
| 23 // Notifies Chrome OS sensors to start and stop observing accelerometer sensors. | |
| 24 // Provides a callback, which interprets accelerometer data for | |
| 25 // Device Orientation events. | |
| 26 class CONTENT_EXPORT SensorManagerChromeOS | |
| 27 : public base::RefCountedThreadSafe<SensorManagerChromeOS> { | |
|
timvolodine
2014/11/26 19:32:19
are you sure about this? the class is a singleton
jonross
2014/11/26 23:17:56
This is based on the example from callback.h for b
timvolodine
2014/11/28 17:46:06
normally you can ensure the callback of a singleto
| |
| 28 public: | |
| 29 // Retrieves the singleton instance. | |
| 30 static SensorManagerChromeOS* GetInstance(); | |
|
timvolodine
2014/11/26 19:32:19
ideally we should get rid of this singleton as wel
jonross
2014/12/02 16:13:36
Done.
| |
| 31 | |
| 32 // Sets the delegate which observes accelerometer events. | |
| 33 void SetDelegate(SensorManagerDelegateChromeOS* delegate); | |
| 34 | |
| 35 // Begins monitoring of orientation events, the shared memory of |buffer| will | |
| 36 // be updated upon subsequent events. | |
| 37 bool StartFetchingDeviceOrientationData( | |
| 38 DeviceOrientationHardwareBuffer* buffer); | |
| 39 | |
| 40 // Stops monitoring orientation events. | |
| 41 void StopFetchingDeviceOrientationData(); | |
| 42 | |
| 43 protected: | |
| 44 virtual ~SensorManagerChromeOS(); | |
| 45 | |
| 46 private: | |
| 47 friend class base::RefCountedThreadSafe<SensorManagerChromeOS>; | |
| 48 friend class SensorManagerChromeOSTest; | |
| 49 friend struct DefaultSingletonTraits<SensorManagerChromeOS>; | |
| 50 | |
| 51 // Shared memory to to update. | |
| 52 DeviceOrientationHardwareBuffer* orientation_buffer_; | |
| 53 | |
| 54 // Synchronize orientation_buffer_ across threads. | |
| 55 base::Lock orientation_buffer_lock_; | |
| 56 | |
| 57 // Thread safe tracking of callback for Chrome OS sensors. | |
| 58 scoped_refptr<SensorManagerChromeOS> callback_ref_; | |
| 59 | |
| 60 // Platform delegate that receives actual accelerometer updates, and provides | |
| 61 // them via a callback. | |
| 62 SensorManagerDelegateChromeOS* delegate_; | |
|
timvolodine
2014/11/26 19:32:19
I assume Shell owns (and destructs) this. it's pro
jonross
2014/11/26 23:17:56
After the Shell destructs delegate_ it cannot be u
timvolodine
2014/11/28 17:46:06
ok, that's what I was wondering: the order of dest
jonross
2014/12/02 16:13:36
Extra documentation and a TODO added.
| |
| 63 | |
| 64 SensorManagerChromeOS(); | |
|
timvolodine
2014/11/26 19:32:19
this should come before the members
jonross
2014/12/02 16:13:36
Done.
| |
| 65 | |
| 66 // Callback that receives accelerometer events. These events are interpreted | |
| 67 // into orientation events. | |
| 68 void OnAccelerationIncludingGravity(double x, double y, double z); | |
|
timvolodine
2014/11/26 19:32:19
this also before the members
jonross
2014/12/02 16:13:36
Done.
| |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS); | |
| 71 }; | |
| 72 | |
| 73 } // namespace content | |
| 74 | |
| 75 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ | |
| OLD | NEW |