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

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

Issue 180773003: Simplify the way to initialize context (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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/WorkerScriptController.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/WorkerScriptController.cpp
diff --git a/Source/bindings/v8/WorkerScriptController.cpp b/Source/bindings/v8/WorkerScriptController.cpp
index 1c169f71f7ed81a2deec53b3a80b742e74c0b04c..47beee655dd03a9e744052230f6d813b0ab1d206 100644
--- a/Source/bindings/v8/WorkerScriptController.cpp
+++ b/Source/bindings/v8/WorkerScriptController.cpp
@@ -120,31 +120,21 @@ WorkerScriptController::~WorkerScriptController()
void WorkerScriptController::disposeContext()
{
m_perContextData.clear();
- m_contextHolder.clear();
}
bool WorkerScriptController::initializeContextIfNeeded()
{
- if (m_contextHolder)
+ if (m_perContextData)
return true;
v8::Handle<v8::Context> context = v8::Context::New(isolate());
if (context.IsEmpty())
return false;
- m_contextHolder = adoptPtr(new gin::ContextHolder(isolate()));
- m_contextHolder->SetContext(context);
+ m_perContextData = V8PerContextData::create(context, m_world.get());
v8::Context::Scope scope(context);
- V8PerContextDataHolder::install(context, m_world.get());
-
- m_perContextData = V8PerContextData::create(context);
- if (!m_perContextData->init()) {
- disposeContext();
- return false;
- }
-
// Set DebugId for the new context.
context->SetEmbedderData(0, v8AtomicString(isolate(), "worker"));
@@ -164,7 +154,7 @@ bool WorkerScriptController::initializeContextIfNeeded()
V8DOMWrapper::associateObjectWithWrapper<V8WorkerGlobalScope>(PassRefPtr<WorkerGlobalScope>(m_workerGlobalScope), contextType, jsWorkerGlobalScope, isolate(), WrapperConfiguration::Dependent);
// Insert the object instance as the prototype of the shadow object.
- v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_contextHolder->context()->Global()->GetPrototype());
+ v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_perContextData->context()->Global()->GetPrototype());
globalObject->SetPrototype(jsWorkerGlobalScope);
return true;
@@ -177,7 +167,7 @@ ScriptValue WorkerScriptController::evaluate(const String& script, const String&
if (!initializeContextIfNeeded())
return ScriptValue();
- v8::Handle<v8::Context> context = m_contextHolder->context();
+ v8::Handle<v8::Context> context = m_perContextData->context();
if (!m_disableEvalPending.isEmpty()) {
context->AllowCodeGenerationFromStrings(false);
context->SetErrorMessageForCodeGenerationFromStrings(v8String(isolate(), m_disableEvalPending));
« no previous file with comments | « Source/bindings/v8/WorkerScriptController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698