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

Unified Diff: content/public/browser/browser_thread.h

Issue 2842493004: Add OnceCallback support to PostTaskAndReplyWithResult (Closed)
Patch Set: s/can not/cannot/ Created 3 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
« no previous file with comments | « components/drive/drive_api_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/browser_thread.h
diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h
index fe82220c1e58fd5c0ed6c5c3f234efe46c276afe..8422091d3024087800f8365e034083b05cc3a6f0 100644
--- a/content/public/browser/browser_thread.h
+++ b/content/public/browser/browser_thread.h
@@ -142,14 +142,32 @@ class CONTENT_EXPORT BrowserThread {
static bool PostTaskAndReplyWithResult(
ID identifier,
const tracked_objects::Location& from_here,
- base::Callback<ReturnType()> task,
- base::Callback<void(ReplyArgType)> reply) {
+ base::OnceCallback<ReturnType()> task,
+ base::OnceCallback<void(ReplyArgType)> reply) {
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
GetTaskRunnerForThread(identifier);
return base::PostTaskAndReplyWithResult(task_runner.get(), from_here,
std::move(task), std::move(reply));
}
+ // Callback version of PostTaskAndReplyWithResult above.
+ // Though RepeatingCallback is convertible to OnceCallback, we need this since
+ // we cannot use template deduction and object conversion at once on the
+ // overload resolution.
+ // TODO(crbug.com/714018): Update all callers of the Callback version to use
+ // OnceCallback.
+ template <typename ReturnType, typename ReplyArgType>
+ static bool PostTaskAndReplyWithResult(
+ ID identifier,
+ const tracked_objects::Location& from_here,
+ base::Callback<ReturnType()> task,
+ base::Callback<void(ReplyArgType)> reply) {
+ return PostTaskAndReplyWithResult(
+ identifier, from_here,
+ base::OnceCallback<ReturnType()>(std::move(task)),
+ base::OnceCallback<void(ReplyArgType)>(std::move(reply)));
+ }
+
template <class T>
static bool DeleteSoon(ID identifier,
const tracked_objects::Location& from_here,
« no previous file with comments | « components/drive/drive_api_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698