From 3ac5952636e021ec1f232f1103c8383a46bc0b77 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 29 Oct 2012 21:50:46 +0000 Subject: [PATCH] Support implicit detachment of CEF V8 references when the associated context is released (issue #484). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@882 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/renderer/content_renderer_client.cc | 40 ++++++++++------------ 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index 7057ca66a..ccdc8435c 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -211,31 +211,27 @@ void CefContentRendererClient::WillReleaseScriptContext( WebKit::WebFrame* frame, v8::Handle context, int world_id) { // Notify the render process handler. CefRefPtr application = CefContentClient::Get()->application(); - if (!application.get()) - return; + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) { + CefRefPtr browserPtr = + CefBrowserImpl::GetBrowserForMainFrame(frame->top()); + DCHECK(browserPtr.get()); + if (browserPtr.get()) { + CefRefPtr framePtr = browserPtr->GetWebFrameImpl(frame); - CefRefPtr handler = - application->GetRenderProcessHandler(); - if (!handler.get()) - return; + v8::HandleScope handle_scope; + v8::Context::Scope scope(context); + WebCore::V8RecursionScope recursion_scope( + WebCore::getScriptExecutionContext()); - CefRefPtr browserPtr = - CefBrowserImpl::GetBrowserForMainFrame(frame->top()); - DCHECK(browserPtr.get()); - if (!browserPtr.get()) - return; + CefRefPtr contextPtr(new CefV8ContextImpl(context)); - CefRefPtr framePtr = browserPtr->GetWebFrameImpl(frame); - - { - v8::HandleScope handle_scope; - v8::Context::Scope scope(context); - WebCore::V8RecursionScope recursion_scope( - WebCore::getScriptExecutionContext()); - - CefRefPtr contextPtr(new CefV8ContextImpl(context)); - - handler->OnContextReleased(browserPtr.get(), framePtr.get(), contextPtr); + handler->OnContextReleased(browserPtr.get(), framePtr.get(), + contextPtr); + } + } } CefV8ReleaseContext(context);