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

Side by Side Diff: base/task_runner_util.h

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « base/task_runner.h ('k') | base/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_TASK_RUNNER_UTIL_H_ 5 #ifndef BASE_TASK_RUNNER_UTIL_H_
6 #define BASE_TASK_RUNNER_UTIL_H_ 6 #define BASE_TASK_RUNNER_UTIL_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback_internal.h" 10 #include "base/callback_internal.h"
(...skipping 29 matching lines...) Expand all
40 // When you have these methods 40 // When you have these methods
41 // 41 //
42 // R DoWorkAndReturn(); 42 // R DoWorkAndReturn();
43 // void Callback(const R& result); 43 // void Callback(const R& result);
44 // 44 //
45 // and want to call them in a PostTaskAndReply kind of fashion where the 45 // and want to call them in a PostTaskAndReply kind of fashion where the
46 // result of DoWorkAndReturn is passed to the Callback, you can use 46 // result of DoWorkAndReturn is passed to the Callback, you can use
47 // PostTaskAndReplyWithResult as in this example: 47 // PostTaskAndReplyWithResult as in this example:
48 // 48 //
49 // PostTaskAndReplyWithResult( 49 // PostTaskAndReplyWithResult(
50 // target_thread_.message_loop_proxy(), 50 // target_thread_.task_runner(),
51 // FROM_HERE, 51 // FROM_HERE,
52 // Bind(&DoWorkAndReturn), 52 // Bind(&DoWorkAndReturn),
53 // Bind(&Callback)); 53 // Bind(&Callback));
54 template <typename TaskReturnType, typename ReplyArgType> 54 template <typename TaskReturnType, typename ReplyArgType>
55 bool PostTaskAndReplyWithResult( 55 bool PostTaskAndReplyWithResult(
56 TaskRunner* task_runner, 56 TaskRunner* task_runner,
57 const tracked_objects::Location& from_here, 57 const tracked_objects::Location& from_here,
58 const Callback<TaskReturnType(void)>& task, 58 const Callback<TaskReturnType(void)>& task,
59 const Callback<void(ReplyArgType)>& reply) { 59 const Callback<void(ReplyArgType)>& reply) {
60 TaskReturnType* result = new TaskReturnType(); 60 TaskReturnType* result = new TaskReturnType();
61 return task_runner->PostTaskAndReply( 61 return task_runner->PostTaskAndReply(
62 from_here, 62 from_here,
63 base::Bind(&internal::ReturnAsParamAdapter<TaskReturnType>, task, 63 base::Bind(&internal::ReturnAsParamAdapter<TaskReturnType>, task,
64 result), 64 result),
65 base::Bind(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>, reply, 65 base::Bind(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>, reply,
66 base::Owned(result))); 66 base::Owned(result)));
67 } 67 }
68 68
69 } // namespace base 69 } // namespace base
70 70
71 #endif // BASE_TASK_RUNNER_UTIL_H_ 71 #endif // BASE_TASK_RUNNER_UTIL_H_
OLDNEW
« no previous file with comments | « base/task_runner.h ('k') | base/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698