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 {
class WrappedTask;
class PumpableTaskRunner;
typedef std::list<WrappedTask*> WrappedTaskQueue;
typedef base::Callback<void(base::WaitableEvent*, base::TimeDelta)>
EventTimedWaitCallback;
using WrappedTaskQueue = std::list<WrappedTask*>;
using EventTimedWaitCallback =
base::RepeatingCallback<void(base::WaitableEvent*, base::TimeDelta)>;
// A wrapper for IPCs and tasks that we may potentially execute in
// 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.
class WrappedTask {
public:
......@@ -66,7 +66,7 @@ class PumpableTaskRunner : public base::SingleThreadTaskRunner {
// Enqueue WrappedTask and post it to |target_task_runner_|.
bool EnqueueAndPostWrappedTask(const base::Location& from_here,
WrappedTask* task,
std::unique_ptr<WrappedTask> task,
base::TimeDelta delay);
// Wait at most |max_delay| to run an enqueued task.
......@@ -242,7 +242,7 @@ bool PumpableTaskRunner::WaitForSingleWrappedTaskToRun(
bool PumpableTaskRunner::EnqueueAndPostWrappedTask(
const base::Location& from_here,
WrappedTask* task,
std::unique_ptr<WrappedTask> task,
base::TimeDelta delay) {
task->AddToTaskRunnerQueue(this);
......@@ -252,7 +252,7 @@ bool PumpableTaskRunner::EnqueueAndPostWrappedTask(
event_.Signal();
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,
base::OnceClosure task,
base::TimeDelta delay) {
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(
......@@ -298,7 +298,8 @@ void WindowResizeHelperMac::Init(
const scoped_refptr<base::SingleThreadTaskRunner>& target_task_runner) {
DCHECK(!task_runner_);
task_runner_ = new PumpableTaskRunner(
base::Bind(&WindowResizeHelperMac::EventTimedWait), target_task_runner);
base::BindRepeating(&WindowResizeHelperMac::EventTimedWait),
target_task_runner);
}
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