1 // Copyright (c) 2012 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_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_H_
6 #define CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
16 // A RAII-style class to block the system from entering low-power (sleep) mode.
17 // This class is thread-safe; it may be constructed and deleted on any thread.
18 class CONTENT_EXPORT PowerSaveBlocker
{
20 enum PowerSaveBlockerType
{
21 // Prevent the application from being suspended. On some platforms, apps may
22 // be suspended when they are not visible to the user. This type of block
23 // requests that the app continue to run in that case, and on all platforms
24 // prevents the system from sleeping.
25 // Example use cases: downloading a file, playing audio.
26 kPowerSaveBlockPreventAppSuspension
,
28 // Prevent the display from going to sleep. This also has the side effect of
29 // preventing the system from sleeping, but does not necessarily prevent the
30 // app from being suspended on some platforms if the user hides it.
31 // Example use case: playing video.
32 kPowerSaveBlockPreventDisplaySleep
,
35 // Reasons why power-saving features may be blocked.
37 // Audio is being played.
39 // Video is being played.
41 // Power-saving is blocked for some other reason.
45 virtual ~PowerSaveBlocker() = 0;
47 // Pass in the type of power save blocking desired. If multiple types of
48 // blocking are desired, instantiate one PowerSaveBlocker for each type.
49 // |reason| and |description| (a more-verbose, human-readable justification of
50 // the blocking) may be provided to the underlying system APIs on some
52 static scoped_ptr
<PowerSaveBlocker
> Create(PowerSaveBlockerType type
,
54 const std::string
& description
);
57 } // namespace content
59 #endif // CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_H_