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_CRITICAL_CLOSURE_H_ |
| 6 #define BASE_CRITICAL_CLOSURE_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 |
| 10 namespace base { |
| 11 |
| 12 // Returns a closure that will continue to run for a period of time when the |
| 13 // application goes to the background if possible on platforms where |
| 14 // applications don't execute while backgrounded, otherwise the original task is |
| 15 // returned. |
| 16 // |
| 17 // Example: |
| 18 // file_message_loop_proxy_->PostTask( |
| 19 // FROM_HERE, |
| 20 // MakeCriticalClosure(base::Bind(&WriteToDiskTask, path_, data))); |
| 21 // |
| 22 // Note new closures might be posted in this closure. If the new closures need |
| 23 // background running time, |MakeCriticalClosure| should be applied on them |
| 24 // before posting. |
| 25 #if defined(OS_IOS) |
| 26 base::Closure MakeCriticalClosure(const base::Closure& closure); |
| 27 #else |
| 28 base::Closure MakeCriticalClosure(const base::Closure& closure) { |
| 29 // No-op for platforms where the application does not need to acquire |
| 30 // background time for closures to finish when it goes into the background. |
| 31 return closure; |
| 32 } |
| 33 #endif // !defined(OS_IOS) |
| 34 |
| 35 } // namespace base |
| 36 |
| 37 #endif // BASE_CRITICAL_CLOSURE_H_ |
OLD | NEW |