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

Unified Diff: Source/bindings/v8/V8DOMWindowShell.cpp

Issue 17035004: [ABANDONED] Introduce Promise example implementation written in JavaScript. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/V8DOMWindowShell.h ('k') | Source/bindings/v8/V8HiddenPropertyName.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8DOMWindowShell.cpp
diff --git a/Source/bindings/v8/V8DOMWindowShell.cpp b/Source/bindings/v8/V8DOMWindowShell.cpp
index 6cc480b8b802e12d2826f9be8199fcc27176faa8..6e214b0bf4ed33168ba0048b4884c0a0447b9436 100644
--- a/Source/bindings/v8/V8DOMWindowShell.cpp
+++ b/Source/bindings/v8/V8DOMWindowShell.cpp
@@ -79,6 +79,28 @@ static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex
V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugId);
}
+V8DOMWindowShell::ContextScope::ContextScope(V8DOMWindowShell* shell, ContextDescriptor descriptor)
+ : m_scope(descriptor == DomContext ? shell->m_context.newLocal(shell->m_isolate) : shell->m_contextForBlinkJS.newLocal(shell->m_isolate))
+{
+}
+
+V8DOMWindowShell* V8DOMWindowShell::ContextScope::currentWindowShell()
+{
+ DOMWindow* window = activeDOMWindow();
+ if (!window)
+ return 0;
+ Document* document = window->document();
+ if (!document)
+ return 0;
+ Frame* frame = document->frame();
+ if (!frame)
+ return 0;
+ ScriptController* script = frame->script();
+ if (!script)
+ return 0;
+ return script->windowShell(DOMWrapperWorld::current());
+}
+
PassOwnPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
{
return adoptPtr(new V8DOMWindowShell(frame, world, isolate));
@@ -94,6 +116,7 @@ V8DOMWindowShell::V8DOMWindowShell(Frame* frame, PassRefPtr<DOMWrapperWorld> wor
void V8DOMWindowShell::disposeContext()
{
m_perContextData.clear();
+ m_perContextDataForBlinkJS.clear();
if (m_context.isEmpty())
return;
@@ -102,6 +125,7 @@ void V8DOMWindowShell::disposeContext()
m_frame->loader()->client()->willReleaseScriptContext(m_context.newLocal(m_isolate), m_world->worldId());
m_context.clear();
+ m_contextForBlinkJS.clear();
// It's likely that disposing the context has created a lot of
// garbage. Notify V8 about this so it'll have a chance of cleaning
@@ -221,6 +245,18 @@ bool V8DOMWindowShell::initializeIfNeeded()
return false;
}
m_perContextData->setActivityLogger(DOMWrapperWorld::activityLogger(m_world->worldId()));
+
+ {
+ v8::Handle<v8::Context> contextForBlinkJS = m_contextForBlinkJS.newLocal(m_isolate);
+ v8::Context::Scope contextScope(contextForBlinkJS);
+ m_perContextDataForBlinkJS = V8PerContextData::create(contextForBlinkJS);
+ if (!m_perContextDataForBlinkJS->init()) {
+ disposeContext();
+ return false;
+ }
+ m_perContextDataForBlinkJS->setActivityLogger(DOMWrapperWorld::activityLogger(m_world->worldId()));
+ }
+
if (!installDOMWindow()) {
disposeContext();
return false;
@@ -293,6 +329,7 @@ void V8DOMWindowShell::createContext()
v8::HandleScope handleScope(m_isolate);
m_context.set(m_isolate, v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate, m_global.newLocal(m_isolate)));
+ m_contextForBlinkJS.set(m_isolate, v8::Context::New(m_isolate, 0, globalTemplate));
double contextCreationDurationInMilliseconds = (currentTime() - contextCreationStartInSeconds) * 1000;
const char* histogramName = "WebCore.V8DOMWindowShell.createContext.MainWorld";
@@ -330,6 +367,12 @@ bool V8DOMWindowShell::installDOMWindow()
V8DOMWrapper::setNativeInfo(innerGlobalObject, &V8DOMWindow::info, window);
innerGlobalObject->SetPrototype(windowWrapper);
V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper, m_isolate, WrapperConfiguration::Dependent);
+
+ v8::Handle<v8::Object> innerGlobalObjectForBlinkJS = toInnerGlobalObject(m_contextForBlinkJS.newLocal(m_isolate));
+ V8DOMWrapper::setNativeInfo(innerGlobalObjectForBlinkJS, &V8DOMWindow::info, window);
+ innerGlobalObjectForBlinkJS->SetPrototype(windowWrapper);
+ V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper, m_isolate, WrapperConfiguration::Dependent);
+
DOMWrapperWorld::setInitializingWindow(false);
return true;
}
« no previous file with comments | « Source/bindings/v8/V8DOMWindowShell.h ('k') | Source/bindings/v8/V8HiddenPropertyName.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698