OLD | NEW |
---|---|
(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 BASE_IOS_SCOPED_CRITICAL_ACTION_H_ | |
6 #define BASE_IOS_SCOPED_CRITICAL_ACTION_H_ | |
7 | |
8 #include "base/synchronization/lock.h" | |
9 | |
10 namespace base { | |
11 namespace ios { | |
12 | |
13 // This class attempts to allow the application to continue to run for a period | |
14 // of time after it transitions to the background. The construction of an | |
15 // instance of this class marks the beginning of a task that needs background | |
16 // running time when the application is moved to the background and the | |
17 // destruction marks the end of such a task. | |
18 // | |
19 // Note there is no guarantee that the task will continue to finish when the | |
20 // application is moved to the background. | |
21 // | |
22 // This class should be used at times where leaving a task unfinished might be | |
23 // detrimental to user experience. For example, it should be used to ensure that | |
24 // the application has enough time to save important data or at least attempt to | |
25 // save such data. | |
26 class ScopedCriticalAction { | |
27 public: | |
28 ScopedCriticalAction(); | |
29 ~ScopedCriticalAction(); | |
30 | |
31 private: | |
32 // Informs the OS that the background task has completed. | |
33 void EndBackgroundTask(); | |
34 // |UIBackgroundTaskIdentifier| returned by | |
Mark Mentovai
2012/08/01 13:50:42
Blank line before this, so EndBackgroundTask() app
| |
35 // |beginBackgroundTaskWithExpirationHandler:| when marking the beginning of | |
36 // a long-running background task. It is defined as an |unsigned int| instead | |
37 // of a |UIBackgroundTaskIdentifier| so this class can be used in .cc files. | |
Mark Mentovai
2012/08/01 13:50:42
This comment suffices.
| |
38 unsigned int background_task_id_; | |
39 Lock background_task_id_lock_; | |
40 | |
41 DISALLOW_COPY_AND_ASSIGN(ScopedCriticalAction); | |
42 }; | |
43 | |
44 } // namespace ios | |
45 } // namespace base | |
46 | |
47 #endif // BASE_IOS_SCOPED_CRITICAL_ACTION_H_ | |
OLD | NEW |