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

Side by Side Diff: services/device/device_service.cc

Issue 2953263002: Revert of Reland: Refactor DeviceMotionEventPump to use //device/generic_sensor instead of //device/sensors (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « services/device/device_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
14 #include "device/generic_sensor/sensor_provider_impl.h" 15 #include "device/generic_sensor/sensor_provider_impl.h"
15 #include "device/sensors/device_sensor_host.h" 16 #include "device/sensors/device_sensor_host.h"
16 #include "device/wake_lock/wake_lock_provider.h" 17 #include "device/wake_lock/wake_lock_provider.h"
17 #include "mojo/public/cpp/system/message_pipe.h" 18 #include "mojo/public/cpp/system/message_pipe.h"
18 #include "services/device/fingerprint/fingerprint.h" 19 #include "services/device/fingerprint/fingerprint.h"
19 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" 20 #include "services/device/power_monitor/power_monitor_message_broadcaster.h"
21 #include "services/device/public/cpp/device_features.h"
20 #include "services/device/public/interfaces/battery_monitor.mojom.h" 22 #include "services/device/public/interfaces/battery_monitor.mojom.h"
21 #include "services/device/time_zone_monitor/time_zone_monitor.h" 23 #include "services/device/time_zone_monitor/time_zone_monitor.h"
22 #include "services/service_manager/public/cpp/bind_source_info.h" 24 #include "services/service_manager/public/cpp/bind_source_info.h"
23 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
24 26
25 #if defined(OS_ANDROID) 27 #if defined(OS_ANDROID)
26 #include "base/android/jni_android.h" 28 #include "base/android/jni_android.h"
27 #include "jni/InterfaceRegistrar_jni.h" 29 #include "jni/InterfaceRegistrar_jni.h"
28 #include "services/device/android/register_jni.h" 30 #include "services/device/android/register_jni.h"
29 #include "services/device/screen_orientation/screen_orientation_listener_android .h" 31 #include "services/device/screen_orientation/screen_orientation_listener_android .h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 83
82 DeviceService::~DeviceService() { 84 DeviceService::~DeviceService() {
83 #if !defined(OS_ANDROID) 85 #if !defined(OS_ANDROID)
84 device::BatteryStatusService::GetInstance()->Shutdown(); 86 device::BatteryStatusService::GetInstance()->Shutdown();
85 #endif 87 #endif
86 } 88 }
87 89
88 void DeviceService::OnStart() { 90 void DeviceService::OnStart() {
89 registry_.AddInterface<mojom::Fingerprint>(base::Bind( 91 registry_.AddInterface<mojom::Fingerprint>(base::Bind(
90 &DeviceService::BindFingerprintRequest, base::Unretained(this))); 92 &DeviceService::BindFingerprintRequest, base::Unretained(this)));
93 registry_.AddInterface<mojom::MotionSensor>(base::Bind(
94 &DeviceService::BindMotionSensorRequest, base::Unretained(this)));
91 registry_.AddInterface<mojom::OrientationSensor>(base::Bind( 95 registry_.AddInterface<mojom::OrientationSensor>(base::Bind(
92 &DeviceService::BindOrientationSensorRequest, base::Unretained(this))); 96 &DeviceService::BindOrientationSensorRequest, base::Unretained(this)));
93 registry_.AddInterface<mojom::OrientationAbsoluteSensor>( 97 registry_.AddInterface<mojom::OrientationAbsoluteSensor>(
94 base::Bind(&DeviceService::BindOrientationAbsoluteSensorRequest, 98 base::Bind(&DeviceService::BindOrientationAbsoluteSensorRequest,
95 base::Unretained(this))); 99 base::Unretained(this)));
96 registry_.AddInterface<mojom::PowerMonitor>(base::Bind( 100 registry_.AddInterface<mojom::PowerMonitor>(base::Bind(
97 &DeviceService::BindPowerMonitorRequest, base::Unretained(this))); 101 &DeviceService::BindPowerMonitorRequest, base::Unretained(this)));
98 registry_.AddInterface<mojom::ScreenOrientationListener>( 102 registry_.AddInterface<mojom::ScreenOrientationListener>(
99 base::Bind(&DeviceService::BindScreenOrientationListenerRequest, 103 base::Bind(&DeviceService::BindScreenOrientationListenerRequest,
100 base::Unretained(this))); 104 base::Unretained(this)));
101 registry_.AddInterface<mojom::SensorProvider>(base::Bind( 105 if (base::FeatureList::IsEnabled(features::kGenericSensor)) {
102 &DeviceService::BindSensorProviderRequest, base::Unretained(this))); 106 registry_.AddInterface<mojom::SensorProvider>(base::Bind(
107 &DeviceService::BindSensorProviderRequest, base::Unretained(this)));
108 }
103 registry_.AddInterface<mojom::TimeZoneMonitor>(base::Bind( 109 registry_.AddInterface<mojom::TimeZoneMonitor>(base::Bind(
104 &DeviceService::BindTimeZoneMonitorRequest, base::Unretained(this))); 110 &DeviceService::BindTimeZoneMonitorRequest, base::Unretained(this)));
105 registry_.AddInterface<mojom::WakeLockProvider>(base::Bind( 111 registry_.AddInterface<mojom::WakeLockProvider>(base::Bind(
106 &DeviceService::BindWakeLockProviderRequest, base::Unretained(this))); 112 &DeviceService::BindWakeLockProviderRequest, base::Unretained(this)));
107 113
108 #if defined(OS_ANDROID) 114 #if defined(OS_ANDROID)
109 registry_.AddInterface(GetJavaInterfaceProvider() 115 registry_.AddInterface(GetJavaInterfaceProvider()
110 ->CreateInterfaceFactory<mojom::BatteryMonitor>()); 116 ->CreateInterfaceFactory<mojom::BatteryMonitor>());
111 registry_.AddInterface( 117 registry_.AddInterface(
112 GetJavaInterfaceProvider()->CreateInterfaceFactory<mojom::NFCProvider>()); 118 GetJavaInterfaceProvider()->CreateInterfaceFactory<mojom::NFCProvider>());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 VibrationManagerImpl::Create(std::move(request)); 157 VibrationManagerImpl::Create(std::move(request));
152 } 158 }
153 #endif 159 #endif
154 160
155 void DeviceService::BindFingerprintRequest( 161 void DeviceService::BindFingerprintRequest(
156 const service_manager::BindSourceInfo& source_info, 162 const service_manager::BindSourceInfo& source_info,
157 mojom::FingerprintRequest request) { 163 mojom::FingerprintRequest request) {
158 Fingerprint::Create(std::move(request)); 164 Fingerprint::Create(std::move(request));
159 } 165 }
160 166
167 void DeviceService::BindMotionSensorRequest(
168 const service_manager::BindSourceInfo& source_info,
169 mojom::MotionSensorRequest request) {
170 #if defined(OS_ANDROID)
171 // On Android the device sensors implementations need to run on the UI thread
172 // to communicate to Java.
173 DeviceMotionHost::Create(std::move(request));
174 #else
175 // On platforms other than Android the device sensors implementations run on
176 // the IO thread.
177 if (io_task_runner_) {
178 io_task_runner_->PostTask(FROM_HERE, base::Bind(&DeviceMotionHost::Create,
179 base::Passed(&request)));
180 }
181 #endif // defined(OS_ANDROID)
182 }
183
161 void DeviceService::BindOrientationSensorRequest( 184 void DeviceService::BindOrientationSensorRequest(
162 const service_manager::BindSourceInfo& source_info, 185 const service_manager::BindSourceInfo& source_info,
163 mojom::OrientationSensorRequest request) { 186 mojom::OrientationSensorRequest request) {
164 #if defined(OS_ANDROID) 187 #if defined(OS_ANDROID)
165 // On Android the device sensors implementations need to run on the UI thread 188 // On Android the device sensors implementations need to run on the UI thread
166 // to communicate to Java. 189 // to communicate to Java.
167 DeviceOrientationHost::Create(std::move(request)); 190 DeviceOrientationHost::Create(std::move(request));
168 #else 191 #else
169 // On platforms other than Android the device sensors implementations run on 192 // On platforms other than Android the device sensors implementations run on
170 // the IO thread. 193 // the IO thread.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 java_interface_provider_.Bind(std::move(provider)); 275 java_interface_provider_.Bind(std::move(provider));
253 276
254 java_interface_provider_initialized_ = true; 277 java_interface_provider_initialized_ = true;
255 } 278 }
256 279
257 return &java_interface_provider_; 280 return &java_interface_provider_;
258 } 281 }
259 #endif 282 #endif
260 283
261 } // namespace device 284 } // namespace device
OLDNEW
« no previous file with comments | « services/device/device_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698