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

Unified Diff: content/renderer/gpu/stream_texture_host_android.cc

Issue 2530443002: Fix OnChannelError() in StreamTextureHost (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | content/renderer/media/android/stream_texture_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | content/renderer/media/android/stream_texture_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698