Commit 8557e55b authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert ui/accelerated_widget_mac away from base::Bind/base::Callback

base::Bind/base::Callback are deprecated in favor of either
base::BindOnce/base::OnceCallback or base::BindRepeating/
base::RepeatingCallback (depending on whether the callback
is invoked once or multiple time).

Convert all uses of base::Bind/base::Callback in ui/accelerated_widget_mac
to the recommended methods/types.

Also change PumpableTaskRunner::EnqueueAndPostWrappedTask to take
the task as an std::unique_ptr<WrappedTask> to remove usage of
base::Owned() and remove a naked "new".

Bug: 1007844
Change-Id: I893b7d83715ed960898034608ea83afb39c7efe5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1833462
Commit-Queue: ccameron <ccameron@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701560}
parent bba507fa
...@@ -22,13 +22,13 @@ namespace { ...@@ -22,13 +22,13 @@ namespace {
class WrappedTask; class WrappedTask;
class PumpableTaskRunner; class PumpableTaskRunner;
typedef std::list<WrappedTask*> WrappedTaskQueue; using WrappedTaskQueue = std::list<WrappedTask*>;
typedef base::Callback<void(base::WaitableEvent*, base::TimeDelta)> using EventTimedWaitCallback =
EventTimedWaitCallback; base::RepeatingCallback<void(base::WaitableEvent*, base::TimeDelta)>;
// A wrapper for IPCs and tasks that we may potentially execute in // A wrapper for IPCs and tasks that we may potentially execute in
// WaitForSingleTaskToRun. Because these tasks are sent to two places to run, // WaitForSingleTaskToRun. Because these tasks are sent to two places to run,
// we to wrap them in this structure and track whether or not they have run // we have to wrap them in this structure and track whether or not they have run
// yet, to avoid running them twice. // yet, to avoid running them twice.
class WrappedTask { class WrappedTask {
public: public:
...@@ -66,7 +66,7 @@ class PumpableTaskRunner : public base::SingleThreadTaskRunner { ...@@ -66,7 +66,7 @@ class PumpableTaskRunner : public base::SingleThreadTaskRunner {
// Enqueue WrappedTask and post it to |target_task_runner_|. // Enqueue WrappedTask and post it to |target_task_runner_|.
bool EnqueueAndPostWrappedTask(const base::Location& from_here, bool EnqueueAndPostWrappedTask(const base::Location& from_here,
WrappedTask* task, std::unique_ptr<WrappedTask> task,
base::TimeDelta delay); base::TimeDelta delay);
// Wait at most |max_delay| to run an enqueued task. // Wait at most |max_delay| to run an enqueued task.
...@@ -242,7 +242,7 @@ bool PumpableTaskRunner::WaitForSingleWrappedTaskToRun( ...@@ -242,7 +242,7 @@ bool PumpableTaskRunner::WaitForSingleWrappedTaskToRun(
bool PumpableTaskRunner::EnqueueAndPostWrappedTask( bool PumpableTaskRunner::EnqueueAndPostWrappedTask(
const base::Location& from_here, const base::Location& from_here,
WrappedTask* task, std::unique_ptr<WrappedTask> task,
base::TimeDelta delay) { base::TimeDelta delay) {
task->AddToTaskRunnerQueue(this); task->AddToTaskRunnerQueue(this);
...@@ -252,7 +252,7 @@ bool PumpableTaskRunner::EnqueueAndPostWrappedTask( ...@@ -252,7 +252,7 @@ bool PumpableTaskRunner::EnqueueAndPostWrappedTask(
event_.Signal(); event_.Signal();
return target_task_runner_->PostDelayedTask( return target_task_runner_->PostDelayedTask(
from_here, base::Bind(&WrappedTask::Run, base::Owned(task)), delay); from_here, base::BindOnce(&WrappedTask::Run, std::move(task)), delay);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -262,7 +262,7 @@ bool PumpableTaskRunner::PostDelayedTask(const base::Location& from_here, ...@@ -262,7 +262,7 @@ bool PumpableTaskRunner::PostDelayedTask(const base::Location& from_here,
base::OnceClosure task, base::OnceClosure task,
base::TimeDelta delay) { base::TimeDelta delay) {
return EnqueueAndPostWrappedTask( return EnqueueAndPostWrappedTask(
from_here, new WrappedTask(std::move(task), delay), delay); from_here, std::make_unique<WrappedTask>(std::move(task), delay), delay);
} }
bool PumpableTaskRunner::PostNonNestableDelayedTask( bool PumpableTaskRunner::PostNonNestableDelayedTask(
...@@ -298,7 +298,8 @@ void WindowResizeHelperMac::Init( ...@@ -298,7 +298,8 @@ void WindowResizeHelperMac::Init(
const scoped_refptr<base::SingleThreadTaskRunner>& target_task_runner) { const scoped_refptr<base::SingleThreadTaskRunner>& target_task_runner) {
DCHECK(!task_runner_); DCHECK(!task_runner_);
task_runner_ = new PumpableTaskRunner( task_runner_ = new PumpableTaskRunner(
base::Bind(&WindowResizeHelperMac::EventTimedWait), target_task_runner); base::BindRepeating(&WindowResizeHelperMac::EventTimedWait),
target_task_runner);
} }
void WindowResizeHelperMac::ShutdownForTests() { void WindowResizeHelperMac::ShutdownForTests() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment