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/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
10 | 11 |
11 namespace WebCore { | 12 namespace WebCore { |
12 | 13 |
13 PassRefPtr<ScriptState> ScriptState::create(v8::Handle<v8::Context> context, Pas
sRefPtr<DOMWrapperWorld> world) | 14 PassRefPtr<ScriptState> ScriptState::create(v8::Handle<v8::Context> context, Pas
sRefPtr<DOMWrapperWorld> world) |
14 { | 15 { |
15 RefPtr<ScriptState> scriptState = adoptRef(new ScriptState(context, world)); | 16 RefPtr<ScriptState> scriptState = adoptRef(new ScriptState(context, world)); |
16 // 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. |
17 // 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. |
18 scriptState->ref(); | 19 scriptState->ref(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return toDOMWindow(context()); | 68 return toDOMWindow(context()); |
68 } | 69 } |
69 | 70 |
70 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) | 71 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) |
71 { | 72 { |
72 v8::Isolate* isolate = toIsolate(frame); | 73 v8::Isolate* isolate = toIsolate(frame); |
73 v8::HandleScope handleScope(isolate); | 74 v8::HandleScope handleScope(isolate); |
74 return ScriptState::from(toV8Context(isolate, frame, DOMWrapperWorld::mainWo
rld())); | 75 return ScriptState::from(toV8Context(isolate, frame, DOMWrapperWorld::mainWo
rld())); |
75 } | 76 } |
76 | 77 |
| 78 PassRefPtr<ScriptStateForTesting> ScriptStateForTesting::create(v8::Handle<v8::C
ontext> context, PassRefPtr<DOMWrapperWorld> world) |
| 79 { |
| 80 RefPtr<ScriptStateForTesting> scriptState = adoptRef(new ScriptStateForTesti
ng(context, world)); |
| 81 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. |
| 82 // This is deref()ed in the weak callback of the v8::Context. |
| 83 scriptState->ref(); |
| 84 return scriptState; |
77 } | 85 } |
| 86 |
| 87 ScriptStateForTesting::ScriptStateForTesting(v8::Handle<v8::Context> context, Pa
ssRefPtr<DOMWrapperWorld> world) |
| 88 : ScriptState(context, world) |
| 89 { |
| 90 } |
| 91 |
| 92 ExecutionContext* ScriptStateForTesting::executionContext() const |
| 93 { |
| 94 return m_executionContext.get(); |
| 95 } |
| 96 |
| 97 void ScriptStateForTesting::setExecutionContext(PassRefPtr<ExecutionContext> exe
cutionContext) |
| 98 { |
| 99 m_executionContext = executionContext; |
| 100 } |
| 101 |
| 102 } |
OLD | NEW |