Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / content / browser / power_save_blocker_impl.h
bloba30422646fe05e971866c6160a4ee26fda96f051
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.
5 #ifndef CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_
6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "content/public/browser/power_save_blocker.h"
13 namespace content {
15 class WebContents;
17 class PowerSaveBlockerImpl : public PowerSaveBlocker {
18 public:
19 PowerSaveBlockerImpl(PowerSaveBlockerType type,
20 Reason reason,
21 const std::string& description);
22 ~PowerSaveBlockerImpl() override;
24 #if defined(OS_ANDROID)
25 // In Android platform, the kPowerSaveBlockPreventDisplaySleep type of
26 // PowerSaveBlocker should associated with a WebContents, so the blocker
27 // could be removed by platform if the WebContents is hidden.
28 void InitDisplaySleepBlocker(WebContents* web_contents);
29 #endif
31 private:
32 class Delegate;
34 // Implementations of this class may need a second object with different
35 // lifetime than the RAII container, or additional storage. This member is
36 // here for that purpose. If not used, just define the class as an empty
37 // RefCounted (or RefCountedThreadSafe) like so to make it compile:
38 // class PowerSaveBlocker::Delegate
39 // : public base::RefCounted<PowerSaveBlocker::Delegate> {
40 // private:
41 // friend class base::RefCounted<Delegate>;
42 // ~Delegate() {}
43 // };
44 scoped_refptr<Delegate> delegate_;
46 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl);
49 } // namespace content
51 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_