Rename async upload/readback queries to avoid mix-ups
[chromium-blink-merge.git] / base / ios / scoped_critical_action.h
blob660a83ad024c00d4f9e7444133aadf3630f9dbf6
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.
5 #ifndef BASE_IOS_SCOPED_CRITICAL_ACTION_H_
6 #define BASE_IOS_SCOPED_CRITICAL_ACTION_H_
8 #include "base/synchronization/lock.h"
10 namespace base {
11 namespace ios {
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.
19 // Note there is no guarantee that the task will continue to finish when the
20 // application is moved to the background.
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();
31 private:
32 // Informs the OS that the background task has completed.
33 void EndBackgroundTask();
35 // |UIBackgroundTaskIdentifier| returned by
36 // |beginBackgroundTaskWithExpirationHandler:| when marking the beginning of
37 // a long-running background task. It is defined as an |unsigned int| instead
38 // of a |UIBackgroundTaskIdentifier| so this class can be used in .cc files.
39 unsigned int background_task_id_;
40 Lock background_task_id_lock_;
42 DISALLOW_COPY_AND_ASSIGN(ScopedCriticalAction);
45 } // namespace ios
46 } // namespace base
48 #endif // BASE_IOS_SCOPED_CRITICAL_ACTION_H_