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

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

Issue 649533003: C++11 declares a type safe null pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Presubmit errors Created 6 years, 2 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
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/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/common/gpu/client/gpu_channel_host.h" 10 #include "content/common/gpu/client/gpu_channel_host.h"
11 #include "content/common/gpu/gpu_messages.h" 11 #include "content/common/gpu/gpu_messages.h"
12 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
13 #include "ipc/ipc_message_macros.h" 13 #include "ipc/ipc_message_macros.h"
14 #include "ipc/ipc_message_utils.h" 14 #include "ipc/ipc_message_utils.h"
15 15
16 #if defined(OS_WIN) 16 #if defined(OS_WIN)
17 #include "content/public/common/sandbox_init.h" 17 #include "content/public/common/sandbox_init.h"
18 #endif // OS_WIN 18 #endif // OS_WIN
19 19
20 using media::VideoDecodeAccelerator; 20 using media::VideoDecodeAccelerator;
21 namespace content { 21 namespace content {
22 22
23 GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( 23 GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost(
24 GpuChannelHost* channel, 24 GpuChannelHost* channel,
25 CommandBufferProxyImpl* impl) 25 CommandBufferProxyImpl* impl)
26 : channel_(channel), 26 : channel_(channel),
27 decoder_route_id_(MSG_ROUTING_NONE), 27 decoder_route_id_(MSG_ROUTING_NONE),
28 client_(NULL), 28 client_(nullptr),
29 impl_(impl), 29 impl_(impl),
30 weak_this_factory_(this) { 30 weak_this_factory_(this) {
31 DCHECK(channel_); 31 DCHECK(channel_);
32 DCHECK(impl_); 32 DCHECK(impl_);
33 impl_->AddDeletionObserver(this); 33 impl_->AddDeletionObserver(this);
34 } 34 }
35 35
36 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { 36 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() {
37 DCHECK(CalledOnValidThread()); 37 DCHECK(CalledOnValidThread());
38 38
(...skipping 27 matching lines...) Expand all
66 // See OnNotifyError for why |this| mustn't be used after OnNotifyError might 66 // See OnNotifyError for why |this| mustn't be used after OnNotifyError might
67 // have been called above. 67 // have been called above.
68 return handled; 68 return handled;
69 } 69 }
70 70
71 void GpuVideoDecodeAcceleratorHost::OnChannelError() { 71 void GpuVideoDecodeAcceleratorHost::OnChannelError() {
72 DCHECK(CalledOnValidThread()); 72 DCHECK(CalledOnValidThread());
73 if (channel_) { 73 if (channel_) {
74 if (decoder_route_id_ != MSG_ROUTING_NONE) 74 if (decoder_route_id_ != MSG_ROUTING_NONE)
75 channel_->RemoveRoute(decoder_route_id_); 75 channel_->RemoveRoute(decoder_route_id_);
76 channel_ = NULL; 76 channel_ = nullptr;
77 } 77 }
78 DLOG(ERROR) << "OnChannelError()"; 78 DLOG(ERROR) << "OnChannelError()";
79 PostNotifyError(PLATFORM_FAILURE); 79 PostNotifyError(PLATFORM_FAILURE);
80 } 80 }
81 81
82 bool GpuVideoDecodeAcceleratorHost::Initialize(media::VideoCodecProfile profile, 82 bool GpuVideoDecodeAcceleratorHost::Initialize(media::VideoCodecProfile profile,
83 Client* client) { 83 Client* client) {
84 DCHECK(CalledOnValidThread()); 84 DCHECK(CalledOnValidThread());
85 client_ = client; 85 client_ = client;
86 86
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 DCHECK(CalledOnValidThread()); 166 DCHECK(CalledOnValidThread());
167 if (!channel_) 167 if (!channel_)
168 return; 168 return;
169 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_)); 169 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_));
170 } 170 }
171 171
172 void GpuVideoDecodeAcceleratorHost::Destroy() { 172 void GpuVideoDecodeAcceleratorHost::Destroy() {
173 DCHECK(CalledOnValidThread()); 173 DCHECK(CalledOnValidThread());
174 if (channel_) 174 if (channel_)
175 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); 175 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_));
176 client_ = NULL; 176 client_ = nullptr;
177 delete this; 177 delete this;
178 } 178 }
179 179
180 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { 180 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() {
181 DCHECK(CalledOnValidThread()); 181 DCHECK(CalledOnValidThread());
182 impl_ = NULL; 182 impl_ = nullptr;
183 183
184 // The CommandBufferProxyImpl is going away; error out this VDA. 184 // The CommandBufferProxyImpl is going away; error out this VDA.
185 OnChannelError(); 185 OnChannelError();
186 } 186 }
187 187
188 void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) { 188 void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) {
189 DCHECK(CalledOnValidThread()); 189 DCHECK(CalledOnValidThread());
190 DVLOG(2) << "PostNotifyError(): error=" << error; 190 DVLOG(2) << "PostNotifyError(): error=" << error;
191 base::MessageLoopProxy::current()->PostTask( 191 base::MessageLoopProxy::current()->PostTask(
192 FROM_HERE, 192 FROM_HERE,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32 error) { 256 void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32 error) {
257 DCHECK(CalledOnValidThread()); 257 DCHECK(CalledOnValidThread());
258 if (!client_) 258 if (!client_)
259 return; 259 return;
260 weak_this_factory_.InvalidateWeakPtrs(); 260 weak_this_factory_.InvalidateWeakPtrs();
261 261
262 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the 262 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the
263 // last thing done on this stack! 263 // last thing done on this stack!
264 media::VideoDecodeAccelerator::Client* client = NULL; 264 media::VideoDecodeAccelerator::Client* client = nullptr;
265 std::swap(client, client_); 265 std::swap(client, client_);
266 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); 266 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error));
267 } 267 }
268 268
269 } // namespace content 269 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698