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

Unified Diff: ui/accelerated_widget_mac/window_resize_helper_mac.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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/public/platform/scheduler/test/renderer_scheduler_test_support.h ('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..2deedb5dfeab6e1df8ce200f905487c032528e49 100644
--- a/ui/accelerated_widget_mac/window_resize_helper_mac.cc
+++ b/ui/accelerated_widget_mac/window_resize_helper_mac.cc
@@ -31,7 +31,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::OnceClosure closure, base::TimeDelta delay);
~WrappedTask();
bool ShouldRunBefore(const WrappedTask& other);
void Run();
@@ -40,7 +40,7 @@ class WrappedTask {
const base::TimeTicks& can_run_time() const { return can_run_time_; }
private:
- base::Closure closure_;
+ base::OnceClosure closure_;
base::TimeTicks can_run_time_;
bool has_run_;
uint64_t sequence_number_;
@@ -73,11 +73,11 @@ class PumpableTaskRunner : public base::SingleThreadTaskRunner {
// base::SingleThreadTaskRunner implementation:
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::OnceClosure task,
base::TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::OnceClosure task,
base::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
@@ -113,8 +113,8 @@ base::LazyInstance<WindowResizeHelperMac>::Leaky g_window_resize_helper =
////////////////////////////////////////////////////////////////////////////////
// WrappedTask
-WrappedTask::WrappedTask(const base::Closure& closure, base::TimeDelta delay)
- : closure_(closure),
+WrappedTask::WrappedTask(base::OnceClosure closure, base::TimeDelta delay)
+ : closure_(std::move(closure)),
can_run_time_(base::TimeTicks::Now() + delay),
has_run_(false),
sequence_number_(0) {}
@@ -142,7 +142,7 @@ void WrappedTask::Run() {
return;
RemoveFromTaskRunnerQueue();
has_run_ = true;
- closure_.Run();
+ std::move(closure_).Run();
}
void WrappedTask::AddToTaskRunnerQueue(
@@ -259,15 +259,15 @@ bool PumpableTaskRunner::EnqueueAndPostWrappedTask(
bool PumpableTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::OnceClosure 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::OnceClosure 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/public/platform/scheduler/test/renderer_scheduler_test_support.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698