Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ | 5 #ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ |
| 6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ | 6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/single_thread_task_runner.h" | |
| 13 #include "device/power_save_blocker/power_save_blocker.h" | |
| 9 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" | 14 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" |
| 10 #include "mojo/public/cpp/bindings/interface_request.h" | 15 #include "device/wake_lock/wake_lock_service_context.h" |
| 16 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 17 #include "ui/gfx/native_widget_types.h" | |
| 11 | 18 |
| 12 namespace device { | 19 namespace device { |
| 13 | 20 |
| 14 class WakeLockServiceContext; | |
| 15 | |
| 16 class WakeLockServiceImpl : public mojom::WakeLockService { | 21 class WakeLockServiceImpl : public mojom::WakeLockService { |
| 17 public: | 22 public: |
| 18 explicit WakeLockServiceImpl(WakeLockServiceContext* context); | 23 WakeLockServiceImpl( |
| 24 mojom::WakeLockServiceRequest request, | |
| 25 device::PowerSaveBlocker::PowerSaveBlockerType type, | |
| 26 device::PowerSaveBlocker::Reason reason, | |
| 27 const std::string& description, | |
| 28 int context_id, | |
| 29 WakeLockContextCallback native_view_getter, | |
| 30 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); | |
| 19 ~WakeLockServiceImpl() override; | 31 ~WakeLockServiceImpl() override; |
| 20 | 32 |
| 21 // WakeLockSevice implementation. | 33 // WakeLockSevice implementation. |
| 22 void RequestWakeLock() override; | 34 void RequestWakeLock() override; |
| 23 void CancelWakeLock() override; | 35 void CancelWakeLock() override; |
| 36 void AddClient(mojom::WakeLockServiceRequest request) override; | |
| 37 void HasWakeLockForTests( | |
| 38 const HasWakeLockForTestsCallback& callback) override; | |
| 24 | 39 |
| 25 private: | 40 private: |
| 26 // Will outlive this instance. | 41 void UpdateWakeLock(); |
| 27 WakeLockServiceContext* context_; | 42 void CreateWakeLock(); |
| 28 bool wake_lock_request_outstanding_; | 43 void RemoveWakeLock(); |
| 44 void OnConnectionError(); | |
| 45 | |
| 46 device::PowerSaveBlocker::PowerSaveBlockerType type_; | |
| 47 device::PowerSaveBlocker::Reason reason_; | |
| 48 std::unique_ptr<std::string> description_; | |
| 49 int num_lock_requests_; | |
| 50 | |
| 51 #if defined(OS_ANDROID) | |
| 52 int context_id_; | |
| 53 WakeLockContextCallback native_view_getter_; | |
| 54 #endif | |
| 55 | |
| 56 scoped_refptr<base::SequencedTaskRunner> main_task_runner_; | |
| 57 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | |
| 58 | |
| 59 // The actual power save blocker for screen. | |
| 60 std::unique_ptr<PowerSaveBlocker> wake_lock_; | |
| 61 | |
| 62 mojo::BindingSet<mojom::WakeLockService, std::unique_ptr<bool>> binding_set_; | |
|
Ken Rockot(use gerrit already)
2017/05/05 17:55:31
Please document the meaning of the context here in
ke.he
2017/05/06 03:08:44
Done.
| |
| 29 | 63 |
| 30 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl); | 64 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl); |
| 31 }; | 65 }; |
| 32 | 66 |
| 33 } // namespace device | 67 } // namespace device |
| 34 | 68 |
| 35 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ | 69 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ |
| OLD | NEW |