Chromium Code Reviews| 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 "base/message_loop/message_loop.h" | |
| 7 #include "content/browser/device_sensors/device_sensor_service.h" | 8 #include "content/browser/device_sensors/device_sensor_service.h" |
| 8 #include "content/public/browser/browser_thread.h" | |
|
timvolodine
2016/11/10 16:43:04
actually a question: so we can depend on content/p
blundell
2016/11/15 09:09:09
Yes, essentially. Individual components make their
| |
| 9 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 template <typename MojoInterface, ConsumerType consumer_type> | 13 template <typename MojoInterface, ConsumerType consumer_type> |
| 14 void DeviceSensorHost<MojoInterface, consumer_type>::Create( | 14 void DeviceSensorHost<MojoInterface, consumer_type>::Create( |
| 15 mojo::InterfaceRequest<MojoInterface> request) { | 15 mojo::InterfaceRequest<MojoInterface> request) { |
| 16 mojo::MakeStrongBinding( | 16 mojo::MakeStrongBinding( |
| 17 base::WrapUnique(new DeviceSensorHost<MojoInterface, consumer_type>), | 17 base::WrapUnique(new DeviceSensorHost<MojoInterface, consumer_type>), |
| 18 std::move(request)); | 18 std::move(request)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 template <typename MojoInterface, ConsumerType consumer_type> | 21 template <typename MojoInterface, ConsumerType consumer_type> |
| 22 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost() | 22 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost() |
| 23 : is_started_(false) { | 23 : is_started_(false) { |
| 24 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
| 25 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 25 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| 26 #else | 26 #else |
| 27 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 27 DCHECK(base::MessageLoopForIO::IsCurrent()); |
| 28 #endif | 28 #endif |
| 29 } | 29 } |
| 30 | 30 |
| 31 template <typename MojoInterface, ConsumerType consumer_type> | 31 template <typename MojoInterface, ConsumerType consumer_type> |
| 32 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() { | 32 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() { |
| 33 DCHECK(thread_checker_.CalledOnValidThread()); | 33 DCHECK(thread_checker_.CalledOnValidThread()); |
| 34 if (is_started_) | 34 if (is_started_) |
| 35 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type); | 35 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type); |
| 36 } | 36 } |
| 37 | 37 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 62 template class DeviceSensorHost<device::mojom::LightSensor, | 62 template class DeviceSensorHost<device::mojom::LightSensor, |
| 63 CONSUMER_TYPE_LIGHT>; | 63 CONSUMER_TYPE_LIGHT>; |
| 64 template class DeviceSensorHost<device::mojom::MotionSensor, | 64 template class DeviceSensorHost<device::mojom::MotionSensor, |
| 65 CONSUMER_TYPE_MOTION>; | 65 CONSUMER_TYPE_MOTION>; |
| 66 template class DeviceSensorHost<device::mojom::OrientationSensor, | 66 template class DeviceSensorHost<device::mojom::OrientationSensor, |
| 67 CONSUMER_TYPE_ORIENTATION>; | 67 CONSUMER_TYPE_ORIENTATION>; |
| 68 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, | 68 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, |
| 69 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; | 69 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; |
| 70 | 70 |
| 71 } // namespace content | 71 } // namespace content |
| OLD | NEW |