Index: base/ios/scoped_critical_action.h |
diff --git a/base/ios/scoped_critical_action.h b/base/ios/scoped_critical_action.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2bebaecebb70bddf36fd3b553ba9992a96e860dc |
--- /dev/null |
+++ b/base/ios/scoped_critical_action.h |
@@ -0,0 +1,41 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_IOS_SCOPED_CRITICAL_ACTION_H_ |
+#define BASE_IOS_SCOPED_CRITICAL_ACTION_H_ |
+ |
+#include "base/synchronization/lock.h" |
+ |
+namespace base { |
+namespace ios { |
+ |
+// This class allows the application to continue to run for a period of time |
+// after it transitions to the background. The construction of an instance of |
+// this class marks the beginning of a task that needs background running time |
+// when the application is moved to the background and the destruction marks the |
+// end of such a task. |
+// |
+// This class should be used at times where leaving a task unfinished might be |
+// detrimental to user experience. For example, it should be used to ensure that |
+// the application has enough time to save important data or at least attempt to |
+// save such data. |
+class ScopedCriticalAction { |
+ public: |
+ ScopedCriticalAction(); |
+ ~ScopedCriticalAction(); |
+ |
+ private: |
+ // Informs the OS that the background task has completed. |
+ void EndBackgroundTask(); |
+ |
+ unsigned int background_task_id_; |
Mark Mentovai
2012/07/31 23:16:33
What does this do? Comment it.
Chen Yu
2012/08/01 11:26:13
Done.
|
+ Lock id_lock_; |
Mark Mentovai
2012/07/31 23:16:33
What does this protect? Comment it. If it protects
Chen Yu
2012/08/01 11:26:13
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedCriticalAction); |
+}; |
+ |
+} // namespace ios |
+} // namespace base |
+ |
+#endif // BASE_IOS_SCOPED_CRITICAL_ACTION_H_ |