Chromium Code Reviews| Index: content/browser/device_orientation/data_fetcher_impl_win.h |
| diff --git a/content/browser/device_orientation/data_fetcher_impl_win.h b/content/browser/device_orientation/data_fetcher_impl_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ef25778f5f3723250e2a2fac59bf0b2c76381f18 |
| --- /dev/null |
| +++ b/content/browser/device_orientation/data_fetcher_impl_win.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ |
| +#define CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ |
| + |
| +#include <SensorsApi.h> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/win/scoped_comptr.h" |
| +#include "content/browser/device_orientation/data_fetcher.h" |
| +#include "content/browser/device_orientation/device_data.h" |
| + |
| +namespace content { |
| + |
| +class Orientation; |
| + |
| +// Windows implementation of DeviceOrientation API. |
| +// The SensorEventSink is installed to Windows sensor thread to listen for |
| +// sensor's data. Upon each notification, DataFetcherImplWin buffers the data. |
| +// Then Chrome sensor polling thread pulls the buffered data via GetDeviceData. |
| +// 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.
|
| +// orientation data. |
| + |
| +class DataFetcherImplWin : public DataFetcher { |
| + public: |
| + // Factory function. We'll listen for events for the lifetime of this object. |
| + // Returns NULL on error. |
| + static DataFetcher* Create(); |
| + |
| + // Implement DataFetcher. |
| + virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; |
| + |
| + virtual ~DataFetcherImplWin(); |
| + |
| + private: |
| + class SensorEventSink; |
| + friend SensorEventSink; |
| + |
| + DataFetcherImplWin(); |
| + bool Init(); |
| + void OnOrientationData(bool can_provide_alpha, double alpha, |
| + bool can_provide_beta, double beta, |
| + bool can_provide_gamma, double gamma); |
| + const Orientation* GetOrientation(); |
| + |
| + base::win::ScopedComPtr<ISensor> sensor_; |
| + |
| + // The data buffer, written by OnOrientationData, read by GetDeviceData. |
| + base::Lock last_orientation_lock_; |
| + scoped_refptr<Orientation> last_orientation_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ |
| + |