| 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 const v8::WeakCallbackInfo<ScriptState>& data) { | 29 const v8::WeakCallbackInfo<ScriptState>& data) { |
| 30 data.GetParameter()->clearContext(); | 30 data.GetParameter()->clearContext(); |
| 31 data.SetSecondPassCallback(derefCallback); | 31 data.SetSecondPassCallback(derefCallback); |
| 32 } | 32 } |
| 33 | 33 |
| 34 ScriptState::ScriptState(v8::Local<v8::Context> context, | 34 ScriptState::ScriptState(v8::Local<v8::Context> context, |
| 35 PassRefPtr<DOMWrapperWorld> world) | 35 PassRefPtr<DOMWrapperWorld> world) |
| 36 : m_isolate(context->GetIsolate()), | 36 : m_isolate(context->GetIsolate()), |
| 37 m_context(m_isolate, context), | 37 m_context(m_isolate, context), |
| 38 m_world(world), | 38 m_world(world), |
| 39 m_perContextData(V8PerContextData::create(context)) | 39 m_perContextData(V8PerContextData::create(context)) { |
| 40 { | |
| 41 DCHECK(m_world); | 40 DCHECK(m_world); |
| 42 m_context.setWeak(this, &contextCollectedCallback); | 41 m_context.setWeak(this, &contextCollectedCallback); |
| 43 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this); | 42 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this); |
| 44 } | 43 } |
| 45 | 44 |
| 46 ScriptState::~ScriptState() { | 45 ScriptState::~ScriptState() { |
| 47 ASSERT(!m_perContextData); | 46 ASSERT(!m_perContextData); |
| 48 ASSERT(m_context.isEmpty()); | 47 ASSERT(m_context.isEmpty()); |
| 49 } | 48 } |
| 50 | 49 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 v8::HandleScope handleScope(toIsolate(frame)); | 93 v8::HandleScope handleScope(toIsolate(frame)); |
| 95 v8::Local<v8::Context> context = toV8Context(frame, world); | 94 v8::Local<v8::Context> context = toV8Context(frame, world); |
| 96 if (context.IsEmpty()) | 95 if (context.IsEmpty()) |
| 97 return nullptr; | 96 return nullptr; |
| 98 ScriptState* scriptState = ScriptState::from(context); | 97 ScriptState* scriptState = ScriptState::from(context); |
| 99 ASSERT(scriptState->contextIsValid()); | 98 ASSERT(scriptState->contextIsValid()); |
| 100 return scriptState; | 99 return scriptState; |
| 101 } | 100 } |
| 102 | 101 |
| 103 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |