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

Side by Side Diff: content/common/gpu/client/gpu_video_decode_accelerator_host.cc

Issue 10852009: Clarify ownership of GpuVideoDecodeAcceleratorHost and avoid crash on context loss. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months 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 | Annotate | Revision Log
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/common/gpu/client/gpu_video_decode_accelerator_host.h" 5 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/common/gpu/client/gpu_channel_host.h" 10 #include "content/common/gpu/client/gpu_channel_host.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_)); 112 Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_));
113 } 113 }
114 114
115 void GpuVideoDecodeAcceleratorHost::Reset() { 115 void GpuVideoDecodeAcceleratorHost::Reset() {
116 DCHECK(CalledOnValidThread()); 116 DCHECK(CalledOnValidThread());
117 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_)); 117 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_));
118 } 118 }
119 119
120 void GpuVideoDecodeAcceleratorHost::Destroy() { 120 void GpuVideoDecodeAcceleratorHost::Destroy() {
121 DCHECK(CalledOnValidThread()); 121 DCHECK(CalledOnValidThread());
122 channel_->RemoveRoute(decoder_route_id_); 122 if (channel_)
123 channel_->RemoveRoute(decoder_route_id_);
123 client_ = NULL; 124 client_ = NULL;
124 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); 125 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_));
125 delete this; 126 delete this;
126 } 127 }
127 128
128 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() {} 129 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() {
130 DCHECK(CalledOnValidThread());
131 DCHECK(!client_) << "destructor called without Destroy being called!";
132 }
129 133
130 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { 134 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) {
131 // After OnChannelError is called, the client should no longer send 135 // After OnChannelError is called, the client should no longer send
132 // messages to the gpu channel through this object. But queued posted tasks 136 // messages to the gpu channel through this object. But queued posted tasks
133 // can still be draining, so we're forgiving and simply ignore them. 137 // can still be draining, so we're forgiving and simply ignore them.
134 bool error = false; 138 bool error = false;
135 uint32 message_type = message->type(); 139 uint32 message_type = message->type();
136 if (!channel_) { 140 if (!channel_) {
137 delete message; 141 delete message;
138 DLOG(ERROR) << "Send(" << message_type << ") after error ignored"; 142 DLOG(ERROR) << "Send(" << message_type << ") after error ignored";
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 196 }
193 197
194 void GpuVideoDecodeAcceleratorHost::OnErrorNotification(uint32 error) { 198 void GpuVideoDecodeAcceleratorHost::OnErrorNotification(uint32 error) {
195 DCHECK(CalledOnValidThread()); 199 DCHECK(CalledOnValidThread());
196 if (!client_) 200 if (!client_)
197 return; 201 return;
198 client_->NotifyError( 202 client_->NotifyError(
199 static_cast<media::VideoDecodeAccelerator::Error>(error)); 203 static_cast<media::VideoDecodeAccelerator::Error>(error));
200 client_ = NULL; 204 client_ = NULL;
201 } 205 }
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_video_decode_accelerator_host.h ('k') | media/filters/gpu_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698