| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/ScriptState.h" | 5 #include "bindings/core/v8/ScriptState.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 data.GetParameter()->clearContext(); | 29 data.GetParameter()->clearContext(); |
| 30 data.SetSecondPassCallback(derefCallback); | 30 data.SetSecondPassCallback(derefCallback); |
| 31 } | 31 } |
| 32 | 32 |
| 33 ScriptState::ScriptState(v8::Local<v8::Context> context, | 33 ScriptState::ScriptState(v8::Local<v8::Context> context, |
| 34 PassRefPtr<DOMWrapperWorld> world) | 34 PassRefPtr<DOMWrapperWorld> world) |
| 35 : m_isolate(context->GetIsolate()), | 35 : m_isolate(context->GetIsolate()), |
| 36 m_context(m_isolate, context), | 36 m_context(m_isolate, context), |
| 37 m_world(world), | 37 m_world(world), |
| 38 m_perContextData(V8PerContextData::create(context)) | 38 m_perContextData(V8PerContextData::create(context)) |
| 39 #if ENABLE(ASSERT) | |
| 40 , | |
| 41 m_globalObjectDetached(false) | |
| 42 #endif | |
| 43 { | 39 { |
| 44 DCHECK(m_world); | 40 DCHECK(m_world); |
| 45 m_context.setWeak(this, &weakCallback); | 41 m_context.setWeak(this, &weakCallback); |
| 46 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this); | 42 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this); |
| 47 } | 43 } |
| 48 | 44 |
| 49 ScriptState::~ScriptState() { | 45 ScriptState::~ScriptState() { |
| 50 ASSERT(!m_perContextData); | 46 ASSERT(!m_perContextData); |
| 51 ASSERT(m_context.isEmpty()); | 47 ASSERT(m_context.isEmpty()); |
| 52 } | 48 } |
| 53 | 49 |
| 54 void ScriptState::detachGlobalObject() { | 50 void ScriptState::detachGlobalObject() { |
| 55 ASSERT(!m_context.isEmpty()); | 51 ASSERT(!m_context.isEmpty()); |
| 56 context()->DetachGlobal(); | 52 context()->DetachGlobal(); |
| 57 #if ENABLE(ASSERT) | 53 #if DCHECK_IS_ON() |
| 58 m_globalObjectDetached = true; | 54 m_globalObjectDetached = true; |
| 59 #endif | 55 #endif |
| 60 } | 56 } |
| 61 | 57 |
| 62 void ScriptState::disposePerContextData() { | 58 void ScriptState::disposePerContextData() { |
| 63 m_perContextData = nullptr; | 59 m_perContextData = nullptr; |
| 64 } | 60 } |
| 65 | 61 |
| 66 ScriptValue ScriptState::getFromExtrasExports(const char* name) { | 62 ScriptValue ScriptState::getFromExtrasExports(const char* name) { |
| 67 v8::HandleScope handleScope(m_isolate); | 63 v8::HandleScope handleScope(m_isolate); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 97 v8::HandleScope handleScope(toIsolate(frame)); | 93 v8::HandleScope handleScope(toIsolate(frame)); |
| 98 v8::Local<v8::Context> context = toV8Context(frame, world); | 94 v8::Local<v8::Context> context = toV8Context(frame, world); |
| 99 if (context.IsEmpty()) | 95 if (context.IsEmpty()) |
| 100 return nullptr; | 96 return nullptr; |
| 101 ScriptState* scriptState = ScriptState::from(context); | 97 ScriptState* scriptState = ScriptState::from(context); |
| 102 ASSERT(scriptState->contextIsValid()); | 98 ASSERT(scriptState->contextIsValid()); |
| 103 return scriptState; | 99 return scriptState; |
| 104 } | 100 } |
| 105 | 101 |
| 106 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |