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..cd040052532d18970883e85b044d2c32c22c9f23 100644 |
--- a/content/browser/device_orientation/device_motion_provider.h |
+++ b/content/browser/device_orientation/device_motion_provider.h |
@@ -13,9 +13,16 @@ |
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(); |
+ explicit DeviceMotionProvider(scoped_ptr<DataFetcherSharedMemory> fetcher); |
+ |
virtual ~DeviceMotionProvider(); |
// Returns the shared memory handle of the device motion data duplicated |
@@ -23,19 +30,21 @@ 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_; |
- |
- bool is_started_; |
+ scoped_ptr<PollingThread> polling_thread_; |
+ bool is_stopped_or_stopping_; |
DISALLOW_COPY_AND_ASSIGN(DeviceMotionProvider); |
}; |