Index: Source/bindings/v8/V8PerContextData.cpp |
diff --git a/Source/bindings/v8/V8PerContextData.cpp b/Source/bindings/v8/V8PerContextData.cpp |
index ff9ce8e73e72dc8caae4800aebd3c6cbb098dcc9..4414ef23daff6316d7bf80a7abbf90973a28a255 100644 |
--- a/Source/bindings/v8/V8PerContextData.cpp |
+++ b/Source/bindings/v8/V8PerContextData.cpp |
@@ -48,52 +48,41 @@ static void disposeMapWithUnsafePersistentValues(Map* map) |
map->clear(); |
} |
+V8PerContextData::V8PerContextData(v8::Handle<v8::Context> context, DOMWrapperWorld* world) |
+ : m_activityLogger(0) |
+ , m_isolate(context->GetIsolate()) |
+ , m_contextHolder(adoptPtr(new gin::ContextHolder(context->GetIsolate()))) |
+ , m_world(world) |
+ , m_context(m_isolate, context) |
+ , m_customElementBindings(adoptPtr(new CustomElementBindingMap())) |
+{ |
+ m_contextHolder->SetContext(context); |
+ context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this); |
+ |
+ v8::Context::Scope contextScope(context); |
+ ASSERT(m_errorPrototype.isEmpty()); |
+ v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(v8AtomicString(m_isolate, "Error"))); |
+ ASSERT(!object.IsEmpty()); |
+ v8::Handle<v8::Value> prototypeValue = object->Get(v8AtomicString(m_isolate, "prototype")); |
+ ASSERT(!prototypeValue.IsEmpty()); |
+ m_errorPrototype.set(m_isolate, prototypeValue); |
+} |
+ |
V8PerContextData::~V8PerContextData() |
{ |
v8::HandleScope handleScope(m_isolate); |
- V8PerContextDataHolder::from(m_context.newLocal(m_isolate))->setPerContextData(0); |
+ context()->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, 0); |
disposeMapWithUnsafePersistentValues(&m_wrapperBoilerplates); |
disposeMapWithUnsafePersistentValues(&m_constructorMap); |
m_customElementBindings.clear(); |
} |
-#define V8_STORE_PRIMORDIAL(name, Name) \ |
haraken
2014/02/28 11:14:05
This macro is used by only one place, so I inlined
|
-{ \ |
- ASSERT(m_##name##Prototype.isEmpty()); \ |
- v8::Handle<v8::String> symbol = v8AtomicString(m_isolate, #Name); \ |
- if (symbol.IsEmpty()) \ |
- return false; \ |
- v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(m_context.newLocal(m_isolate)->Global()->Get(symbol)); \ |
- if (object.IsEmpty()) \ |
- return false; \ |
- v8::Handle<v8::Value> prototypeValue = object->Get(prototypeString); \ |
- if (prototypeValue.IsEmpty()) \ |
- return false; \ |
- m_##name##Prototype.set(m_isolate, prototypeValue); \ |
-} |
- |
-bool V8PerContextData::init() |
haraken
2014/02/28 11:14:05
In reality, init() should not return false. Thus I
|
-{ |
- v8::Handle<v8::Context> context = m_context.newLocal(m_isolate); |
- V8PerContextDataHolder::from(context)->setPerContextData(this); |
- |
- v8::Handle<v8::String> prototypeString = v8AtomicString(m_isolate, "prototype"); |
- if (prototypeString.IsEmpty()) |
- return false; |
- |
- V8_STORE_PRIMORDIAL(error, Error); |
- |
- return true; |
-} |
- |
-#undef V8_STORE_PRIMORDIAL |
- |
v8::Local<v8::Object> V8PerContextData::createWrapperFromCacheSlowCase(const WrapperTypeInfo* type) |
{ |
ASSERT(!m_errorPrototype.isEmpty()); |
- v8::Context::Scope scope(m_context.newLocal(m_isolate)); |
+ v8::Context::Scope scope(context()); |
v8::Local<v8::Function> function = constructorForType(type); |
v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(function); |
if (!instanceTemplate.IsEmpty()) { |
@@ -107,7 +96,7 @@ v8::Local<v8::Function> V8PerContextData::constructorForTypeSlowCase(const Wrapp |
{ |
ASSERT(!m_errorPrototype.isEmpty()); |
- v8::Context::Scope scope(m_context.newLocal(m_isolate)); |
+ v8::Context::Scope scope(context()); |
v8::Handle<v8::FunctionTemplate> functionTemplate = type->domTemplate(m_isolate, worldType(m_isolate)); |
// Getting the function might fail if we're running out of stack or memory. |
v8::TryCatch tryCatch; |