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

Side by Side Diff: base/critical_closure.h

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: fix some tests -- more to come Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_CRITICAL_CLOSURE_H_ 5 #ifndef BASE_CRITICAL_CLOSURE_H_
6 #define BASE_CRITICAL_CLOSURE_H_ 6 #define BASE_CRITICAL_CLOSURE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 9
10 namespace base { 10 namespace base {
11 11
12 // Returns a closure that will continue to run for a period of time when the 12 // Returns a closure (which may return a result, but must not require any extra
13 // arguments) that will continue to run for a period of time when the
13 // application goes to the background if possible on platforms where 14 // application goes to the background if possible on platforms where
14 // applications don't execute while backgrounded, otherwise the original task is 15 // applications don't execute while backgrounded, otherwise the original task is
15 // returned. 16 // returned.
16 // 17 //
17 // Example: 18 // Example:
18 // file_message_loop_proxy_->PostTask( 19 // file_message_loop_proxy_->PostTask(
19 // FROM_HERE, 20 // FROM_HERE,
20 // MakeCriticalClosure(base::Bind(&WriteToDiskTask, path_, data))); 21 // MakeCriticalClosure(base::Bind(&WriteToDiskTask, path_, data)));
21 // 22 //
22 // Note new closures might be posted in this closure. If the new closures need 23 // 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 // background running time, |MakeCriticalClosure| should be applied on them
24 // before posting. 25 // before posting.
25 #if defined(OS_IOS) 26 #if defined(OS_IOS)
26 base::Closure MakeCriticalClosure(const base::Closure& closure); 27 template <typename R>
28 Callback<R(void)> MakeCriticalClosure(const Callback<R(void)>& closure);
27 #else 29 #else
28 inline base::Closure MakeCriticalClosure(const base::Closure& closure) { 30 template <typename R>
31 inline Callback<R(void)> MakeCriticalClosure(const Callback<R(void)>& closure) {
29 // No-op for platforms where the application does not need to acquire 32 // 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. 33 // background time for closures to finish when it goes into the background.
31 return closure; 34 return closure;
32 } 35 }
33 #endif // !defined(OS_IOS) 36 #endif // !defined(OS_IOS)
34 37
35 } // namespace base 38 } // namespace base
36 39
37 #endif // BASE_CRITICAL_CLOSURE_H_ 40 #endif // BASE_CRITICAL_CLOSURE_H_
OLDNEW
« no previous file with comments | « no previous file | base/critical_closure_ios.mm » ('j') | base/files/important_file_writer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698