Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: base/critical_closure.h

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/cpu_unittest.cc ('k') | base/critical_closure_internal_ios.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/critical_closure.h
diff --git a/base/critical_closure.h b/base/critical_closure.h
deleted file mode 100644
index 75e37045a774f888ea54ee470dc607519075c5c5..0000000000000000000000000000000000000000
--- a/base/critical_closure.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// 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_CRITICAL_CLOSURE_H_
-#define BASE_CRITICAL_CLOSURE_H_
-
-#include "base/callback.h"
-
-#if defined(OS_IOS)
-#include "base/bind.h"
-#include "base/ios/scoped_critical_action.h"
-#endif
-
-namespace base {
-
-namespace internal {
-
-#if defined(OS_IOS)
-// Returns true if multi-tasking is supported on this iOS device.
-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();
- }
-
- private:
- ios::ScopedCriticalAction critical_action_;
- Callback<R(void)> closure_;
-
- DISALLOW_COPY_AND_ASSIGN(CriticalClosure);
-};
-#endif // defined(OS_IOS)
-
-} // 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
-// application goes to the background if possible on platforms where
-// applications don't execute while backgrounded, otherwise the original task is
-// returned.
-//
-// Example:
-// file_task_runner_->PostTask(
-// FROM_HERE,
-// MakeCriticalClosure(base::Bind(&WriteToDiskTask, path_, data)));
-//
-// Note new closures might be posted in this closure. If the new closures need
-// 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) {
- DCHECK(internal::IsMultiTaskingSupported());
- return base::Bind(&internal::CriticalClosure<R>::Run,
- Owned(new internal::CriticalClosure<R>(closure)));
-}
-#else // defined(OS_IOS)
-template <typename R>
-inline Callback<R(void)> MakeCriticalClosure(const Callback<R(void)>& 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;
-}
-#endif // defined(OS_IOS)
-
-} // namespace base
-
-#endif // BASE_CRITICAL_CLOSURE_H_
« no previous file with comments | « base/cpu_unittest.cc ('k') | base/critical_closure_internal_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698