| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_IMPL_H_ | |
| 6 #define DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_IMPL_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/sequenced_task_runner.h" | |
| 14 #include "base/single_thread_task_runner.h" | |
| 15 #include "build/build_config.h" | |
| 16 #include "device/power_save_blocker/power_save_blocker.h" | |
| 17 #include "device/power_save_blocker/power_save_blocker_export.h" | |
| 18 | |
| 19 #if defined(OS_ANDROID) | |
| 20 #include "ui/android/view_android.h" | |
| 21 #endif // OS_ANDROID | |
| 22 | |
| 23 namespace device { | |
| 24 | |
| 25 class WebContents; | |
| 26 | |
| 27 class PowerSaveBlockerImpl : public PowerSaveBlocker { | |
| 28 public: | |
| 29 PowerSaveBlockerImpl( | |
| 30 PowerSaveBlockerType type, | |
| 31 Reason reason, | |
| 32 const std::string& description, | |
| 33 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | |
| 34 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner); | |
| 35 ~PowerSaveBlockerImpl() override; | |
| 36 | |
| 37 #if defined(OS_ANDROID) | |
| 38 // On Android, the kPowerSaveBlockPreventDisplaySleep type of | |
| 39 // PowerSaveBlocker should associated with a View, so the blocker can be | |
| 40 // removed by the platform. | |
| 41 DEVICE_POWER_SAVE_BLOCKER_EXPORT void InitDisplaySleepBlocker( | |
| 42 const base::WeakPtr<ui::ViewAndroid>& view_android); | |
| 43 #endif | |
| 44 | |
| 45 private: | |
| 46 class Delegate; | |
| 47 | |
| 48 // Implementations of this class may need a second object with different | |
| 49 // lifetime than the RAII container, or additional storage. This member is | |
| 50 // here for that purpose. If not used, just define the class as an empty | |
| 51 // RefCounted (or RefCountedThreadSafe) like so to make it compile: | |
| 52 // class PowerSaveBlocker::Delegate | |
| 53 // : public base::RefCounted<PowerSaveBlocker::Delegate> { | |
| 54 // private: | |
| 55 // friend class base::RefCounted<Delegate>; | |
| 56 // ~Delegate() {} | |
| 57 // }; | |
| 58 scoped_refptr<Delegate> delegate_; | |
| 59 | |
| 60 #if defined(USE_X11) | |
| 61 // Since display sleep prevention also implies system suspend prevention, for | |
| 62 // the Linux FreeDesktop API case, there needs to be a second delegate to | |
| 63 // block system suspend when screen saver / display sleep is blocked. | |
| 64 scoped_refptr<Delegate> freedesktop_suspend_delegate_; | |
| 65 #endif | |
| 66 | |
| 67 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | |
| 68 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl); | |
| 71 }; | |
| 72 | |
| 73 } // namespace device | |
| 74 | |
| 75 #endif // DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_IMPL_H_ | |
| OLD | NEW |