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

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

Issue 10749019: VideoDecodeAccelerator now SupportsWeakPtr instead of being RefCountedThreadSafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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/command_buffer_proxy_impl.h" 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 28 matching lines...) Expand all
39 39
40 CommandBufferProxyImpl::~CommandBufferProxyImpl() { 40 CommandBufferProxyImpl::~CommandBufferProxyImpl() {
41 // Delete all the locally cached shared memory objects, closing the handle 41 // Delete all the locally cached shared memory objects, closing the handle
42 // in this process. 42 // in this process.
43 for (TransferBufferMap::iterator it = transfer_buffers_.begin(); 43 for (TransferBufferMap::iterator it = transfer_buffers_.begin();
44 it != transfer_buffers_.end(); 44 it != transfer_buffers_.end();
45 ++it) { 45 ++it) {
46 delete it->second.shared_memory; 46 delete it->second.shared_memory;
47 it->second.shared_memory = NULL; 47 it->second.shared_memory = NULL;
48 } 48 }
49 for (Decoders::iterator it = video_decoder_hosts_.begin();
50 it != video_decoder_hosts_.end(); ++it) {
51 it->second->Destroy();
52 }
49 } 53 }
50 54
51 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) { 55 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) {
52 bool handled = true; 56 bool handled = true;
53 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxyImpl, message) 57 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxyImpl, message)
54 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); 58 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed);
55 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint, 59 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint,
56 OnNotifyRepaint); 60 OnNotifyRepaint);
57 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EchoAck, OnEchoAck); 61 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EchoAck, OnEchoAck);
58 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); 62 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage);
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 480 }
477 } 481 }
478 482
479 return result; 483 return result;
480 } 484 }
481 485
482 void CommandBufferProxyImpl::SetNotifyRepaintTask(const base::Closure& task) { 486 void CommandBufferProxyImpl::SetNotifyRepaintTask(const base::Closure& task) {
483 notify_repaint_task_ = task; 487 notify_repaint_task_ = task;
484 } 488 }
485 489
486 scoped_refptr<GpuVideoDecodeAcceleratorHost> 490 GpuVideoDecodeAcceleratorHost*
487 CommandBufferProxyImpl::CreateVideoDecoder( 491 CommandBufferProxyImpl::CreateVideoDecoder(
488 media::VideoCodecProfile profile, 492 media::VideoCodecProfile profile,
489 media::VideoDecodeAccelerator::Client* client) { 493 media::VideoDecodeAccelerator::Client* client) {
490 int decoder_route_id; 494 int decoder_route_id;
491 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, profile, 495 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, profile,
492 &decoder_route_id))) { 496 &decoder_route_id))) {
493 LOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder) failed"; 497 LOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder) failed";
494 return NULL; 498 return NULL;
495 } 499 }
496 500
497 if (decoder_route_id < 0) { 501 if (decoder_route_id < 0) {
498 DLOG(ERROR) << "Failed to Initialize GPU decoder on profile: " << profile; 502 DLOG(ERROR) << "Failed to Initialize GPU decoder on profile: " << profile;
499 return NULL; 503 return NULL;
500 } 504 }
501 505
502 scoped_refptr<GpuVideoDecodeAcceleratorHost> decoder_host = 506 GpuVideoDecodeAcceleratorHost* decoder_host =
503 new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, client); 507 new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, client);
504 bool inserted = video_decoder_hosts_.insert(std::make_pair( 508 bool inserted = video_decoder_hosts_.insert(std::make_pair(
505 decoder_route_id, decoder_host)).second; 509 decoder_route_id, decoder_host)).second;
506 DCHECK(inserted); 510 DCHECK(inserted);
507 511
508 channel_->AddRoute(decoder_route_id, decoder_host->AsWeakPtr()); 512 channel_->AddRoute(decoder_route_id, base::AsWeakPtr(decoder_host));
509 513
510 return decoder_host; 514 return decoder_host;
511 } 515 }
512 516
513 gpu::error::Error CommandBufferProxyImpl::GetLastError() { 517 gpu::error::Error CommandBufferProxyImpl::GetLastError() {
514 return last_state_.error; 518 return last_state_.error;
515 } 519 }
516 520
517 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { 521 bool CommandBufferProxyImpl::Send(IPC::Message* msg) {
518 // Caller should not intentionally send a message if the context is lost. 522 // Caller should not intentionally send a message if the context is lost.
(...skipping 27 matching lines...) Expand all
546 550
547 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( 551 void CommandBufferProxyImpl::SetOnConsoleMessageCallback(
548 const GpuConsoleMessageCallback& callback) { 552 const GpuConsoleMessageCallback& callback) {
549 console_message_callback_ = callback; 553 console_message_callback_ = callback;
550 } 554 }
551 555
552 void CommandBufferProxyImpl::TryUpdateState() { 556 void CommandBufferProxyImpl::TryUpdateState() {
553 if (last_state_.error == gpu::error::kNoError) 557 if (last_state_.error == gpu::error::kNoError)
554 shared_state_->Read(&last_state_); 558 shared_state_->Read(&last_state_);
555 } 559 }
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.h ('k') | content/common/gpu/client/gpu_video_decode_accelerator_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698