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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 10832264: Fix lifecycle-vs-threads of GpuVDAContext3D. (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/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 739 }
740 740
741 void RenderThreadImpl::UpdateHistograms(int sequence_number) { 741 void RenderThreadImpl::UpdateHistograms(int sequence_number) {
742 child_histogram_message_filter()->SendHistograms(sequence_number); 742 child_histogram_message_filter()->SendHistograms(sequence_number);
743 } 743 }
744 744
745 void RenderThreadImpl::PostponeIdleNotification() { 745 void RenderThreadImpl::PostponeIdleNotification() {
746 idle_notifications_to_skip_ = 2; 746 idle_notifications_to_skip_ = 2;
747 } 747 }
748 748
749 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> 749 class GpuVDAContextLostCallback
750 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
751 public:
752 virtual void onContextLost() {
753 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind(
754 &RenderThreadImpl::OnGpuVDAContextLoss));
755 }
756 };
757
758 /* static */
759 void RenderThreadImpl::OnGpuVDAContextLoss() {
760 RenderThreadImpl* self = RenderThreadImpl::current();
761 DCHECK(self);
762 if (!self->gpu_vda_context3d_.get())
763 return;
764 if (self->compositor_thread()) {
765 self->compositor_thread()->GetWebThread()->message_loop()->DeleteSoon(
766 FROM_HERE, self->gpu_vda_context3d_.release());
767 } else {
768 self->gpu_vda_context3d_.reset();
769 }
770 }
771
772 WebGraphicsContext3DCommandBufferImpl*
750 RenderThreadImpl::GetGpuVDAContext3D() { 773 RenderThreadImpl::GetGpuVDAContext3D() {
751 // If we already handed out a pointer to a context and it's been lost, create 774 static GpuVDAContextLostCallback* context_lost_cb =
752 // a new one. 775 new GpuVDAContextLostCallback();
piman 2012/08/13 17:23:35 Why the need to leak it? Could it be a scoped_ptr
Ami GONE FROM CHROMIUM 2012/08/13 17:38:16 Done, at the cost of having to #include "third_pa
753 if (gpu_vda_context3d_.get() && gpu_vda_context3d_->isContextLost()) {
754 if (compositor_thread()) {
755 compositor_thread()->GetWebThread()->message_loop()->DeleteSoon(
756 FROM_HERE, gpu_vda_context3d_.release());
757 } else {
758 gpu_vda_context3d_.reset();
759 }
760 }
761 if (!gpu_vda_context3d_.get()) { 776 if (!gpu_vda_context3d_.get()) {
762 gpu_vda_context3d_.reset( 777 gpu_vda_context3d_.reset(
763 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 778 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
764 this, WebKit::WebGraphicsContext3D::Attributes(), 779 this, WebKit::WebGraphicsContext3D::Attributes(),
765 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))); 780 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D")));
781 gpu_vda_context3d_->setContextLostCallback(context_lost_cb);
766 } 782 }
767 if (!gpu_vda_context3d_.get()) 783 return gpu_vda_context3d_.get();
768 return base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>();
769 return gpu_vda_context3d_->AsWeakPtr();
770 } 784 }
771 785
772 content::AudioRendererMixerManager* 786 content::AudioRendererMixerManager*
773 RenderThreadImpl::GetAudioRendererMixerManager() { 787 RenderThreadImpl::GetAudioRendererMixerManager() {
774 if (!audio_renderer_mixer_manager_.get()) { 788 if (!audio_renderer_mixer_manager_.get()) {
775 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( 789 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager(
776 audio_hardware::GetOutputSampleRate(), 790 audio_hardware::GetOutputSampleRate(),
777 audio_hardware::GetOutputBufferSize())); 791 audio_hardware::GetOutputBufferSize()));
778 } 792 }
779 793
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1055
1042 scoped_refptr<base::MessageLoopProxy> 1056 scoped_refptr<base::MessageLoopProxy>
1043 RenderThreadImpl::GetFileThreadMessageLoopProxy() { 1057 RenderThreadImpl::GetFileThreadMessageLoopProxy() {
1044 DCHECK(message_loop() == MessageLoop::current()); 1058 DCHECK(message_loop() == MessageLoop::current());
1045 if (!file_thread_.get()) { 1059 if (!file_thread_.get()) {
1046 file_thread_.reset(new base::Thread("Renderer::FILE")); 1060 file_thread_.reset(new base::Thread("Renderer::FILE"));
1047 file_thread_->Start(); 1061 file_thread_->Start();
1048 } 1062 }
1049 return file_thread_->message_loop_proxy(); 1063 return file_thread_->message_loop_proxy();
1050 } 1064 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698