OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_H_ |
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_H_ | 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_H_ |
7 | 7 |
8 #include "content/browser/device_orientation/device_data.h" | 8 #include "content/browser/device_orientation/device_data.h" |
9 #include "content/common/device_motion_hardware_buffer.h" | 9 #include "content/common/device_motion_hardware_buffer.h" |
10 | 10 |
11 namespace WebKit { | 11 namespace WebKit { |
12 class WebDeviceMotionData; | 12 class WebDeviceMotionData; |
13 } | 13 } |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class DataFetcherSharedMemory { | 17 class CONTENT_EXPORT DataFetcherSharedMemory { |
18 public: | 18 public: |
19 DataFetcherSharedMemory() : device_motion_buffer_(NULL) { } | 19 DataFetcherSharedMemory() |
| 20 : device_motion_buffer_(NULL), |
| 21 started_(false) { } |
20 virtual ~DataFetcherSharedMemory(); | 22 virtual ~DataFetcherSharedMemory(); |
21 | 23 |
22 // Returns true if this fetcher needs explicit calls to fetch the data. | 24 // Returns true if this fetcher needs explicit calls to fetch the data. |
| 25 // Called from any thread. |
23 virtual bool NeedsPolling(); | 26 virtual bool NeedsPolling(); |
24 | 27 |
25 // If this fetcher NeedsPolling() is true, this method will update the | 28 // If this fetcher NeedsPolling() is true, this method will update the |
26 // buffer with the latest device motion data. | 29 // buffer with the latest device motion data. |
27 // This method will do nothing if NeedsPolling() is false. | |
28 // Returns true if there was any motion data to update the buffer with. | 30 // Returns true if there was any motion data to update the buffer with. |
| 31 // Called from the DeviceMotionProvider::PollingThread. |
29 virtual bool FetchDeviceMotionDataIntoBuffer(); | 32 virtual bool FetchDeviceMotionDataIntoBuffer(); |
30 | 33 |
31 // Returns true if the relevant sensors could be successfully activated. | 34 // Returns true if the relevant sensors could be successfully activated. |
32 // This method should be called before any calls to | 35 // This method should be called before any calls to |
33 // FetchDeviceMotionDataIntoBuffer(). | 36 // FetchDeviceMotionDataIntoBuffer(). |
| 37 // If NeedsPolling() is true this method should be called from the |
| 38 // PollingThread. |
34 virtual bool StartFetchingDeviceMotionData( | 39 virtual bool StartFetchingDeviceMotionData( |
35 DeviceMotionHardwareBuffer* buffer); | 40 DeviceMotionHardwareBuffer* buffer); |
36 | 41 |
37 // Indicates to the fetcher to stop fetching device data. | 42 // Indicates to the fetcher to stop fetching device data. |
| 43 // If NeedsPolling() is true this method should be called from the |
| 44 // PollingThread. |
38 virtual void StopFetchingDeviceMotionData(); | 45 virtual void StopFetchingDeviceMotionData(); |
39 | 46 |
40 private: | 47 private: |
41 DeviceMotionHardwareBuffer* device_motion_buffer_; | 48 DeviceMotionHardwareBuffer* device_motion_buffer_; |
| 49 bool started_; |
42 | 50 |
43 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemory); | 51 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemory); |
44 }; | 52 }; |
45 | 53 |
46 } // namespace content | 54 } // namespace content |
47 | 55 |
48 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_H_ | 56 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_H_ |
OLD | NEW |