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

Unified Diff: base/critical_closure_ios.mm

Issue 257003007: Introduce a new framework for back-and-forth tracked/protected preferences migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: run cleanup directly if destination store wasn't altered (i.e. migration completed in previous run,… Created 6 years, 8 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
Index: base/critical_closure_ios.mm
diff --git a/base/critical_closure_ios.mm b/base/critical_closure_ios.mm
index d605cad0a20a5baf076672f07dd4427f43222220..9550f6bebd4f67e0a56d1f6bf2423c06a7341847 100644
--- a/base/critical_closure_ios.mm
+++ b/base/critical_closure_ios.mm
@@ -15,9 +15,10 @@ namespace {
// 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
// |base::ios::ScopedCriticalAction|.
+template <typename CallbackType>
class CriticalClosure : public base::RefCountedThreadSafe<CriticalClosure> {
public:
- explicit CriticalClosure(base::Closure* closure) : closure_(closure) {
+ explicit CriticalClosure(CallbackType* closure) : closure_(closure) {
}
void Run() {
Bernhard Bauer 2014/04/30 09:31:05 Hm, this class only implements an argumentless Run
gab 2014/04/30 14:32:53 Ah good point, I actually made the template more s
@@ -30,7 +31,7 @@ class CriticalClosure : public base::RefCountedThreadSafe<CriticalClosure> {
virtual ~CriticalClosure() {}
base::ios::ScopedCriticalAction criticial_action_;
Bernhard Bauer 2014/04/30 09:31:05 If you want to clean this up a bit, it should be n
gab 2014/04/30 14:32:53 Done.
- scoped_ptr<base::Closure> closure_;
+ scoped_ptr<CallbackType> closure_;
Bernhard Bauer 2014/04/30 09:31:05 Oh, and this could probably also directly own the
gab 2014/04/30 14:32:53 Done, and also removed refcounting (whose only pur
DISALLOW_COPY_AND_ASSIGN(CriticalClosure);
};
@@ -39,10 +40,11 @@ class CriticalClosure : public base::RefCountedThreadSafe<CriticalClosure> {
namespace base {
-base::Closure MakeCriticalClosure(const base::Closure& closure) {
+template <typename CallbackType>
+CallbackType MakeCriticalClosure(const CallbackType& closure) {
DCHECK([[UIDevice currentDevice] isMultitaskingSupported]);
scoped_refptr<CriticalClosure> critical_closure(
- new CriticalClosure(new base::Closure(closure)));
+ new CriticalClosure(new CallbackType(closure)));
return base::Bind(&CriticalClosure::Run, critical_closure.get());
}

Powered by Google App Engine
This is Rietveld 408576698