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 Inclinometer 3D sensor (SENSOR_TYPE_INCLINOMETER_3D) is used to get the | |
| 26 // orientation data. | |
| 27 | |
| 28 class DataFetcherImplWin : public DataFetcher { | |
| 29 public: | |
| 30 // Factory function. It returns NULL on error. | |
| 31 // The created object listens for events for the whole lifetime. | |
| 32 static DataFetcher* Create(); | |
| 33 | |
| 34 // Implement DataFetcher. | |
| 35 virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; | |
| 36 | |
| 37 virtual ~DataFetcherImplWin(); | |
|
bulach
2013/04/10 07:59:46
nit: destructor should be on top, before the stati
nhu
2013/04/10 09:46:42
Done.
| |
| 38 | |
| 39 private: | |
| 40 class SensorEventSink; | |
| 41 friend SensorEventSink; | |
| 42 | |
| 43 DataFetcherImplWin(); | |
| 44 bool Initialize(); | |
| 45 void OnOrientationData(Orientation* orientation); | |
| 46 const Orientation* GetOrientation(); | |
| 47 | |
| 48 base::win::ScopedComPtr<ISensor> sensor_; | |
| 49 | |
| 50 // Value returned by GetDeviceData. | |
| 51 scoped_refptr<Orientation> current_orientation_; | |
| 52 | |
| 53 // The 1-element buffer follows DataFetcherImplAndroid implementation. | |
| 54 // It is written by OnOrientationData and read by GetDeviceData. | |
| 55 base::Lock next_orientation_lock_; | |
| 56 scoped_refptr<Orientation> next_orientation_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplWin); | |
| 59 }; | |
| 60 | |
| 61 } // namespace content | |
| 62 | |
| 63 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ | |
| 64 | |
|
bulach
2013/04/10 07:59:46
nit: extra \n
nhu
2013/04/10 09:46:42
Done.
| |
| OLD | NEW |