Chromium Code Reviews| Index: content/renderer/gpu/stream_texture_host_android.cc |
| diff --git a/content/renderer/gpu/stream_texture_host_android.cc b/content/renderer/gpu/stream_texture_host_android.cc |
| index e03a16dee84a20222268155158f35d56ae766ac0..b9b8615ac758b4ee5cb91fdbe3bf20f485e38f6f 100644 |
| --- a/content/renderer/gpu/stream_texture_host_android.cc |
| +++ b/content/renderer/gpu/stream_texture_host_android.cc |
| @@ -19,29 +19,31 @@ StreamTextureHost::StreamTextureHost(scoped_refptr<gpu::GpuChannelHost> channel, |
| channel_(std::move(channel)), |
| weak_ptr_factory_(this) { |
| DCHECK(channel_); |
| + DCHECK(route_id_); |
| } |
| StreamTextureHost::~StreamTextureHost() { |
| - if (channel_.get() && route_id_) |
| - channel_->RemoveRoute(route_id_); |
| + if (!channel_.get()) |
| + return; |
| + |
| + channel_->RemoveRoute(route_id_); |
| } |
| bool StreamTextureHost::BindToCurrentThread(Listener* listener) { |
| listener_ = listener; |
| - if (channel_.get() && route_id_) { |
| - channel_->AddRoute(route_id_, weak_ptr_factory_.GetWeakPtr()); |
| - channel_->Send(new GpuStreamTextureMsg_StartListening(route_id_)); |
| - return true; |
| - } |
| + if (!channel_.get()) |
|
watk
2016/11/23 20:26:07
All the if (!channel_.get())s can be replace with
tguilbert
2016/11/23 20:43:13
Woops yes.
|
| + return false; |
| + |
| + channel_->AddRoute(route_id_, weak_ptr_factory_.GetWeakPtr()); |
| + channel_->Send(new GpuStreamTextureMsg_StartListening(route_id_)); |
| - return false; |
| + return true; |
| } |
| bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) { |
| bool handled = true; |
| IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message) |
| - IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable, |
| - OnFrameAvailable); |
| + IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable, OnFrameAvailable); |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| DCHECK(handled); |
| @@ -49,31 +51,38 @@ bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) { |
| } |
| void StreamTextureHost::OnChannelError() { |
| + channel_ = nullptr; |
| } |
| void StreamTextureHost::OnFrameAvailable() { |
| - if (listener_) |
| - listener_->OnFrameAvailable(); |
| + if (!listener_) |
| + return; |
|
watk
2016/11/23 20:26:07
Re your question: think it's a personal preference
tguilbert
2016/11/23 20:43:13
Ok. I also preferred the old way. Changing it back
|
| + |
| + listener_->OnFrameAvailable(); |
| } |
| void StreamTextureHost::EstablishPeer(int player_id, int frame_id) { |
| - if (route_id_) { |
| - channel_->Send( |
| - new GpuStreamTextureMsg_EstablishPeer(route_id_, frame_id, player_id)); |
| - } |
| + if (!channel_.get()) |
| + return; |
| + |
| + channel_->Send( |
| + new GpuStreamTextureMsg_EstablishPeer(route_id_, frame_id, player_id)); |
| } |
| void StreamTextureHost::SetStreamTextureSize(const gfx::Size& size) { |
| - if (route_id_) |
| - channel_->Send(new GpuStreamTextureMsg_SetSize(route_id_, size)); |
| + if (!channel_.get()) |
| + return; |
| + |
| + channel_->Send(new GpuStreamTextureMsg_SetSize(route_id_, size)); |
| } |
| void StreamTextureHost::ForwardStreamTextureForSurfaceRequest( |
| const base::UnguessableToken& request_token) { |
| - if (route_id_) { |
| - channel_->Send(new GpuStreamTextureMsg_ForwardForSurfaceRequest( |
| - route_id_, request_token)); |
| - } |
| + if (!channel_.get()) |
| + return; |
| + |
| + channel_->Send(new GpuStreamTextureMsg_ForwardForSurfaceRequest( |
| + route_id_, request_token)); |
| } |
| } // namespace content |