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

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

Issue 11784016: chromeos: Block system suspend while uploading files to Drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 | Annotate | Revision Log
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_BROWSER_POWER_SAVE_BLOCKER_H_
6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "content/common/content_export.h"
14
15 namespace content {
16
17 // A RAII-style class to block the system from entering low-power (sleep) mode.
18 // This class is thread-safe; it may be constructed and deleted on any thread.
19 class CONTENT_EXPORT PowerSaveBlocker {
20 public:
21 enum PowerSaveBlockerType {
22 // Prevent the application from being suspended. On some platforms, apps may
23 // be suspended when they are not visible to the user. This type of block
24 // requests that the app continue to run in that case, and on all platforms
25 // prevents the system from sleeping.
26 // Example use cases: downloading a file, playing audio.
27 kPowerSaveBlockPreventAppSuspension,
28
29 // Prevent the display from going to sleep. This also has the side effect of
30 // preventing the system from sleeping, but does not necessarily prevent the
31 // app from being suspended on some platforms if the user hides it.
32 // Example use case: playing video.
33 kPowerSaveBlockPreventDisplaySleep,
34 };
35
36 // Pass in the type of power save blocking desired. If multiple types of
37 // blocking are desired, instantiate one PowerSaveBlocker for each type.
38 // |reason| may be provided to the underlying system APIs on some platforms.
39 PowerSaveBlocker(PowerSaveBlockerType type, const std::string& reason);
40 ~PowerSaveBlocker();
41
42 private:
43 class Delegate;
44
45 // Implementations of this class may need a second object with different
46 // lifetime than the RAII container, or additional storage. This member is
47 // here for that purpose. If not used, just define the class as an empty
48 // RefCounted (or RefCountedThreadSafe) like so to make it compile:
49 // class PowerSaveBlocker::Delegate
50 // : public base::RefCounted<PowerSaveBlocker::Delegate> {
51 // private:
52 // friend class base::RefCounted<Delegate>;
53 // ~Delegate() {}
54 // };
55 scoped_refptr<Delegate> delegate_;
56
57 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
58 };
59
60 } // namespace content
61
62 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_
OLDNEW
« no previous file with comments | « content/browser/download/drag_download_file_browsertest.cc ('k') | content/browser/power_save_blocker_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698