| 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" |
| 11 #include "platform/v8_inspector/public/V8Debugger.h" | |
| 12 | 11 |
| 13 namespace blink { | 12 namespace blink { |
| 14 | 13 |
| 15 PassRefPtr<ScriptState> ScriptState::create(v8::Local<v8::Context> context, Pass
RefPtr<DOMWrapperWorld> world) | 14 PassRefPtr<ScriptState> ScriptState::create(v8::Local<v8::Context> context, Pass
RefPtr<DOMWrapperWorld> world) |
| 16 { | 15 { |
| 17 RefPtr<ScriptState> scriptState = adoptRef(new ScriptState(context, world)); | 16 RefPtr<ScriptState> scriptState = adoptRef(new ScriptState(context, world)); |
| 18 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. | 17 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. |
| 19 // This is deref()ed in the weak callback of the v8::Context. | 18 // This is deref()ed in the weak callback of the v8::Context. |
| 20 scriptState->ref(); | 19 scriptState->ref(); |
| 21 return scriptState; | 20 return scriptState; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 { | 84 { |
| 86 ASSERT_NOT_REACHED(); | 85 ASSERT_NOT_REACHED(); |
| 87 } | 86 } |
| 88 | 87 |
| 89 LocalDOMWindow* ScriptState::domWindow() const | 88 LocalDOMWindow* ScriptState::domWindow() const |
| 90 { | 89 { |
| 91 v8::HandleScope scope(m_isolate); | 90 v8::HandleScope scope(m_isolate); |
| 92 return toLocalDOMWindow(toDOMWindow(context())); | 91 return toLocalDOMWindow(toDOMWindow(context())); |
| 93 } | 92 } |
| 94 | 93 |
| 95 int ScriptState::contextIdInDebugger() | |
| 96 { | |
| 97 v8::HandleScope scope(m_isolate); | |
| 98 return V8Debugger::contextId(m_context.newLocal(m_isolate)); | |
| 99 } | |
| 100 | |
| 101 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) | 94 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) |
| 102 { | 95 { |
| 103 return ScriptState::forWorld(frame, DOMWrapperWorld::mainWorld()); | 96 return ScriptState::forWorld(frame, DOMWrapperWorld::mainWorld()); |
| 104 } | 97 } |
| 105 | 98 |
| 106 ScriptState* ScriptState::forWorld(LocalFrame* frame, DOMWrapperWorld& world) | 99 ScriptState* ScriptState::forWorld(LocalFrame* frame, DOMWrapperWorld& world) |
| 107 { | 100 { |
| 108 ASSERT(frame); | 101 ASSERT(frame); |
| 109 v8::HandleScope handleScope(toIsolate(frame)); | 102 v8::HandleScope handleScope(toIsolate(frame)); |
| 110 v8::Local<v8::Context> context = toV8Context(frame, world); | 103 v8::Local<v8::Context> context = toV8Context(frame, world); |
| 111 if (context.IsEmpty()) | 104 if (context.IsEmpty()) |
| 112 return nullptr; | 105 return nullptr; |
| 113 ScriptState* scriptState = ScriptState::from(context); | 106 ScriptState* scriptState = ScriptState::from(context); |
| 114 ASSERT(scriptState->contextIsValid()); | 107 ASSERT(scriptState->contextIsValid()); |
| 115 return scriptState; | 108 return scriptState; |
| 116 } | 109 } |
| 117 | 110 |
| 118 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |