Commit 4e150c51 authored by kylechar's avatar kylechar Committed by Commit Bot

Various small fixes for ui::Gpu.

Update a few things to make code easier to understand while looking at
another bug related to the class.
1. Reset scoped_refpts via reset() instead of assigning nullptr.
2. Use BindOnce() where possible.

Bug: 874797
Change-Id: I3910aa17e22e880690b49a98285c49d7a483c3af
Reviewed-on: https://chromium-review.googlesource.com/c/1291776Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605450}
parent 950cedec
...@@ -60,7 +60,7 @@ class Gpu::GpuPtrIO { ...@@ -60,7 +60,7 @@ class Gpu::GpuPtrIO {
if (gpu_ptr_.encountered_error()) { if (gpu_ptr_.encountered_error()) {
ConnectionError(); ConnectionError();
} else { } else {
gpu_ptr_->EstablishGpuChannel(base::BindRepeating( gpu_ptr_->EstablishGpuChannel(base::BindOnce(
&GpuPtrIO::OnEstablishedGpuChannel, base::Unretained(this))); &GpuPtrIO::OnEstablishedGpuChannel, base::Unretained(this)));
} }
} }
...@@ -188,7 +188,7 @@ class Gpu::EstablishRequest ...@@ -188,7 +188,7 @@ class Gpu::EstablishRequest
establish_event_->Signal(); establish_event_->Signal();
} else { } else {
main_task_runner_->PostTask( main_task_runner_->PostTask(
FROM_HERE, base::Bind(&EstablishRequest::FinishOnMain, this)); FROM_HERE, base::BindOnce(&EstablishRequest::FinishOnMain, this));
} }
} }
...@@ -221,7 +221,7 @@ void Gpu::GpuPtrIO::ConnectionError() { ...@@ -221,7 +221,7 @@ void Gpu::GpuPtrIO::ConnectionError() {
establish_request_->OnEstablishedGpuChannel( establish_request_->OnEstablishedGpuChannel(
0, mojo::ScopedMessagePipeHandle(), gpu::GPUInfo(), 0, mojo::ScopedMessagePipeHandle(), gpu::GPUInfo(),
gpu::GpuFeatureInfo()); gpu::GpuFeatureInfo());
establish_request_ = nullptr; establish_request_.reset();
} }
void Gpu::GpuPtrIO::OnEstablishedGpuChannel( void Gpu::GpuPtrIO::OnEstablishedGpuChannel(
...@@ -235,7 +235,7 @@ void Gpu::GpuPtrIO::OnEstablishedGpuChannel( ...@@ -235,7 +235,7 @@ void Gpu::GpuPtrIO::OnEstablishedGpuChannel(
establish_request_->OnEstablishedGpuChannel( establish_request_->OnEstablishedGpuChannel(
client_id, std::move(channel_handle), std::move(gpu_info), client_id, std::move(channel_handle), std::move(gpu_info),
std::move(gpu_feature_info)); std::move(gpu_feature_info));
establish_request_ = nullptr; establish_request_.reset();
} }
Gpu::Gpu(GpuPtrFactory factory, Gpu::Gpu(GpuPtrFactory factory,
...@@ -272,7 +272,7 @@ Gpu::~Gpu() { ...@@ -272,7 +272,7 @@ Gpu::~Gpu() {
DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(main_task_runner_->BelongsToCurrentThread());
if (pending_request_) { if (pending_request_) {
pending_request_->Cancel(); pending_request_->Cancel();
pending_request_ = nullptr; pending_request_.reset();
} }
if (gpu_channel_) if (gpu_channel_)
...@@ -373,14 +373,14 @@ void Gpu::LoseChannel() { ...@@ -373,14 +373,14 @@ void Gpu::LoseChannel() {
DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(main_task_runner_->BelongsToCurrentThread());
if (gpu_channel_) { if (gpu_channel_) {
gpu_channel_->DestroyChannel(); gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr; gpu_channel_.reset();
} }
} }
scoped_refptr<gpu::GpuChannelHost> Gpu::GetGpuChannel() { scoped_refptr<gpu::GpuChannelHost> Gpu::GetGpuChannel() {
DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(main_task_runner_->BelongsToCurrentThread());
if (gpu_channel_ && gpu_channel_->IsLost()) if (gpu_channel_ && gpu_channel_->IsLost())
gpu_channel_ = nullptr; gpu_channel_.reset();
return gpu_channel_; return gpu_channel_;
} }
...@@ -402,7 +402,7 @@ void Gpu::OnEstablishedGpuChannel() { ...@@ -402,7 +402,7 @@ void Gpu::OnEstablishedGpuChannel() {
DCHECK(!gpu_channel_); DCHECK(!gpu_channel_);
gpu_channel_ = pending_request_->gpu_channel(); gpu_channel_ = pending_request_->gpu_channel();
pending_request_ = nullptr; pending_request_.reset();
std::vector<gpu::GpuChannelEstablishedCallback> callbacks; std::vector<gpu::GpuChannelEstablishedCallback> callbacks;
callbacks.swap(establish_callbacks_); callbacks.swap(establish_callbacks_);
......
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