| 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 "services/device/device_service.h" | 5 #include "services/device/device_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 DeviceService::~DeviceService() { | 85 DeviceService::~DeviceService() { |
| 86 #if !defined(OS_ANDROID) | 86 #if !defined(OS_ANDROID) |
| 87 device::BatteryStatusService::GetInstance()->Shutdown(); | 87 device::BatteryStatusService::GetInstance()->Shutdown(); |
| 88 #endif | 88 #endif |
| 89 } | 89 } |
| 90 | 90 |
| 91 void DeviceService::OnStart() { | 91 void DeviceService::OnStart() { |
| 92 registry_.AddInterface<mojom::Fingerprint>(base::Bind( | 92 registry_.AddInterface<mojom::Fingerprint>(base::Bind( |
| 93 &DeviceService::BindFingerprintRequest, base::Unretained(this))); | 93 &DeviceService::BindFingerprintRequest, base::Unretained(this))); |
| 94 registry_.AddInterface<mojom::MotionSensor>(base::Bind( | |
| 95 &DeviceService::BindMotionSensorRequest, base::Unretained(this))); | |
| 96 registry_.AddInterface<mojom::OrientationSensor>(base::Bind( | 94 registry_.AddInterface<mojom::OrientationSensor>(base::Bind( |
| 97 &DeviceService::BindOrientationSensorRequest, base::Unretained(this))); | 95 &DeviceService::BindOrientationSensorRequest, base::Unretained(this))); |
| 98 registry_.AddInterface<mojom::OrientationAbsoluteSensor>( | 96 registry_.AddInterface<mojom::OrientationAbsoluteSensor>( |
| 99 base::Bind(&DeviceService::BindOrientationAbsoluteSensorRequest, | 97 base::Bind(&DeviceService::BindOrientationAbsoluteSensorRequest, |
| 100 base::Unretained(this))); | 98 base::Unretained(this))); |
| 101 registry_.AddInterface<mojom::PowerMonitor>(base::Bind( | 99 registry_.AddInterface<mojom::PowerMonitor>(base::Bind( |
| 102 &DeviceService::BindPowerMonitorRequest, base::Unretained(this))); | 100 &DeviceService::BindPowerMonitorRequest, base::Unretained(this))); |
| 103 registry_.AddInterface<mojom::ScreenOrientationListener>( | 101 registry_.AddInterface<mojom::ScreenOrientationListener>( |
| 104 base::Bind(&DeviceService::BindScreenOrientationListenerRequest, | 102 base::Bind(&DeviceService::BindScreenOrientationListenerRequest, |
| 105 base::Unretained(this))); | 103 base::Unretained(this))); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 VibrationManagerImpl::Create(std::move(request)); | 157 VibrationManagerImpl::Create(std::move(request)); |
| 160 } | 158 } |
| 161 #endif | 159 #endif |
| 162 | 160 |
| 163 void DeviceService::BindFingerprintRequest( | 161 void DeviceService::BindFingerprintRequest( |
| 164 const service_manager::BindSourceInfo& source_info, | 162 const service_manager::BindSourceInfo& source_info, |
| 165 mojom::FingerprintRequest request) { | 163 mojom::FingerprintRequest request) { |
| 166 Fingerprint::Create(std::move(request)); | 164 Fingerprint::Create(std::move(request)); |
| 167 } | 165 } |
| 168 | 166 |
| 169 void DeviceService::BindMotionSensorRequest( | |
| 170 const service_manager::BindSourceInfo& source_info, | |
| 171 mojom::MotionSensorRequest request) { | |
| 172 #if defined(OS_ANDROID) | |
| 173 // On Android the device sensors implementations need to run on the UI thread | |
| 174 // to communicate to Java. | |
| 175 DeviceMotionHost::Create(std::move(request)); | |
| 176 #else | |
| 177 // On platforms other than Android the device sensors implementations run on | |
| 178 // the IO thread. | |
| 179 if (io_task_runner_) { | |
| 180 io_task_runner_->PostTask(FROM_HERE, base::Bind(&DeviceMotionHost::Create, | |
| 181 base::Passed(&request))); | |
| 182 } | |
| 183 #endif // defined(OS_ANDROID) | |
| 184 } | |
| 185 | |
| 186 void DeviceService::BindOrientationSensorRequest( | 167 void DeviceService::BindOrientationSensorRequest( |
| 187 const service_manager::BindSourceInfo& source_info, | 168 const service_manager::BindSourceInfo& source_info, |
| 188 mojom::OrientationSensorRequest request) { | 169 mojom::OrientationSensorRequest request) { |
| 189 #if defined(OS_ANDROID) | 170 #if defined(OS_ANDROID) |
| 190 // On Android the device sensors implementations need to run on the UI thread | 171 // On Android the device sensors implementations need to run on the UI thread |
| 191 // to communicate to Java. | 172 // to communicate to Java. |
| 192 DeviceOrientationHost::Create(std::move(request)); | 173 DeviceOrientationHost::Create(std::move(request)); |
| 193 #else | 174 #else |
| 194 // On platforms other than Android the device sensors implementations run on | 175 // On platforms other than Android the device sensors implementations run on |
| 195 // the IO thread. | 176 // the IO thread. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 java_interface_provider_.Bind(std::move(provider)); | 258 java_interface_provider_.Bind(std::move(provider)); |
| 278 | 259 |
| 279 java_interface_provider_initialized_ = true; | 260 java_interface_provider_initialized_ = true; |
| 280 } | 261 } |
| 281 | 262 |
| 282 return &java_interface_provider_; | 263 return &java_interface_provider_; |
| 283 } | 264 } |
| 284 #endif | 265 #endif |
| 285 | 266 |
| 286 } // namespace device | 267 } // namespace device |
| OLD | NEW |