Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ | |
| 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ | |
| 7 | |
| 8 #include <SensorsApi.h> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/synchronization/lock.h" | |
| 13 #include "base/win/scoped_comptr.h" | |
| 14 #include "content/browser/device_orientation/data_fetcher.h" | |
| 15 #include "content/browser/device_orientation/device_data.h" | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 class Orientation; | |
| 20 | |
| 21 // Windows implementation of DeviceOrientation API. | |
| 22 // The SensorEventSink is installed to Windows sensor thread to listen for | |
| 23 // sensor's data. Upon each notification, DataFetcherImplWin buffers the data. | |
| 24 // Then Chrome sensor polling thread pulls the buffered data via GetDeviceData. | |
| 25 // The Inlinometer 3D sensor (SENSOR_TYPE_INCLINOMETER_3D) is used to get the | |
|
bulach
2013/04/02 15:48:07
nit: typo, In"c"linometer
nhu
2013/04/03 03:06:52
Done.
| |
| 26 // orientation data. | |
| 27 | |
| 28 class DataFetcherImplWin : public DataFetcher { | |
| 29 public: | |
| 30 // Factory function. We'll listen for events for the lifetime of this object. | |
| 31 // Returns NULL on error. | |
| 32 static DataFetcher* Create(); | |
| 33 | |
| 34 // Implement DataFetcher. | |
| 35 virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; | |
| 36 | |
| 37 virtual ~DataFetcherImplWin(); | |
| 38 | |
| 39 private: | |
| 40 class SensorEventSink; | |
| 41 friend SensorEventSink; | |
| 42 | |
| 43 DataFetcherImplWin(); | |
| 44 bool Init(); | |
| 45 void OnOrientationData(bool can_provide_alpha, double alpha, | |
| 46 bool can_provide_beta, double beta, | |
| 47 bool can_provide_gamma, double gamma); | |
| 48 const Orientation* GetOrientation(); | |
| 49 | |
| 50 base::win::ScopedComPtr<ISensor> sensor_; | |
| 51 | |
| 52 // The data buffer, written by OnOrientationData, read by GetDeviceData. | |
| 53 base::Lock last_orientation_lock_; | |
| 54 scoped_refptr<Orientation> last_orientation_; | |
| 55 }; | |
| 56 | |
| 57 } // namespace content | |
| 58 | |
| 59 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ | |
| 60 | |
| OLD | NEW |