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

Side by Side Diff: content/browser/device_sensors/device_sensor_host.h

Issue 2160913005: Use a ThreadChecker in DeviceSensorHost instead of DCHECK_CURRENTLY_ON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_ 5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_
6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_ 6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "content/browser/device_sensors/device_sensors_consts.h" 10 #include "content/browser/device_sensors/device_sensors_consts.h"
11 #include "device/sensors/public/interfaces/light.mojom.h" 11 #include "device/sensors/public/interfaces/light.mojom.h"
12 #include "device/sensors/public/interfaces/motion.mojom.h" 12 #include "device/sensors/public/interfaces/motion.mojom.h"
13 #include "device/sensors/public/interfaces/orientation.mojom.h" 13 #include "device/sensors/public/interfaces/orientation.mojom.h"
14 #include "mojo/public/cpp/bindings/interface_request.h" 14 #include "mojo/public/cpp/bindings/interface_request.h"
15 #include "mojo/public/cpp/bindings/strong_binding.h" 15 #include "mojo/public/cpp/bindings/strong_binding.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 // A base class for device sensor related mojo interface implementations. 19 // A base class for device sensor related mojo interface implementations.
20 template <typename MojoInterface, ConsumerType consumer_type> 20 template <typename MojoInterface, ConsumerType consumer_type>
21 class DeviceSensorHost : public MojoInterface { 21 class DeviceSensorHost : public MojoInterface {
22 public: 22 public:
23 static void Create(mojo::InterfaceRequest<MojoInterface> request); 23 static void Create(mojo::InterfaceRequest<MojoInterface> request);
24 24
25 // All methods below to be called on the IO thread. 25 // All methods below to be called on the IO thread.
timvolodine 2016/07/20 18:41:56 hmm I understand this is now actually enforced in
Sam McNally 2016/07/21 00:09:28 Done.
26 ~DeviceSensorHost() override; 26 ~DeviceSensorHost() override;
27 27
28 private: 28 private:
29 explicit DeviceSensorHost(mojo::InterfaceRequest<MojoInterface> request); 29 explicit DeviceSensorHost(mojo::InterfaceRequest<MojoInterface> request);
30 30
31 void StartPolling( 31 void StartPolling(
32 const typename MojoInterface::StartPollingCallback& callback) override; 32 const typename MojoInterface::StartPollingCallback& callback) override;
33 void StopPolling() override; 33 void StopPolling() override;
34 34
35 bool is_started_; 35 bool is_started_;
36 36
37 mojo::StrongBinding<MojoInterface> binding_; 37 mojo::StrongBinding<MojoInterface> binding_;
38 38
39 base::ThreadChecker thread_checker_;
40
39 DISALLOW_COPY_AND_ASSIGN(DeviceSensorHost); 41 DISALLOW_COPY_AND_ASSIGN(DeviceSensorHost);
40 }; 42 };
41 43
42 using DeviceLightHost = 44 using DeviceLightHost =
43 DeviceSensorHost<device::mojom::LightSensor, CONSUMER_TYPE_LIGHT>; 45 DeviceSensorHost<device::mojom::LightSensor, CONSUMER_TYPE_LIGHT>;
44 using DeviceMotionHost = 46 using DeviceMotionHost =
45 DeviceSensorHost<device::mojom::MotionSensor, CONSUMER_TYPE_MOTION>; 47 DeviceSensorHost<device::mojom::MotionSensor, CONSUMER_TYPE_MOTION>;
46 using DeviceOrientationHost = DeviceSensorHost<device::mojom::OrientationSensor, 48 using DeviceOrientationHost = DeviceSensorHost<device::mojom::OrientationSensor,
47 CONSUMER_TYPE_ORIENTATION>; 49 CONSUMER_TYPE_ORIENTATION>;
48 using DeviceOrientationAbsoluteHost = 50 using DeviceOrientationAbsoluteHost =
49 DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, 51 DeviceSensorHost<device::mojom::OrientationAbsoluteSensor,
50 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; 52 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>;
51 53
52 } // namespace content 54 } // namespace content
53 55
54 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_ 56 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/device_sensors/device_sensor_browsertest.cc ('k') | content/browser/device_sensors/device_sensor_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698