OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 module device.mojom; | 5 module device.mojom; |
6 | 6 |
7 import "device/wake_lock/public/interfaces/wake_lock_service.mojom"; | 7 import "device/wake_lock/public/interfaces/wake_lock_service.mojom"; |
8 | 8 |
| 9 // TODO(heke): Switch PowerSaveBlocker to use WakeLockType and WakeLockReason |
| 10 // below once it has no direct consumers. |
| 11 enum WakeLockType { |
| 12 // Prevent the application from being suspended. On some platforms, apps may |
| 13 // be suspended when they are not visible to the user. This type of block |
| 14 // requests that the app continue to run in that case, and on all platforms |
| 15 // prevents the system from sleeping. |
| 16 // Example use cases: downloading a file, playing audio. |
| 17 PreventAppSuspension = 0, |
| 18 |
| 19 // Prevent the display from going to sleep. This also has the side effect of |
| 20 // preventing the system from sleeping, but does not necessarily prevent the |
| 21 // app from being suspended on some platforms if the user hides it. |
| 22 // Example use case: playing video. |
| 23 PreventDisplaySleep = 1, |
| 24 }; |
| 25 |
| 26 enum WakeLockReason { |
| 27 // Audio is being played. |
| 28 ReasonAudioPlayback = 0, |
| 29 // Video is being played. |
| 30 ReasonVideoPlayback = 1, |
| 31 // WakeLock for some other reason. |
| 32 ReasonOther = 2, |
| 33 }; |
| 34 |
9 // Context in which WakeLockService instances operate. | 35 // Context in which WakeLockService instances operate. |
10 interface WakeLockContext { | 36 interface WakeLockContext { |
11 // Gets a WakeLockService within this context. | 37 // Gets a WakeLockService within this context. |
12 GetWakeLock(WakeLockService& wake_lock); | 38 GetWakeLock(WakeLockType type, WakeLockReason reason, string description, Wake
LockService& wake_lock); |
13 | 39 |
14 // Test-only method that returns whethere a wake lock is currently active | 40 // Test-only method that returns whethere a wake lock is currently active |
15 // within this context. | 41 // within this context. |
16 HasWakeLockForTests() => (bool result); | 42 HasWakeLockForTests() => (bool result); |
17 }; | 43 }; |
OLD | NEW |