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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/device/device_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/device/device_service.cc
diff --git a/services/device/device_service.cc b/services/device/device_service.cc
index f2a82c68abfae91dcd52688c4ce5ce66a283fcf7..ca19aa5cdaf91510201dc5f1bea6a0203241c752 100644
--- a/services/device/device_service.cc
+++ b/services/device/device_service.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
@@ -17,6 +18,7 @@
#include "mojo/public/cpp/system/message_pipe.h"
#include "services/device/fingerprint/fingerprint.h"
#include "services/device/power_monitor/power_monitor_message_broadcaster.h"
+#include "services/device/public/cpp/device_features.h"
#include "services/device/public/interfaces/battery_monitor.mojom.h"
#include "services/device/time_zone_monitor/time_zone_monitor.h"
#include "services/service_manager/public/cpp/bind_source_info.h"
@@ -88,6 +90,8 @@
void DeviceService::OnStart() {
registry_.AddInterface<mojom::Fingerprint>(base::Bind(
&DeviceService::BindFingerprintRequest, base::Unretained(this)));
+ registry_.AddInterface<mojom::MotionSensor>(base::Bind(
+ &DeviceService::BindMotionSensorRequest, base::Unretained(this)));
registry_.AddInterface<mojom::OrientationSensor>(base::Bind(
&DeviceService::BindOrientationSensorRequest, base::Unretained(this)));
registry_.AddInterface<mojom::OrientationAbsoluteSensor>(
@@ -98,8 +102,10 @@
registry_.AddInterface<mojom::ScreenOrientationListener>(
base::Bind(&DeviceService::BindScreenOrientationListenerRequest,
base::Unretained(this)));
- registry_.AddInterface<mojom::SensorProvider>(base::Bind(
- &DeviceService::BindSensorProviderRequest, base::Unretained(this)));
+ if (base::FeatureList::IsEnabled(features::kGenericSensor)) {
+ registry_.AddInterface<mojom::SensorProvider>(base::Bind(
+ &DeviceService::BindSensorProviderRequest, base::Unretained(this)));
+ }
registry_.AddInterface<mojom::TimeZoneMonitor>(base::Bind(
&DeviceService::BindTimeZoneMonitorRequest, base::Unretained(this)));
registry_.AddInterface<mojom::WakeLockProvider>(base::Bind(
@@ -156,6 +162,23 @@
const service_manager::BindSourceInfo& source_info,
mojom::FingerprintRequest request) {
Fingerprint::Create(std::move(request));
+}
+
+void DeviceService::BindMotionSensorRequest(
+ const service_manager::BindSourceInfo& source_info,
+ mojom::MotionSensorRequest request) {
+#if defined(OS_ANDROID)
+ // On Android the device sensors implementations need to run on the UI thread
+ // to communicate to Java.
+ DeviceMotionHost::Create(std::move(request));
+#else
+ // On platforms other than Android the device sensors implementations run on
+ // the IO thread.
+ if (io_task_runner_) {
+ io_task_runner_->PostTask(FROM_HERE, base::Bind(&DeviceMotionHost::Create,
+ base::Passed(&request)));
+ }
+#endif // defined(OS_ANDROID)
}
void DeviceService::BindOrientationSensorRequest(
« 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