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
This commit is contained in:
Marshall Greenblatt 2012-10-29 21:50:46 +00:00
parent 0cea9668fe
commit 3ac5952636
1 changed files with 18 additions and 22 deletions

View File

@ -211,31 +211,27 @@ void CefContentRendererClient::WillReleaseScriptContext(
WebKit::WebFrame* frame, v8::Handle<v8::Context> context, int world_id) {
// Notify the render process handler.
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
if (!application.get())
return;
if (application.get()) {
CefRefPtr<CefRenderProcessHandler> handler =
application->GetRenderProcessHandler();
if (handler.get()) {
CefRefPtr<CefBrowserImpl> browserPtr =
CefBrowserImpl::GetBrowserForMainFrame(frame->top());
DCHECK(browserPtr.get());
if (browserPtr.get()) {
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
CefRefPtr<CefRenderProcessHandler> handler =
application->GetRenderProcessHandler();
if (!handler.get())
return;
v8::HandleScope handle_scope;
v8::Context::Scope scope(context);
WebCore::V8RecursionScope recursion_scope(
WebCore::getScriptExecutionContext());
CefRefPtr<CefBrowserImpl> browserPtr =
CefBrowserImpl::GetBrowserForMainFrame(frame->top());
DCHECK(browserPtr.get());
if (!browserPtr.get())
return;
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(context));
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
{
v8::HandleScope handle_scope;
v8::Context::Scope scope(context);
WebCore::V8RecursionScope recursion_scope(
WebCore::getScriptExecutionContext());
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(context));
handler->OnContextReleased(browserPtr.get(), framePtr.get(), contextPtr);
handler->OnContextReleased(browserPtr.get(), framePtr.get(),
contextPtr);
}
}
}
CefV8ReleaseContext(context);