Chromium Code Reviews| 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..c3e77aa4e668dae61d33477baf893f86d1fc4b0c 100644 |
| --- a/device/wake_lock/wake_lock_service_impl.h |
| +++ b/device/wake_lock/wake_lock_service_impl.h |
| @@ -5,27 +5,65 @@ |
| #ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ |
| #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ |
| +#include <memory> |
| + |
| #include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/single_thread_task_runner.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)>; |
|
blundell
2017/05/05 12:49:38
Just include wake_lock_service_context.h?
ke.he
2017/05/05 14:56:36
Done.
|
| 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, std::unique_ptr<bool>> binding_set_; |
| DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl); |
| }; |