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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "device/battery/battery_monitor.mojom.h" | 14 #include "device/battery/battery_monitor.mojom.h" |
15 #include "device/battery/battery_monitor_impl.h" | 15 #include "device/battery/battery_monitor_impl.h" |
16 #include "device/battery/battery_status_service.h" | 16 #include "device/battery/battery_status_service.h" |
17 #include "device/generic_sensor/sensor_provider_impl.h" | |
17 #include "device/sensors/device_sensor_host.h" | 18 #include "device/sensors/device_sensor_host.h" |
18 #include "device/wake_lock/wake_lock_context_provider.h" | 19 #include "device/wake_lock/wake_lock_context_provider.h" |
19 #include "mojo/public/cpp/system/message_pipe.h" | 20 #include "mojo/public/cpp/system/message_pipe.h" |
20 #include "services/device/fingerprint/fingerprint.h" | 21 #include "services/device/fingerprint/fingerprint.h" |
21 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" | 22 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" |
22 #include "services/device/time_zone_monitor/time_zone_monitor.h" | 23 #include "services/device/time_zone_monitor/time_zone_monitor.h" |
23 #include "services/service_manager/public/cpp/connection.h" | 24 #include "services/service_manager/public/cpp/connection.h" |
24 #include "services/service_manager/public/cpp/interface_registry.h" | 25 #include "services/service_manager/public/cpp/interface_registry.h" |
25 #include "services/service_manager/public/cpp/service_info.h" | 26 #include "services/service_manager/public/cpp/service_info.h" |
26 #include "ui/gfx/native_widget_types.h" | 27 #include "ui/gfx/native_widget_types.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 | 88 |
88 bool DeviceService::OnConnect(const service_manager::ServiceInfo& remote_info, | 89 bool DeviceService::OnConnect(const service_manager::ServiceInfo& remote_info, |
89 service_manager::InterfaceRegistry* registry) { | 90 service_manager::InterfaceRegistry* registry) { |
90 registry->AddInterface<mojom::Fingerprint>(this); | 91 registry->AddInterface<mojom::Fingerprint>(this); |
91 registry->AddInterface<mojom::LightSensor>(this); | 92 registry->AddInterface<mojom::LightSensor>(this); |
92 registry->AddInterface<mojom::MotionSensor>(this); | 93 registry->AddInterface<mojom::MotionSensor>(this); |
93 registry->AddInterface<mojom::OrientationSensor>(this); | 94 registry->AddInterface<mojom::OrientationSensor>(this); |
94 registry->AddInterface<mojom::OrientationAbsoluteSensor>(this); | 95 registry->AddInterface<mojom::OrientationAbsoluteSensor>(this); |
95 registry->AddInterface<mojom::PowerMonitor>(this); | 96 registry->AddInterface<mojom::PowerMonitor>(this); |
96 registry->AddInterface<mojom::ScreenOrientationListener>(this); | 97 registry->AddInterface<mojom::ScreenOrientationListener>(this); |
98 registry->AddInterface<mojom::SensorProvider>(this); | |
blundell
2017/03/27 14:56:52
We should preserve the check about the feature bei
ke.he
2017/03/28 05:41:11
The check code is: "if (base::FeatureList::IsEnabl
blundell
2017/03/28 07:03:52
Ah, great point! You are correct that a dep from /
| |
97 registry->AddInterface<mojom::TimeZoneMonitor>(this); | 99 registry->AddInterface<mojom::TimeZoneMonitor>(this); |
98 registry->AddInterface<mojom::WakeLockContextProvider>(this); | 100 registry->AddInterface<mojom::WakeLockContextProvider>(this); |
99 | 101 |
100 #if defined(OS_ANDROID) | 102 #if defined(OS_ANDROID) |
101 registry->AddInterface( | 103 registry->AddInterface( |
102 GetJavaInterfaceProvider()->CreateInterfaceFactory<BatteryMonitor>()); | 104 GetJavaInterfaceProvider()->CreateInterfaceFactory<BatteryMonitor>()); |
103 registry->AddInterface( | 105 registry->AddInterface( |
104 GetJavaInterfaceProvider() | 106 GetJavaInterfaceProvider() |
105 ->CreateInterfaceFactory<mojom::VibrationManager>()); | 107 ->CreateInterfaceFactory<mojom::VibrationManager>()); |
106 #else | 108 #else |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 #if defined(OS_ANDROID) | 210 #if defined(OS_ANDROID) |
209 if (io_task_runner_) { | 211 if (io_task_runner_) { |
210 io_task_runner_->PostTask( | 212 io_task_runner_->PostTask( |
211 FROM_HERE, base::Bind(&ScreenOrientationListenerAndroid::Create, | 213 FROM_HERE, base::Bind(&ScreenOrientationListenerAndroid::Create, |
212 base::Passed(&request))); | 214 base::Passed(&request))); |
213 } | 215 } |
214 #endif | 216 #endif |
215 } | 217 } |
216 | 218 |
217 void DeviceService::Create(const service_manager::Identity& remote_identity, | 219 void DeviceService::Create(const service_manager::Identity& remote_identity, |
220 mojom::SensorProviderRequest request) { | |
221 if (io_task_runner_) { | |
222 io_task_runner_->PostTask( | |
223 FROM_HERE, base::Bind(&device::SensorProviderImpl::Create, | |
224 file_task_runner_, base::Passed(&request))); | |
225 } | |
226 } | |
227 | |
228 void DeviceService::Create(const service_manager::Identity& remote_identity, | |
218 mojom::TimeZoneMonitorRequest request) { | 229 mojom::TimeZoneMonitorRequest request) { |
219 if (!time_zone_monitor_) | 230 if (!time_zone_monitor_) |
220 time_zone_monitor_ = TimeZoneMonitor::Create(file_task_runner_); | 231 time_zone_monitor_ = TimeZoneMonitor::Create(file_task_runner_); |
221 time_zone_monitor_->Bind(std::move(request)); | 232 time_zone_monitor_->Bind(std::move(request)); |
222 } | 233 } |
223 | 234 |
224 void DeviceService::Create(const service_manager::Identity& remote_identity, | 235 void DeviceService::Create(const service_manager::Identity& remote_identity, |
225 mojom::WakeLockContextProviderRequest request) { | 236 mojom::WakeLockContextProviderRequest request) { |
226 WakeLockContextProvider::Create(std::move(request), file_task_runner_, | 237 WakeLockContextProvider::Create(std::move(request), file_task_runner_, |
227 wake_lock_context_callback_); | 238 wake_lock_context_callback_); |
(...skipping 10 matching lines...) Expand all Loading... | |
238 java_interface_provider_.Bind(std::move(provider)); | 249 java_interface_provider_.Bind(std::move(provider)); |
239 | 250 |
240 java_interface_provider_initialized_ = true; | 251 java_interface_provider_initialized_ = true; |
241 } | 252 } |
242 | 253 |
243 return &java_interface_provider_; | 254 return &java_interface_provider_; |
244 } | 255 } |
245 #endif | 256 #endif |
246 | 257 |
247 } // namespace device | 258 } // namespace device |
OLD | NEW |