Index: content/browser/device_orientation/device_motion_provider.h |
diff --git a/content/browser/device_orientation/device_motion_provider.h b/content/browser/device_orientation/device_motion_provider.h |
index 90588dac58c234197173df3ce6d295ecfb8be128..8fd36de33d6e9f01f972a486ab019747f4560951 100644 |
--- a/content/browser/device_orientation/device_motion_provider.h |
+++ b/content/browser/device_orientation/device_motion_provider.h |
@@ -13,9 +13,18 @@ |
namespace content { |
class DataFetcherSharedMemory; |
+// This class owns the shared memory buffer for Device Motion and makes |
+// sure the data is fetched into that buffer. |
+// When DataFetcherSharedMemory::NeedsPolling() is true, it starts a |
+// background polling thread to make sure the data is fetched at regular |
+// intervals. |
class CONTENT_EXPORT DeviceMotionProvider { |
public: |
DeviceMotionProvider(); |
+ |
+ // Creates provider with a custom fetcher. Used for testing. |
+ explicit DeviceMotionProvider(scoped_ptr<DataFetcherSharedMemory> fetcher); |
+ |
virtual ~DeviceMotionProvider(); |
// Returns the shared memory handle of the device motion data duplicated |
@@ -23,18 +32,20 @@ class CONTENT_EXPORT DeviceMotionProvider { |
base::SharedMemoryHandle GetSharedMemoryHandleForProcess( |
base::ProcessHandle renderer_process); |
- // Pause and resume the background polling thread. Can be called from any |
- // thread. |
void StartFetchingDeviceMotionData(); |
void StopFetchingDeviceMotionData(); |
private: |
- base::SharedMemory device_motion_shared_memory_; |
+ class PollingThread; |
+ |
+ void Initialize(); |
+ void CreateAndStartPollingThread(); |
DeviceMotionHardwareBuffer* SharedMemoryAsHardwareBuffer(); |
+ base::SharedMemory device_motion_shared_memory_; |
scoped_ptr<DataFetcherSharedMemory> data_fetcher_; |
- |
+ scoped_ptr<PollingThread> polling_thread_; |
bool is_started_; |
DISALLOW_COPY_AND_ASSIGN(DeviceMotionProvider); |