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

Unified Diff: remoting/client/plugin/pepper_main_thread_task_runner.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: s/base::ResetAndReturn/std::move/ Created 3 years, 9 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: remoting/client/plugin/pepper_main_thread_task_runner.cc
diff --git a/remoting/client/plugin/pepper_main_thread_task_runner.cc b/remoting/client/plugin/pepper_main_thread_task_runner.cc
index 078d5b812a27a3d115433fcef88c99d29977cbae..49ecaa32f615749e75593f0772dee3476fb4c83c 100644
--- a/remoting/client/plugin/pepper_main_thread_task_runner.cc
+++ b/remoting/client/plugin/pepper_main_thread_task_runner.cc
@@ -5,8 +5,11 @@
#include "remoting/client/plugin/pepper_main_thread_task_runner.h"
#include <memory>
+#include <utility>
#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/core.h"
@@ -30,10 +33,10 @@ PepperMainThreadTaskRunner::PepperMainThreadTaskRunner()
bool PepperMainThreadTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
- auto task_ptr = base::MakeUnique<base::Closure>(
- base::Bind(&PepperMainThreadTaskRunner::RunTask, weak_ptr_, task));
+ auto task_ptr = base::MakeUnique<base::Closure>(base::Bind(
+ &PepperMainThreadTaskRunner::RunTask, weak_ptr_, base::Passed(&task)));
core_->CallOnMainThread(
delay.InMillisecondsRoundedUp(),
pp::CompletionCallback(&RunAndDestroy, task_ptr.release()));
@@ -42,9 +45,9 @@ bool PepperMainThreadTaskRunner::PostDelayedTask(
bool PepperMainThreadTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
- return PostDelayedTask(from_here, task, delay);
+ return PostDelayedTask(from_here, std::move(task), delay);
}
bool PepperMainThreadTaskRunner::RunsTasksOnCurrentThread() const {
@@ -53,8 +56,8 @@ bool PepperMainThreadTaskRunner::RunsTasksOnCurrentThread() const {
PepperMainThreadTaskRunner::~PepperMainThreadTaskRunner() {}
-void PepperMainThreadTaskRunner::RunTask(const base::Closure& task) {
- task.Run();
+void PepperMainThreadTaskRunner::RunTask(base::Closure task) {
+ std::move(task).Run();
}
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698