OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ |
6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ | 6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/public/browser/power_save_blocker.h" | 11 #include "content/public/browser/power_save_blocker.h" |
12 #include "ui/gfx/native_widget_types.h" | |
13 | 12 |
14 namespace content { | 13 namespace content { |
15 | 14 |
| 15 class WebContents; |
| 16 |
16 class PowerSaveBlockerImpl : public PowerSaveBlocker { | 17 class PowerSaveBlockerImpl : public PowerSaveBlocker { |
17 public: | 18 public: |
18 PowerSaveBlockerImpl(PowerSaveBlockerType type, | 19 PowerSaveBlockerImpl(PowerSaveBlockerType type, |
19 Reason reason, | 20 Reason reason, |
20 const std::string& description); | 21 const std::string& description); |
21 ~PowerSaveBlockerImpl() override; | 22 ~PowerSaveBlockerImpl() override; |
22 | 23 |
23 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
24 // In Android platform, the kPowerSaveBlockPreventDisplaySleep type of | 25 // In Android platform, the kPowerSaveBlockPreventDisplaySleep type of |
25 // PowerSaveBlocker should associated with the ViewAndroid, | 26 // PowerSaveBlocker should associated with a WebContents, so the blocker |
26 // so the blocker could be removed by platform if the view isn't visble | 27 // could be removed by platform if the WebContents is hidden. |
27 void InitDisplaySleepBlocker(gfx::NativeView view_android); | 28 void InitDisplaySleepBlocker(WebContents* web_contents); |
28 #endif | 29 #endif |
29 | 30 |
30 private: | 31 private: |
31 class Delegate; | 32 class Delegate; |
32 | 33 |
33 // Implementations of this class may need a second object with different | 34 // Implementations of this class may need a second object with different |
34 // lifetime than the RAII container, or additional storage. This member is | 35 // lifetime than the RAII container, or additional storage. This member is |
35 // here for that purpose. If not used, just define the class as an empty | 36 // here for that purpose. If not used, just define the class as an empty |
36 // RefCounted (or RefCountedThreadSafe) like so to make it compile: | 37 // RefCounted (or RefCountedThreadSafe) like so to make it compile: |
37 // class PowerSaveBlocker::Delegate | 38 // class PowerSaveBlocker::Delegate |
38 // : public base::RefCounted<PowerSaveBlocker::Delegate> { | 39 // : public base::RefCounted<PowerSaveBlocker::Delegate> { |
39 // private: | 40 // private: |
40 // friend class base::RefCounted<Delegate>; | 41 // friend class base::RefCounted<Delegate>; |
41 // ~Delegate() {} | 42 // ~Delegate() {} |
42 // }; | 43 // }; |
43 scoped_refptr<Delegate> delegate_; | 44 scoped_refptr<Delegate> delegate_; |
44 | 45 |
45 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl); | 46 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl); |
46 }; | 47 }; |
47 | 48 |
48 } // namespace content | 49 } // namespace content |
49 | 50 |
50 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ | 51 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ |
OLD | NEW |