- add sources.
[platform/framework/web/crosswalk.git] / src / content / public / browser / power_save_blocker.h
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 <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
13
14 namespace content {
15
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 {
19  public:
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,
27
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,
33   };
34
35   virtual ~PowerSaveBlocker() = 0;
36
37   // Pass in the type of power save blocking desired. If multiple types of
38   // blocking are desired, instantiate one PowerSaveBlocker for each type.
39   // |reason| may be provided to the underlying system APIs on some platforms.
40   static scoped_ptr<PowerSaveBlocker> Create(PowerSaveBlockerType type,
41                                              const std::string& reason);
42 };
43
44 }  // namespace content
45
46 #endif  // CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_H_