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

Unified Diff: device/generic_sensor/platform_sensor_provider_win.h

Issue 2447973003: [sensors] [win] Implement ambient light sensor for Windows platform (Closed)
Patch Set: Modify timestamp calculation as proposed by miu@ Created 4 years, 2 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: device/generic_sensor/platform_sensor_provider_win.h
diff --git a/device/generic_sensor/platform_sensor_provider_win.h b/device/generic_sensor/platform_sensor_provider_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..13b2aa48d50fd41a30222cf50696072515b4370b
--- /dev/null
+++ b/device/generic_sensor/platform_sensor_provider_win.h
@@ -0,0 +1,72 @@
+// Copyright 2016 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 DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_WIN_H_
+#define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_WIN_H_
+
+#include <SensorsApi.h>
+
+#include "base/win/scoped_comptr.h"
+#include "device/generic_sensor/generic_sensor_export.h"
+#include "device/generic_sensor/platform_sensor_provider.h"
+
+namespace base {
+template <typename T>
+struct DefaultSingletonTraits;
+class Thread;
+}
+
+namespace device {
+
+class PlatformSensorReaderWin;
+
+// Implementation of PlatformSensorProvider for Windows platform.
+// PlatformSensorProviderWin is responsible for following tasks:
+// - Starts sensor thread and stops it when there are no active sensors.
+// - Initialises ISensorManager and creates sensor reader on sensor thread.
+// - Constructs PlatformSensorWin on IPC thread and returns it to requester.
+class DEVICE_GENERIC_SENSOR_EXPORT PlatformSensorProviderWin final
+ : public PlatformSensorProvider {
+ public:
+ static PlatformSensorProviderWin* GetInstance();
+
+ // Overrides ISensorManager COM interface provided by the system, used
+ // only for testing purposes.
+ void SetSensorManagerForTesing(
Lei Zhang 2016/10/29 05:10:42 type: ForTesting
shalamov 2016/10/31 13:12:57 Done.
+ base::win::ScopedComPtr<ISensorManager> sensor_manager);
+
+ protected:
+ ~PlatformSensorProviderWin() override;
+
+ // PlatformSensorProvider interface implementation.
+ void AllSensorsRemoved() override;
+ void CreateSensorInternal(mojom::SensorType type,
+ mojo::ScopedSharedBufferMapping mapping,
+ const CreateSensorCallback& callback) override;
+
+ private:
+ PlatformSensorProviderWin();
Lei Zhang 2016/10/29 05:10:42 separate the ctor for the rest.
shalamov 2016/10/31 13:12:57 Done.
+ bool InitializeSensorManager();
+ bool StartSensorThread();
+ void StopSensorThread();
+ std::unique_ptr<PlatformSensorReaderWin> CreateSensorReader(
+ mojom::SensorType type);
+ void SensorReaderCreated(
+ mojom::SensorType type,
+ mojo::ScopedSharedBufferMapping mapping,
+ const CreateSensorCallback& callback,
+ std::unique_ptr<PlatformSensorReaderWin> sensor_reader);
+
+ private:
+ friend struct base::DefaultSingletonTraits<PlatformSensorProviderWin>;
+
+ base::win::ScopedComPtr<ISensorManager> sensor_manager_;
+ std::unique_ptr<base::Thread> sensor_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderWin);
+};
+
+} // namespace device
+
+#endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698