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

Unified Diff: ui/accelerated_widget_mac/window_resize_helper_mac.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* 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
« no previous file with comments | « third_party/WebKit/Source/platform/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accelerated_widget_mac/window_resize_helper_mac.cc
diff --git a/ui/accelerated_widget_mac/window_resize_helper_mac.cc b/ui/accelerated_widget_mac/window_resize_helper_mac.cc
index b64e09b01d1f6cff4fe155e37a7b0c45ad40115f..2c999b8a19a190e08dd3630bb34980608479c1f1 100644
--- a/ui/accelerated_widget_mac/window_resize_helper_mac.cc
+++ b/ui/accelerated_widget_mac/window_resize_helper_mac.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <list>
+#include <utility>
#include "base/bind.h"
#include "base/callback.h"
@@ -31,7 +32,7 @@ typedef base::Callback<void(base::WaitableEvent*, base::TimeDelta)>
// yet, to avoid running them twice.
class WrappedTask {
public:
- WrappedTask(const base::Closure& closure, base::TimeDelta delay);
+ WrappedTask(base::Closure closure, base::TimeDelta delay);
~WrappedTask();
bool ShouldRunBefore(const WrappedTask& other);
void Run();
@@ -73,11 +74,11 @@ class PumpableTaskRunner : public base::SingleThreadTaskRunner {
// base::SingleThreadTaskRunner implementation:
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
@@ -113,8 +114,8 @@ base::LazyInstance<WindowResizeHelperMac>::Leaky g_window_resize_helper =
////////////////////////////////////////////////////////////////////////////////
// WrappedTask
-WrappedTask::WrappedTask(const base::Closure& closure, base::TimeDelta delay)
- : closure_(closure),
+WrappedTask::WrappedTask(base::Closure closure, base::TimeDelta delay)
+ : closure_(std::move(closure)),
can_run_time_(base::TimeTicks::Now() + delay),
has_run_(false),
sequence_number_(0) {}
@@ -142,7 +143,7 @@ void WrappedTask::Run() {
return;
RemoveFromTaskRunnerQueue();
has_run_ = true;
- closure_.Run();
+ std::move(closure_).Run();
}
void WrappedTask::AddToTaskRunnerQueue(
@@ -259,15 +260,15 @@ bool PumpableTaskRunner::EnqueueAndPostWrappedTask(
bool PumpableTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
- return EnqueueAndPostWrappedTask(from_here, new WrappedTask(task, delay),
- delay);
+ return EnqueueAndPostWrappedTask(
+ from_here, new WrappedTask(std::move(task), delay), delay);
}
bool PumpableTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
// The correctness of non-nestable events hasn't been proven for this
// structure.
« no previous file with comments | « third_party/WebKit/Source/platform/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698