| 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 "config.h" | 5 #include "config.h" |
| 6 #include "bindings/v8/ScriptState.h" | 6 #include "bindings/v8/ScriptState.h" |
| 7 | 7 |
| 8 #include "bindings/v8/V8Binding.h" | 8 #include "bindings/v8/V8Binding.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 DOMWindow* ScriptState::domWindow() const | 77 DOMWindow* ScriptState::domWindow() const |
| 78 { | 78 { |
| 79 v8::HandleScope scope(m_isolate); | 79 v8::HandleScope scope(m_isolate); |
| 80 return toDOMWindow(context()); | 80 return toDOMWindow(context()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) | 83 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) |
| 84 { | 84 { |
| 85 v8::Isolate* isolate = toIsolate(frame); | 85 v8::Isolate* isolate = toIsolate(frame); |
| 86 v8::HandleScope handleScope(isolate); | 86 v8::HandleScope handleScope(isolate); |
| 87 return ScriptState::from(toV8Context(isolate, frame, DOMWrapperWorld::mainWo
rld())); | 87 return ScriptState::from(toV8Context(frame, DOMWrapperWorld::mainWorld())); |
| 88 } | 88 } |
| 89 | 89 |
| 90 PassRefPtr<ScriptStateForTesting> ScriptStateForTesting::create(v8::Handle<v8::C
ontext> context, PassRefPtr<DOMWrapperWorld> world) | 90 PassRefPtr<ScriptStateForTesting> ScriptStateForTesting::create(v8::Handle<v8::C
ontext> context, PassRefPtr<DOMWrapperWorld> world) |
| 91 { | 91 { |
| 92 RefPtr<ScriptStateForTesting> scriptState = adoptRef(new ScriptStateForTesti
ng(context, world)); | 92 RefPtr<ScriptStateForTesting> scriptState = adoptRef(new ScriptStateForTesti
ng(context, world)); |
| 93 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. | 93 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. |
| 94 // This is deref()ed in the weak callback of the v8::Context. | 94 // This is deref()ed in the weak callback of the v8::Context. |
| 95 scriptState->ref(); | 95 scriptState->ref(); |
| 96 return scriptState; | 96 return scriptState; |
| 97 } | 97 } |
| 98 | 98 |
| 99 ScriptStateForTesting::ScriptStateForTesting(v8::Handle<v8::Context> context, Pa
ssRefPtr<DOMWrapperWorld> world) | 99 ScriptStateForTesting::ScriptStateForTesting(v8::Handle<v8::Context> context, Pa
ssRefPtr<DOMWrapperWorld> world) |
| 100 : ScriptState(context, world) | 100 : ScriptState(context, world) |
| 101 { | 101 { |
| 102 } | 102 } |
| 103 | 103 |
| 104 ExecutionContext* ScriptStateForTesting::executionContext() const | 104 ExecutionContext* ScriptStateForTesting::executionContext() const |
| 105 { | 105 { |
| 106 return m_executionContext.get(); | 106 return m_executionContext.get(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ScriptStateForTesting::setExecutionContext(PassRefPtr<ExecutionContext> exe
cutionContext) | 109 void ScriptStateForTesting::setExecutionContext(PassRefPtr<ExecutionContext> exe
cutionContext) |
| 110 { | 110 { |
| 111 m_executionContext = executionContext; | 111 m_executionContext = executionContext; |
| 112 } | 112 } |
| 113 | 113 |
| 114 } | 114 } |
| OLD | NEW |