Index: chrome/renderer/pepper_platform_context_3d_impl.cc |
diff --git a/chrome/renderer/pepper_platform_context_3d_impl.cc b/chrome/renderer/pepper_platform_context_3d_impl.cc |
index 52539ffe37bb81bb97dd3a744a437933c7e57162..eaae782c219b21f338c14722fa4ee9237f108be8 100644 |
--- a/chrome/renderer/pepper_platform_context_3d_impl.cc |
+++ b/chrome/renderer/pepper_platform_context_3d_impl.cc |
@@ -13,7 +13,7 @@ |
#ifdef ENABLE_GPU |
PlatformContext3DImpl::PlatformContext3DImpl(ggl::Context* parent_context) |
- : parent_context_(parent_context), |
+ : parent_context_(ggl::GetWeakContextReference(parent_context)), |
parent_texture_id_(0), |
command_buffer_(NULL), |
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
@@ -28,7 +28,7 @@ PlatformContext3DImpl::~PlatformContext3DImpl() { |
channel_ = NULL; |
- if (parent_context_ && parent_texture_id_ != 0) { |
+ if (parent_context_.get() && parent_texture_id_ != 0) { |
ggl::GetImplementation(parent_context_)->FreeTextureId(parent_texture_id_); |
} |
@@ -39,6 +39,10 @@ bool PlatformContext3DImpl::Init() { |
if (command_buffer_) |
return true; |
+ // Parent may already have been deleted. |
+ if (!parent_context_.get()) |
+ return false; |
+ |
RenderThread* render_thread = RenderThread::current(); |
if (!render_thread) |
return false; |
@@ -103,10 +107,6 @@ void PlatformContext3DImpl::SetContextLostCallback(Callback0::Type* callback) { |
void PlatformContext3DImpl::OnContextLost() { |
DCHECK(command_buffer_); |
- // We will lose the parent context soon (it will be reallocated by the main |
- // page). |
- parent_context_ = NULL; |
- parent_texture_id_ = 0; |
if (context_lost_callback_.get()) |
context_lost_callback_->Run(); |
} |