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

Unified Diff: content/browser/device_orientation/device_motion_provider.h

Issue 19833005: Implement PollingThread for Device Motion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed comments Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698