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

Unified Diff: content/browser/device_sensors/device_sensor_host.h

Issue 2037513002: Convert device_sensors to use mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@conversion--mime-registry
Patch Set: rebase Created 4 years, 6 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: content/browser/device_sensors/device_sensor_host.h
diff --git a/content/browser/device_sensors/device_sensor_host.h b/content/browser/device_sensors/device_sensor_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..9ab73649cc1e8747ac7602942a92769d4ccb2283
--- /dev/null
+++ b/content/browser/device_sensors/device_sensor_host.h
@@ -0,0 +1,54 @@
+// 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 CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_
+#define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_
+
+#include "base/macros.h"
+#include "base/memory/shared_memory.h"
+#include "content/browser/device_sensors/device_sensors_consts.h"
+#include "device/sensors/public/interfaces/light.mojom.h"
+#include "device/sensors/public/interfaces/motion.mojom.h"
+#include "device/sensors/public/interfaces/orientation.mojom.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace content {
+
+// A base class for device sensor related mojo interface implementations.
+template <typename MojoInterface, ConsumerType consumer_type>
+class DeviceSensorHost : public MojoInterface {
+ public:
+ static void Create(mojo::InterfaceRequest<MojoInterface> request);
+
+ // All methods below to be called on the IO thread.
+ ~DeviceSensorHost() override;
+
+ private:
+ explicit DeviceSensorHost(mojo::InterfaceRequest<MojoInterface> request);
+
+ void StartPolling(
+ const typename MojoInterface::StartPollingCallback& callback) override;
+ void StopPolling() override;
+
+ bool is_started_;
+
+ mojo::StrongBinding<MojoInterface> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceSensorHost);
+};
+
+using DeviceLightHost =
+ DeviceSensorHost<device::mojom::LightSensor, CONSUMER_TYPE_LIGHT>;
+using DeviceMotionHost =
+ DeviceSensorHost<device::mojom::MotionSensor, CONSUMER_TYPE_MOTION>;
+using DeviceOrientationHost = DeviceSensorHost<device::mojom::OrientationSensor,
+ CONSUMER_TYPE_ORIENTATION>;
+using DeviceOrientationAbsoluteHost =
+ DeviceSensorHost<device::mojom::OrientationAbsoluteSensor,
+ CONSUMER_TYPE_ORIENTATION_ABSOLUTE>;
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698