OLD | NEW |
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 #include "content/browser/device_sensors/device_sensor_host.h" | 5 #include "content/browser/device_sensors/device_sensor_host.h" |
6 | 6 |
7 #include "content/browser/device_sensors/device_sensor_service.h" | 7 #include "content/browser/device_sensors/device_sensor_service.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
9 | 10 |
10 namespace content { | 11 namespace content { |
11 | 12 |
12 template <typename MojoInterface, ConsumerType consumer_type> | 13 template <typename MojoInterface, ConsumerType consumer_type> |
13 void DeviceSensorHost<MojoInterface, consumer_type>::Create( | 14 void DeviceSensorHost<MojoInterface, consumer_type>::Create( |
14 mojo::InterfaceRequest<MojoInterface> request) { | 15 mojo::InterfaceRequest<MojoInterface> request) { |
15 new DeviceSensorHost(std::move(request)); | 16 mojo::MakeStrongBinding( |
| 17 base::WrapUnique(new DeviceSensorHost<MojoInterface, consumer_type>), |
| 18 std::move(request)); |
16 } | 19 } |
17 | 20 |
18 template <typename MojoInterface, ConsumerType consumer_type> | 21 template <typename MojoInterface, ConsumerType consumer_type> |
19 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost( | 22 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost() |
20 mojo::InterfaceRequest<MojoInterface> request) | 23 : is_started_(false) { |
21 : is_started_(false), binding_(this, std::move(request)) { | |
22 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 24 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
23 } | 25 } |
24 | 26 |
25 template <typename MojoInterface, ConsumerType consumer_type> | 27 template <typename MojoInterface, ConsumerType consumer_type> |
26 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() { | 28 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() { |
27 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
28 if (is_started_) | 30 if (is_started_) |
29 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type); | 31 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type); |
30 } | 32 } |
31 | 33 |
(...skipping 24 matching lines...) Expand all Loading... |
56 template class DeviceSensorHost<device::mojom::LightSensor, | 58 template class DeviceSensorHost<device::mojom::LightSensor, |
57 CONSUMER_TYPE_LIGHT>; | 59 CONSUMER_TYPE_LIGHT>; |
58 template class DeviceSensorHost<device::mojom::MotionSensor, | 60 template class DeviceSensorHost<device::mojom::MotionSensor, |
59 CONSUMER_TYPE_MOTION>; | 61 CONSUMER_TYPE_MOTION>; |
60 template class DeviceSensorHost<device::mojom::OrientationSensor, | 62 template class DeviceSensorHost<device::mojom::OrientationSensor, |
61 CONSUMER_TYPE_ORIENTATION>; | 63 CONSUMER_TYPE_ORIENTATION>; |
62 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, | 64 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, |
63 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; | 65 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; |
64 | 66 |
65 } // namespace content | 67 } // namespace content |
OLD | NEW |