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

Side by Side Diff: content/renderer/gpu/stream_texture_host_android.cc

Issue 2530443002: Fix OnChannelError() in StreamTextureHost (Closed)
Patch Set: Addressed comments Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/android/stream_texture_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/gpu/stream_texture_host_android.h" 5 #include "content/renderer/gpu/stream_texture_host_android.h"
6 6
7 #include "base/unguessable_token.h" 7 #include "base/unguessable_token.h"
8 #include "content/renderer/render_thread_impl.h" 8 #include "content/renderer/render_thread_impl.h"
9 #include "gpu/ipc/client/gpu_channel_host.h" 9 #include "gpu/ipc/client/gpu_channel_host.h"
10 #include "gpu/ipc/common/gpu_messages.h" 10 #include "gpu/ipc/common/gpu_messages.h"
11 #include "ipc/ipc_message_macros.h" 11 #include "ipc/ipc_message_macros.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 StreamTextureHost::StreamTextureHost(scoped_refptr<gpu::GpuChannelHost> channel, 15 StreamTextureHost::StreamTextureHost(scoped_refptr<gpu::GpuChannelHost> channel,
16 int32_t route_id) 16 int32_t route_id)
17 : route_id_(route_id), 17 : route_id_(route_id),
18 listener_(NULL), 18 listener_(nullptr),
19 channel_(std::move(channel)), 19 channel_(std::move(channel)),
20 weak_ptr_factory_(this) { 20 weak_ptr_factory_(this) {
21 DCHECK(channel_); 21 DCHECK(channel_);
22 DCHECK(route_id_);
22 } 23 }
23 24
24 StreamTextureHost::~StreamTextureHost() { 25 StreamTextureHost::~StreamTextureHost() {
25 if (channel_.get() && route_id_) 26 if (channel_)
26 channel_->RemoveRoute(route_id_); 27 channel_->RemoveRoute(route_id_);
27 } 28 }
28 29
29 bool StreamTextureHost::BindToCurrentThread(Listener* listener) { 30 bool StreamTextureHost::BindToCurrentThread(Listener* listener) {
30 listener_ = listener; 31 listener_ = listener;
31 if (channel_.get() && route_id_) { 32
33 if (channel_) {
32 channel_->AddRoute(route_id_, weak_ptr_factory_.GetWeakPtr()); 34 channel_->AddRoute(route_id_, weak_ptr_factory_.GetWeakPtr());
33 channel_->Send(new GpuStreamTextureMsg_StartListening(route_id_)); 35 channel_->Send(new GpuStreamTextureMsg_StartListening(route_id_));
34 return true; 36 return true;
35 } 37 }
36 38
37 return false; 39 return false;
38 } 40 }
39 41
40 bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) { 42 bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) {
41 bool handled = true; 43 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message) 44 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message)
43 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable, 45 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable, OnFrameAvailable);
44 OnFrameAvailable);
45 IPC_MESSAGE_UNHANDLED(handled = false) 46 IPC_MESSAGE_UNHANDLED(handled = false)
46 IPC_END_MESSAGE_MAP() 47 IPC_END_MESSAGE_MAP()
47 DCHECK(handled); 48 DCHECK(handled);
48 return handled; 49 return handled;
49 } 50 }
50 51
51 void StreamTextureHost::OnChannelError() { 52 void StreamTextureHost::OnChannelError() {
53 channel_ = nullptr;
52 } 54 }
53 55
54 void StreamTextureHost::OnFrameAvailable() { 56 void StreamTextureHost::OnFrameAvailable() {
55 if (listener_) 57 if (listener_)
56 listener_->OnFrameAvailable(); 58 listener_->OnFrameAvailable();
57 } 59 }
58 60
59 void StreamTextureHost::EstablishPeer(int player_id, int frame_id) { 61 void StreamTextureHost::EstablishPeer(int player_id, int frame_id) {
60 if (route_id_) { 62 if (channel_) {
61 channel_->Send( 63 channel_->Send(
62 new GpuStreamTextureMsg_EstablishPeer(route_id_, frame_id, player_id)); 64 new GpuStreamTextureMsg_EstablishPeer(route_id_, frame_id, player_id));
63 } 65 }
64 } 66 }
65 67
66 void StreamTextureHost::SetStreamTextureSize(const gfx::Size& size) { 68 void StreamTextureHost::SetStreamTextureSize(const gfx::Size& size) {
67 if (route_id_) 69 if (channel_)
68 channel_->Send(new GpuStreamTextureMsg_SetSize(route_id_, size)); 70 channel_->Send(new GpuStreamTextureMsg_SetSize(route_id_, size));
69 } 71 }
70 72
71 void StreamTextureHost::ForwardStreamTextureForSurfaceRequest( 73 void StreamTextureHost::ForwardStreamTextureForSurfaceRequest(
72 const base::UnguessableToken& request_token) { 74 const base::UnguessableToken& request_token) {
73 if (route_id_) { 75 if (channel_) {
74 channel_->Send(new GpuStreamTextureMsg_ForwardForSurfaceRequest( 76 channel_->Send(new GpuStreamTextureMsg_ForwardForSurfaceRequest(
75 route_id_, request_token)); 77 route_id_, request_token));
76 } 78 }
77 } 79 }
78 80
79 } // namespace content 81 } // namespace content
OLDNEW
« 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