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

Side by Side 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: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_SENSORS_DEVICE_SENSOR_HOST_H_
6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_
7
8 #include "base/macros.h"
9 #include "base/memory/shared_memory.h"
10 #include "content/browser/device_sensors/device_sensors_consts.h"
11 #include "device/sensors/public/interfaces/light.mojom.h"
12 #include "device/sensors/public/interfaces/motion.mojom.h"
13 #include "device/sensors/public/interfaces/orientation.mojom.h"
14 #include "mojo/public/cpp/bindings/interface_request.h"
15 #include "mojo/public/cpp/bindings/strong_binding.h"
16
17 namespace content {
18
19 // A base class for device sensor related mojo interface implementations.
20 template <typename MojoInterface, ConsumerType consumer_type>
21 class DeviceSensorHost : public MojoInterface {
22 public:
23 static void Create(mojo::InterfaceRequest<MojoInterface> request);
24
25 // All methods below to be called on the IO thread.
26 ~DeviceSensorHost() override;
27
28 private:
29 explicit DeviceSensorHost(mojo::InterfaceRequest<MojoInterface> request);
30
31 void StartPolling(
32 const typename MojoInterface::StartPollingCallback& callback) override;
33 void StopPolling() override;
34
35 bool is_started_;
36
37 mojo::StrongBinding<MojoInterface> binding_;
38
39 DISALLOW_COPY_AND_ASSIGN(DeviceSensorHost);
40 };
41
42 using DeviceLightHost =
43 DeviceSensorHost<device::mojom::LightSensor, CONSUMER_TYPE_LIGHT>;
44 using DeviceMotionHost =
45 DeviceSensorHost<device::mojom::MotionSensor, CONSUMER_TYPE_MOTION>;
46 using DeviceOrientationHost = DeviceSensorHost<device::mojom::OrientationSensor,
47 CONSUMER_TYPE_ORIENTATION>;
48 using DeviceOrientationAbsoluteHost =
49 DeviceSensorHost<device::mojom::OrientationAbsoluteSensor,
50 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>;
51
52 } // namespace content
53
54 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698