summaryrefslogtreecommitdiff
path: root/base/critical_closure.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/critical_closure.h')
-rw-r--r--base/critical_closure.h27
1 files changed, 9 insertions, 18 deletions
diff --git a/base/critical_closure.h b/base/critical_closure.h
index 6ebd7afa50..1b10cde7ce 100644
--- a/base/critical_closure.h
+++ b/base/critical_closure.h
@@ -25,21 +25,15 @@ bool IsMultiTaskingSupported();
// This class wraps a closure so it can continue to run for a period of time
// when the application goes to the background by using
// |ios::ScopedCriticalAction|.
-template <typename R>
class CriticalClosure {
public:
- explicit CriticalClosure(const Callback<R(void)>& closure)
- : closure_(closure) {}
-
- ~CriticalClosure() {}
-
- R Run() {
- return closure_.Run();
- }
+ explicit CriticalClosure(const Closure& closure);
+ ~CriticalClosure();
+ void Run();
private:
ios::ScopedCriticalAction critical_action_;
- Callback<R(void)> closure_;
+ Closure closure_;
DISALLOW_COPY_AND_ASSIGN(CriticalClosure);
};
@@ -47,8 +41,7 @@ class CriticalClosure {
} // namespace internal
-// Returns a closure (which may return a result, but must not require any extra
-// arguments) that will continue to run for a period of time when the
+// Returns a closure that will continue to run for a period of time when the
// application goes to the background if possible on platforms where
// applications don't execute while backgrounded, otherwise the original task is
// returned.
@@ -62,15 +55,13 @@ class CriticalClosure {
// background running time, |MakeCriticalClosure| should be applied on them
// before posting.
#if defined(OS_IOS)
-template <typename R>
-Callback<R(void)> MakeCriticalClosure(const Callback<R(void)>& closure) {
+inline Closure MakeCriticalClosure(const Closure& closure) {
DCHECK(internal::IsMultiTaskingSupported());
- return base::Bind(&internal::CriticalClosure<R>::Run,
- Owned(new internal::CriticalClosure<R>(closure)));
+ return base::Bind(&internal::CriticalClosure::Run,
+ Owned(new internal::CriticalClosure(closure)));
}
#else // defined(OS_IOS)
-template <typename R>
-inline Callback<R(void)> MakeCriticalClosure(const Callback<R(void)>& closure) {
+inline Closure MakeCriticalClosure(const Closure& closure) {
// No-op for platforms where the application does not need to acquire
// background time for closures to finish when it goes into the background.
return closure;