Index: device/wake_lock/wake_lock_service_impl.h |
diff --git a/device/wake_lock/wake_lock_service_impl.h b/device/wake_lock/wake_lock_service_impl.h |
index c66ec8d1a8fe73c2f111791f007c6f6afb35eafa..acc68331a0038b428d6a14181cabf9879af4e60d 100644 |
--- a/device/wake_lock/wake_lock_service_impl.h |
+++ b/device/wake_lock/wake_lock_service_impl.h |
@@ -5,27 +5,66 @@ |
#ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ |
#define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ |
+#include <map> |
+ |
#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "device/power_save_blocker/power_save_blocker.h" |
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" |
-#include "mojo/public/cpp/bindings/interface_request.h" |
+#include "mojo/public/cpp/bindings/binding_set.h" |
+#include "ui/gfx/native_widget_types.h" |
namespace device { |
-class WakeLockServiceContext; |
+// Callback that maps a context ID to the NativeView associated with |
+// that context. This callback is provided to the Device Service by its |
+// embedder. |
+using WakeLockContextCallback = base::Callback<gfx::NativeView(int)>; |
class WakeLockServiceImpl : public mojom::WakeLockService { |
public: |
- explicit WakeLockServiceImpl(WakeLockServiceContext* context); |
+ WakeLockServiceImpl( |
+ mojom::WakeLockServiceRequest request, |
+ device::PowerSaveBlocker::PowerSaveBlockerType type, |
+ device::PowerSaveBlocker::Reason reason, |
+ const std::string& description, |
+ int context_id, |
+ WakeLockContextCallback native_view_getter, |
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); |
~WakeLockServiceImpl() override; |
// WakeLockSevice implementation. |
void RequestWakeLock() override; |
void CancelWakeLock() override; |
+ void AddClient(mojom::WakeLockServiceRequest request) override; |
+ void HasWakeLockForTests( |
+ const HasWakeLockForTestsCallback& callback) override; |
private: |
- // Will outlive this instance. |
- WakeLockServiceContext* context_; |
- bool wake_lock_request_outstanding_; |
+ void UpdateWakeLock(); |
+ void CreateWakeLock(); |
+ void RemoveWakeLock(); |
+ void OnConnectionError(); |
+ |
+ device::PowerSaveBlocker::PowerSaveBlockerType type_; |
+ device::PowerSaveBlocker::Reason reason_; |
+ std::unique_ptr<std::string> description_; |
+ int num_lock_requests_; |
+ |
+#if defined(OS_ANDROID) |
+ int context_id_; |
+ WakeLockContextCallback native_view_getter_; |
+#endif |
+ |
+ scoped_refptr<base::SequencedTaskRunner> main_task_runner_; |
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
+ |
+ // The actual power save blocker for screen. |
+ std::unique_ptr<PowerSaveBlocker> wake_lock_; |
+ |
+ mojo::BindingSet<mojom::WakeLockService, int> binding_set_; |
+ std::map<int, bool> outstandings_; |
+ std::map<int, mojo::BindingId> binding_ids_; |
DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl); |
}; |