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 CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ | |
6 #define CONTENT_BROWSER_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 "content/public/browser/power_save_blocker.h" | |
17 | |
18 #if defined(OS_ANDROID) | |
19 #include "ui/android/view_android.h" | |
20 #endif // OS_ANDROID | |
21 | |
22 namespace content { | |
23 | |
24 class WebContents; | |
25 | |
26 class PowerSaveBlockerImpl : public PowerSaveBlocker { | |
27 public: | |
28 PowerSaveBlockerImpl( | |
29 PowerSaveBlockerType type, | |
30 Reason reason, | |
31 const std::string& description, | |
32 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | |
33 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner); | |
34 ~PowerSaveBlockerImpl() override; | |
35 | |
36 #if defined(OS_ANDROID) | |
37 // On Android, the kPowerSaveBlockPreventDisplaySleep type of | |
38 // PowerSaveBlocker should associated with a View, so the blocker can be | |
39 // removed by the platform. | |
40 void InitDisplaySleepBlocker( | |
41 const base::WeakPtr<ui::ViewAndroid>& view_android); | |
42 #endif | |
43 | |
44 private: | |
45 class Delegate; | |
46 | |
47 // Implementations of this class may need a second object with different | |
48 // lifetime than the RAII container, or additional storage. This member is | |
49 // here for that purpose. If not used, just define the class as an empty | |
50 // RefCounted (or RefCountedThreadSafe) like so to make it compile: | |
51 // class PowerSaveBlocker::Delegate | |
52 // : public base::RefCounted<PowerSaveBlocker::Delegate> { | |
53 // private: | |
54 // friend class base::RefCounted<Delegate>; | |
55 // ~Delegate() {} | |
56 // }; | |
57 scoped_refptr<Delegate> delegate_; | |
58 | |
59 #if defined(USE_X11) | |
60 // Since display sleep prevention also implies system suspend prevention, for | |
61 // the Linux FreeDesktop API case, there needs to be a second delegate to | |
62 // block system suspend when screen saver / display sleep is blocked. | |
63 scoped_refptr<Delegate> freedesktop_suspend_delegate_; | |
64 #endif | |
65 | |
66 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | |
67 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl); | |
70 }; | |
71 | |
72 } // namespace content | |
73 | |
74 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ | |
OLD | NEW |