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/core/v8/ScriptState.h" | 6 #include "bindings/core/v8/ScriptState.h" |
7 | 7 |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/frame/LocalDOMWindow.h" | 10 #include "core/frame/LocalDOMWindow.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return toLocalDOMWindow(toDOMWindow(context())); | 109 return toLocalDOMWindow(toDOMWindow(context())); |
110 } | 110 } |
111 | 111 |
112 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) | 112 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) |
113 { | 113 { |
114 v8::Isolate* isolate = toIsolate(frame); | 114 v8::Isolate* isolate = toIsolate(frame); |
115 v8::HandleScope handleScope(isolate); | 115 v8::HandleScope handleScope(isolate); |
116 return ScriptState::from(toV8Context(frame, DOMWrapperWorld::mainWorld())); | 116 return ScriptState::from(toV8Context(frame, DOMWrapperWorld::mainWorld())); |
117 } | 117 } |
118 | 118 |
119 PassRefPtr<ScriptStateForTesting> ScriptStateForTesting::create(v8::Handle<v8::C
ontext> context, PassRefPtr<DOMWrapperWorld> world) | |
120 { | |
121 RefPtr<ScriptStateForTesting> scriptState = adoptRef(new ScriptStateForTesti
ng(context, world)); | |
122 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. | |
123 // This is deref()ed in the weak callback of the v8::Context. | |
124 scriptState->ref(); | |
125 return scriptState; | |
126 } | 119 } |
127 | |
128 ScriptStateForTesting::ScriptStateForTesting(v8::Handle<v8::Context> context, Pa
ssRefPtr<DOMWrapperWorld> world) | |
129 : ScriptState(context, world) | |
130 { | |
131 } | |
132 | |
133 ExecutionContext* ScriptStateForTesting::executionContext() const | |
134 { | |
135 return m_executionContext; | |
136 } | |
137 | |
138 void ScriptStateForTesting::setExecutionContext(ExecutionContext* executionConte
xt) | |
139 { | |
140 m_executionContext = executionContext; | |
141 } | |
142 | |
143 } | |
OLD | NEW |