Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: content/public/browser/power_save_blocker.h

Issue 2075153002: Reland of 'Move content/browser/power_save_blocker to //device/power_save_blocker' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing libs for component mac Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/browser/BUILD.gn ('k') | content/public/browser/power_save_blocker_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_H_
6 #define CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/sequenced_task_runner.h"
13 #include "base/single_thread_task_runner.h"
14 #include "content/common/content_export.h"
15
16 namespace content {
17
18 // A RAII-style class to block the system from entering low-power (sleep) mode.
19 // This class is thread-safe; it may be constructed and deleted on any thread.
20 class CONTENT_EXPORT PowerSaveBlocker {
21 public:
22 enum PowerSaveBlockerType {
23 // Prevent the application from being suspended. On some platforms, apps may
24 // be suspended when they are not visible to the user. This type of block
25 // requests that the app continue to run in that case, and on all platforms
26 // prevents the system from sleeping.
27 // Example use cases: downloading a file, playing audio.
28 kPowerSaveBlockPreventAppSuspension,
29
30 // Prevent the display from going to sleep. This also has the side effect of
31 // preventing the system from sleeping, but does not necessarily prevent the
32 // app from being suspended on some platforms if the user hides it.
33 // Example use case: playing video.
34 kPowerSaveBlockPreventDisplaySleep,
35 };
36
37 // Reasons why power-saving features may be blocked.
38 enum Reason {
39 // Audio is being played.
40 kReasonAudioPlayback,
41 // Video is being played.
42 kReasonVideoPlayback,
43 // Power-saving is blocked for some other reason.
44 kReasonOther,
45 };
46
47 virtual ~PowerSaveBlocker() = 0;
48
49 // Pass in the type of power save blocking desired. If multiple types of
50 // blocking are desired, instantiate one PowerSaveBlocker for each type.
51 // |reason| and |description| (a more-verbose, human-readable justification of
52 // the blocking) may be provided to the underlying system APIs on some
53 // platforms.
54 static std::unique_ptr<PowerSaveBlocker> CreateWithTaskRunners(
55 PowerSaveBlockerType type,
56 Reason reason,
57 const std::string& description,
58 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
59 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_H_
OLDNEW
« no previous file with comments | « content/public/browser/BUILD.gn ('k') | content/public/browser/power_save_blocker_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698