Index: services/device/device_service.cc |
diff --git a/services/device/device_service.cc b/services/device/device_service.cc |
index f9bd085c75ac674dbeb17aecd383a8b1cc2510ea..1a971c19eab6944447c3eec71b29da4892338bc7 100644 |
--- a/services/device/device_service.cc |
+++ b/services/device/device_service.cc |
@@ -9,11 +9,13 @@ |
#include "base/memory/weak_ptr.h" |
#include "base/single_thread_task_runner.h" |
#include "base/threading/thread_task_runner_handle.h" |
+#include "device/wake_lock/wake_lock_context_provider.h" |
#include "services/device/fingerprint/fingerprint.h" |
#include "services/device/power_monitor/power_monitor_message_broadcaster.h" |
#include "services/device/time_zone_monitor/time_zone_monitor.h" |
#include "services/service_manager/public/cpp/connection.h" |
#include "services/service_manager/public/cpp/interface_registry.h" |
+#include "ui/gfx/native_widget_types.h" |
#if defined(OS_ANDROID) |
#include "services/device/android/register_jni.h" |
@@ -22,25 +24,44 @@ |
namespace device { |
+#if defined(OS_ANDROID) |
std::unique_ptr<service_manager::Service> CreateDeviceService( |
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { |
-#if defined(OS_ANDROID) |
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
+ WakeLockContextCallback wake_lock_context_callback) { |
dcheng
2017/03/17 06:55:26
Nit: std::move() the callback if you want to pass
blundell
2017/03/17 12:28:22
Done.
|
if (!EnsureJniRegistered()) { |
DLOG(ERROR) << "Failed to register JNI for Device Service"; |
return nullptr; |
} |
-#endif |
return base::MakeUnique<DeviceService>(std::move(file_task_runner), |
+ std::move(io_task_runner), |
dcheng
2017/03/17 06:55:26
Nit: #include <utility> for std::move
blundell
2017/03/17 12:28:22
Done.
|
+ wake_lock_context_callback); |
+} |
+#else |
+std::unique_ptr<service_manager::Service> CreateDeviceService( |
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { |
+ return base::MakeUnique<DeviceService>(std::move(file_task_runner), |
std::move(io_task_runner)); |
} |
+#endif |
+#if defined(OS_ANDROID) |
+DeviceService::DeviceService( |
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
+ WakeLockContextCallback wake_lock_context_callback) |
+ : file_task_runner_(std::move(file_task_runner)), |
+ io_task_runner_(std::move(io_task_runner)), |
+ wake_lock_context_callback_(wake_lock_context_callback) {} |
+#else |
DeviceService::DeviceService( |
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) |
: file_task_runner_(std::move(file_task_runner)), |
io_task_runner_(std::move(io_task_runner)) {} |
+#endif |
DeviceService::~DeviceService() {} |
@@ -52,6 +73,7 @@ bool DeviceService::OnConnect(const service_manager::ServiceInfo& remote_info, |
registry->AddInterface<mojom::PowerMonitor>(this); |
registry->AddInterface<mojom::ScreenOrientationListener>(this); |
registry->AddInterface<mojom::TimeZoneMonitor>(this); |
+ registry->AddInterface<mojom::WakeLockContextProvider>(this); |
return true; |
} |
@@ -88,4 +110,10 @@ void DeviceService::Create(const service_manager::Identity& remote_identity, |
time_zone_monitor_->Bind(std::move(request)); |
} |
+void DeviceService::Create(const service_manager::Identity& remote_identity, |
+ mojom::WakeLockContextProviderRequest request) { |
+ WakeLockContextProvider::Create(std::move(request), file_task_runner_, |
+ wake_lock_context_callback_); |
+} |
+ |
} // namespace device |