OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 10 matching lines...) Expand all Loading... | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "bindings/core/v8/WorkerScriptController.h" | 31 #include "bindings/core/v8/IsolatedScriptController.h" |
32 | 32 |
33 #include "bindings/core/v8/ScriptSourceCode.h" | 33 #include "bindings/core/v8/ScriptSourceCode.h" |
34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
35 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" | 35 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" |
36 #include "bindings/core/v8/V8ErrorHandler.h" | 36 #include "bindings/core/v8/V8ErrorHandler.h" |
37 #include "bindings/core/v8/V8Initializer.h" | 37 #include "bindings/core/v8/V8Initializer.h" |
38 #include "bindings/core/v8/V8ObjectConstructor.h" | 38 #include "bindings/core/v8/V8ObjectConstructor.h" |
39 #include "bindings/core/v8/V8ScriptRunner.h" | 39 #include "bindings/core/v8/V8ScriptRunner.h" |
40 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" | 40 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" |
41 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 41 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
42 #include "bindings/core/v8/WrapperTypeInfo.h" | 42 #include "bindings/core/v8/WrapperTypeInfo.h" |
43 #include "core/events/ErrorEvent.h" | 43 #include "core/events/ErrorEvent.h" |
44 #include "core/frame/DOMTimer.h" | 44 #include "core/frame/DOMTimer.h" |
45 #include "core/inspector/ScriptCallStack.h" | 45 #include "core/inspector/ScriptCallStack.h" |
46 #include "core/inspector/WorkerThreadDebugger.h" | 46 #include "core/inspector/WorkerThreadDebugger.h" |
47 #include "core/workers/SharedWorkerGlobalScope.h" | 47 #include "core/workers/SharedWorkerGlobalScope.h" |
48 #include "core/workers/WorkerGlobalScope.h" | 48 #include "core/workers/WorkerGlobalScope.h" |
49 #include "core/workers/WorkerObjectProxy.h" | 49 #include "core/workers/WorkerObjectProxy.h" |
50 #include "core/workers/WorkerThread.h" | 50 #include "core/workers/WorkerThread.h" |
51 #include "platform/heap/ThreadState.h" | 51 #include "platform/heap/ThreadState.h" |
52 #include "public/platform/Platform.h" | 52 #include "public/platform/Platform.h" |
53 #include <v8.h> | 53 #include <v8.h> |
54 | 54 |
55 namespace blink { | 55 namespace blink { |
56 | 56 |
57 class WorkerScriptController::ExecutionState final { | 57 class IsolatedScriptController::ExecutionState final { |
58 STACK_ALLOCATED(); | 58 STACK_ALLOCATED(); |
59 public: | 59 public: |
60 explicit ExecutionState(WorkerScriptController* controller) | 60 explicit ExecutionState(IsolatedScriptController* controller) |
61 : hadException(false) | 61 : hadException(false) |
62 , lineNumber(0) | 62 , lineNumber(0) |
63 , columnNumber(0) | 63 , columnNumber(0) |
64 , m_controller(controller) | 64 , m_controller(controller) |
65 , m_outerState(controller->m_executionState) | 65 , m_outerState(controller->m_executionState) |
66 { | 66 { |
67 m_controller->m_executionState = this; | 67 m_controller->m_executionState = this; |
68 } | 68 } |
69 | 69 |
70 ~ExecutionState() | 70 ~ExecutionState() |
71 { | 71 { |
72 m_controller->m_executionState = m_outerState; | 72 m_controller->m_executionState = m_outerState; |
73 } | 73 } |
74 | 74 |
75 DEFINE_INLINE_TRACE() | 75 DEFINE_INLINE_TRACE() |
76 { | 76 { |
77 visitor->trace(m_errorEventFromImportedScript); | 77 visitor->trace(m_errorEventFromImportedScript); |
78 visitor->trace(m_controller); | 78 visitor->trace(m_controller); |
79 } | 79 } |
80 | 80 |
81 bool hadException; | 81 bool hadException; |
82 String errorMessage; | 82 String errorMessage; |
83 int lineNumber; | 83 int lineNumber; |
84 int columnNumber; | 84 int columnNumber; |
85 String sourceURL; | 85 String sourceURL; |
86 ScriptValue exception; | 86 ScriptValue exception; |
87 RefPtrWillBeMember<ErrorEvent> m_errorEventFromImportedScript; | 87 RefPtrWillBeMember<ErrorEvent> m_errorEventFromImportedScript; |
88 | 88 |
89 // A ExecutionState context is stack allocated by | 89 // A ExecutionState context is stack allocated by |
90 // WorkerScriptController::evaluate(), with the contoller using it | 90 // IsolatedScriptController::evaluate(), with the contoller using it |
91 // during script evaluation. To handle nested evaluate() uses, | 91 // during script evaluation. To handle nested evaluate() uses, |
92 // ExecutionStates are chained together; | 92 // ExecutionStates are chained together; |
93 // |m_outerState| keeps a pointer to the context object one level out | 93 // |m_outerState| keeps a pointer to the context object one level out |
94 // (or 0, if outermost.) Upon return from evaluate(), the | 94 // (or 0, if outermost.) Upon return from evaluate(), the |
95 // WorkerScriptController's ExecutionState is popped and the previous one | 95 // IsolatedScriptController's ExecutionState is popped and the previous |
96 // restored (see above dtor.) | 96 // one restored (see above dtor.) |
97 // | 97 // |
98 // With Oilpan, |m_outerState| isn't traced. It'll be "up the stack" | 98 // With Oilpan, |m_outerState| isn't traced. It'll be "up the stack" |
99 // and its fields will be traced when scanning the stack. | 99 // and its fields will be traced when scanning the stack. |
100 RawPtrWillBeMember<WorkerScriptController> m_controller; | 100 RawPtrWillBeMember<IsolatedScriptController> m_controller; |
101 ExecutionState* m_outerState; | 101 ExecutionState* m_outerState; |
102 }; | 102 }; |
103 | 103 |
104 PassOwnPtrWillBeRawPtr<WorkerScriptController> WorkerScriptController::create(Wo rkerGlobalScope* workerGlobalScope, v8::Isolate* isolate) | 104 PassOwnPtrWillBeRawPtr<IsolatedScriptController> IsolatedScriptController::creat e(ExecutionContext* executionContext, ScriptWrappable* scriptWrappable, v8::Isol ate* isolate) |
105 { | 105 { |
106 return adoptPtrWillBeNoop(new WorkerScriptController(workerGlobalScope, isol ate)); | 106 return adoptPtrWillBeNoop(new IsolatedScriptController(executionContext, scr iptWrappable, isolate)); |
107 } | 107 } |
108 | 108 |
109 WorkerScriptController::WorkerScriptController(WorkerGlobalScope* workerGlobalSc ope, v8::Isolate* isolate) | 109 IsolatedScriptController::IsolatedScriptController(ExecutionContext* executionCo ntext, ScriptWrappable* scriptWrappable, v8::Isolate* isolate) |
110 : m_workerGlobalScope(workerGlobalScope) | 110 : m_executionContext(executionContext) |
111 , m_scriptWrappable(scriptWrappable) | |
112 , m_isolate(isolate) | |
111 , m_executionForbidden(false) | 113 , m_executionForbidden(false) |
112 , m_executionScheduledToTerminate(false) | 114 , m_executionScheduledToTerminate(false) |
113 , m_rejectedPromises(RejectedPromises::create()) | 115 , m_rejectedPromises(RejectedPromises::create()) |
114 , m_executionState(0) | 116 , m_executionState(0) |
115 { | 117 { |
118 ASSERT(executionContext->isWorkerGlobalScope() || executionContext->isWorkle tGlobalScope()); | |
116 ASSERT(isolate); | 119 ASSERT(isolate); |
117 m_world = DOMWrapperWorld::create(isolate, WorkerWorldId); | 120 m_world = DOMWrapperWorld::create(isolate, WorkerWorldId); |
118 } | 121 } |
119 | 122 |
120 WorkerScriptController::~WorkerScriptController() | 123 IsolatedScriptController::~IsolatedScriptController() |
121 { | 124 { |
122 ASSERT(!m_rejectedPromises); | 125 ASSERT(!m_rejectedPromises); |
123 } | 126 } |
124 | 127 |
125 void WorkerScriptController::dispose() | 128 void IsolatedScriptController::dispose() |
126 { | 129 { |
127 m_rejectedPromises->dispose(); | 130 m_rejectedPromises->dispose(); |
128 m_rejectedPromises.release(); | 131 m_rejectedPromises.release(); |
129 | 132 |
130 m_world->dispose(); | 133 m_world->dispose(); |
131 | 134 |
132 if (isContextInitialized()) | 135 if (isContextInitialized()) |
133 m_scriptState->disposePerContextData(); | 136 m_scriptState->disposePerContextData(); |
134 } | 137 } |
135 | 138 |
136 bool WorkerScriptController::initializeContextIfNeeded() | 139 bool IsolatedScriptController::initializeContextIfNeeded() |
137 { | 140 { |
138 v8::HandleScope handleScope(isolate()); | 141 v8::HandleScope handleScope(m_isolate); |
139 | 142 |
140 if (isContextInitialized()) | 143 if (isContextInitialized()) |
141 return true; | 144 return true; |
142 | 145 |
143 v8::Local<v8::Context> context = v8::Context::New(isolate()); | 146 v8::Local<v8::Context> context = v8::Context::New(m_isolate); |
144 if (context.IsEmpty()) | 147 if (context.IsEmpty()) |
145 return false; | 148 return false; |
146 | 149 |
147 m_scriptState = ScriptState::create(context, m_world); | 150 m_scriptState = ScriptState::create(context, m_world); |
148 | 151 |
149 ScriptState::Scope scope(m_scriptState.get()); | 152 ScriptState::Scope scope(m_scriptState.get()); |
150 | 153 |
151 // Name new context for debugging. | 154 // Name new context for debugging. |
152 WorkerThreadDebugger::setContextDebugData(context); | 155 WorkerThreadDebugger::setContextDebugData(context); |
153 | 156 |
154 // Create a new JS object and use it as the prototype for the shadow global object. | 157 // Create a new JS object and use it as the prototype for the shadow global object. |
155 const WrapperTypeInfo* wrapperTypeInfo = m_workerGlobalScope->wrapperTypeInf o(); | 158 const WrapperTypeInfo* wrapperTypeInfo = m_scriptWrappable->wrapperTypeInfo( ); |
156 v8::Local<v8::Function> workerGlobalScopeConstructor = m_scriptState->perCon textData()->constructorForType(wrapperTypeInfo); | 159 |
157 if (workerGlobalScopeConstructor.IsEmpty()) | 160 v8::Local<v8::Function> isolatedGlobalScopeConstructor = m_scriptState->perC ontextData()->constructorForType(wrapperTypeInfo); |
161 if (isolatedGlobalScopeConstructor.IsEmpty()) | |
158 return false; | 162 return false; |
159 v8::Local<v8::Object> jsWorkerGlobalScope; | 163 |
160 if (!V8ObjectConstructor::newInstance(isolate(), workerGlobalScopeConstructo r).ToLocal(&jsWorkerGlobalScope)) { | 164 v8::Local<v8::Object> jsGlobalScope; |
165 if (!V8ObjectConstructor::newInstance(m_isolate, isolatedGlobalScopeConstruc tor).ToLocal(&jsGlobalScope)) { | |
161 m_scriptState->disposePerContextData(); | 166 m_scriptState->disposePerContextData(); |
162 return false; | 167 return false; |
163 } | 168 } |
164 | 169 |
165 jsWorkerGlobalScope = V8DOMWrapper::associateObjectWithWrapper(isolate(), m_ workerGlobalScope, wrapperTypeInfo, jsWorkerGlobalScope); | 170 jsGlobalScope = V8DOMWrapper::associateObjectWithWrapper(m_isolate, m_script Wrappable, wrapperTypeInfo, jsGlobalScope); |
166 | 171 |
167 // Insert the object instance as the prototype of the shadow object. | 172 // Insert the object instance as the prototype of the shadow object. |
168 v8::Local<v8::Object> globalObject = v8::Local<v8::Object>::Cast(m_scriptSta te->context()->Global()->GetPrototype()); | 173 v8::Local<v8::Object> globalObject = v8::Local<v8::Object>::Cast(m_scriptSta te->context()->Global()->GetPrototype()); |
169 return v8CallBoolean(globalObject->SetPrototype(context, jsWorkerGlobalScope )); | 174 return v8CallBoolean(globalObject->SetPrototype(context, jsGlobalScope)); |
170 } | 175 } |
171 | 176 |
172 v8::Isolate* WorkerScriptController::isolate() const | 177 ScriptValue IsolatedScriptController::evaluate(const String& script, const Strin g& fileName, const TextPosition& scriptStartPosition, CachedMetadataHandler* cac heHandler, V8CacheOptions v8CacheOptions) |
173 { | |
174 return m_workerGlobalScope->thread()->isolate(); | |
175 } | |
176 | |
177 ScriptValue WorkerScriptController::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, CachedMetadataHandler* cache Handler, V8CacheOptions v8CacheOptions) | |
178 { | 178 { |
179 if (!initializeContextIfNeeded()) | 179 if (!initializeContextIfNeeded()) |
180 return ScriptValue(); | 180 return ScriptValue(); |
181 | 181 |
182 ScriptState::Scope scope(m_scriptState.get()); | 182 ScriptState::Scope scope(m_scriptState.get()); |
183 | 183 |
184 if (!m_disableEvalPending.isEmpty()) { | 184 if (!m_disableEvalPending.isEmpty()) { |
185 m_scriptState->context()->AllowCodeGenerationFromStrings(false); | 185 m_scriptState->context()->AllowCodeGenerationFromStrings(false); |
186 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8 String(isolate(), m_disableEvalPending)); | 186 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8 String(m_isolate, m_disableEvalPending)); |
187 m_disableEvalPending = String(); | 187 m_disableEvalPending = String(); |
188 } | 188 } |
189 | 189 |
190 v8::TryCatch block(isolate()); | 190 v8::TryCatch block(m_isolate); |
191 | 191 |
192 v8::Local<v8::Script> compiledScript; | 192 v8::Local<v8::Script> compiledScript; |
193 v8::MaybeLocal<v8::Value> maybeResult; | 193 v8::MaybeLocal<v8::Value> maybeResult; |
194 if (v8Call(V8ScriptRunner::compileScript(script, fileName, String(), scriptS tartPosition, isolate(), cacheHandler, SharableCrossOrigin, v8CacheOptions), com piledScript, block)) | 194 if (v8Call(V8ScriptRunner::compileScript(script, fileName, String(), scriptS tartPosition, m_isolate, cacheHandler, SharableCrossOrigin, v8CacheOptions), com piledScript, block)) |
195 maybeResult = V8ScriptRunner::runCompiledScript(isolate(), compiledScrip t, m_workerGlobalScope); | 195 maybeResult = V8ScriptRunner::runCompiledScript(m_isolate, compiledScrip t, m_executionContext); |
196 | 196 |
197 if (!block.CanContinue()) { | 197 if (!block.CanContinue()) { |
198 forbidExecution(); | 198 forbidExecution(); |
199 return ScriptValue(); | 199 return ScriptValue(); |
200 } | 200 } |
201 | 201 |
202 if (block.HasCaught()) { | 202 if (block.HasCaught()) { |
203 v8::Local<v8::Message> message = block.Message(); | 203 v8::Local<v8::Message> message = block.Message(); |
204 m_executionState->hadException = true; | 204 m_executionState->hadException = true; |
205 m_executionState->errorMessage = toCoreString(message->Get()); | 205 m_executionState->errorMessage = toCoreString(message->Get()); |
(...skipping 13 matching lines...) Expand all Loading... | |
219 m_executionState->hadException = false; | 219 m_executionState->hadException = false; |
220 } | 220 } |
221 | 221 |
222 v8::Local<v8::Value> result; | 222 v8::Local<v8::Value> result; |
223 if (!maybeResult.ToLocal(&result) || result->IsUndefined()) | 223 if (!maybeResult.ToLocal(&result) || result->IsUndefined()) |
224 return ScriptValue(); | 224 return ScriptValue(); |
225 | 225 |
226 return ScriptValue(m_scriptState.get(), result); | 226 return ScriptValue(m_scriptState.get(), result); |
227 } | 227 } |
228 | 228 |
229 bool WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr WillBeRawPtr<ErrorEvent>* errorEvent, CachedMetadataHandler* cacheHandler, V8Cac heOptions v8CacheOptions) | 229 bool IsolatedScriptController::evaluate(const ScriptSourceCode& sourceCode, RefP trWillBeRawPtr<ErrorEvent>* errorEvent, CachedMetadataHandler* cacheHandler, V8C acheOptions v8CacheOptions) |
230 { | 230 { |
231 if (isExecutionForbidden()) | 231 if (isExecutionForbidden()) |
232 return false; | 232 return false; |
233 | 233 |
234 ExecutionState state(this); | 234 ExecutionState state(this); |
235 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), cacheHandler, v8CacheOptions); | 235 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), cacheHandler, v8CacheOptions); |
236 if (isExecutionForbidden()) | 236 if (isExecutionForbidden()) |
237 return false; | 237 return false; |
238 if (state.hadException) { | 238 if (state.hadException) { |
239 if (errorEvent) { | 239 if (errorEvent) { |
240 if (state.m_errorEventFromImportedScript) { | 240 if (state.m_errorEventFromImportedScript) { |
241 // Propagate inner error event outwards. | 241 // Propagate inner error event outwards. |
242 *errorEvent = state.m_errorEventFromImportedScript.release(); | 242 *errorEvent = state.m_errorEventFromImportedScript.release(); |
243 return false; | 243 return false; |
244 } | 244 } |
245 if (m_workerGlobalScope->shouldSanitizeScriptError(state.sourceURL, NotSharableCrossOrigin)) | 245 if (m_executionContext->shouldSanitizeScriptError(state.sourceURL, N otSharableCrossOrigin)) |
246 *errorEvent = ErrorEvent::createSanitizedError(m_world.get()); | 246 *errorEvent = ErrorEvent::createSanitizedError(m_world.get()); |
247 else | 247 else |
248 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc eURL, state.lineNumber, state.columnNumber, m_world.get()); | 248 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc eURL, state.lineNumber, state.columnNumber, m_world.get()); |
249 V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_scriptState.get( ), errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Globa l()); | 249 V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_scriptState.get( ), errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Globa l()); |
250 } else { | 250 } else { |
251 ASSERT(!m_workerGlobalScope->shouldSanitizeScriptError(state.sourceU RL, NotSharableCrossOrigin)); | 251 ASSERT(!m_executionContext->shouldSanitizeScriptError(state.sourceUR L, NotSharableCrossOrigin)); |
252 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; | 252 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; |
253 if (state.m_errorEventFromImportedScript) | 253 if (state.m_errorEventFromImportedScript) |
254 event = state.m_errorEventFromImportedScript.release(); | 254 event = state.m_errorEventFromImportedScript.release(); |
255 else | 255 else |
256 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get()); | 256 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get()); |
257 m_workerGlobalScope->reportException(event, 0, nullptr, NotSharableC rossOrigin); | 257 m_executionContext->reportException(event, 0, nullptr, NotSharableCr ossOrigin); |
258 } | 258 } |
259 return false; | 259 return false; |
260 } | 260 } |
261 return true; | 261 return true; |
262 } | 262 } |
263 | 263 |
264 void WorkerScriptController::willScheduleExecutionTermination() | 264 void IsolatedScriptController::willScheduleExecutionTermination() |
265 { | 265 { |
266 // The mutex provides a memory barrier to ensure that once | 266 // The mutex provides a memory barrier to ensure that once |
267 // termination is scheduled, isExecutionTerminating will | 267 // termination is scheduled, isExecutionTerminating will |
268 // accurately reflect that state when called from another thread. | 268 // accurately reflect that state when called from another thread. |
269 MutexLocker locker(m_scheduledTerminationMutex); | 269 MutexLocker locker(m_scheduledTerminationMutex); |
270 m_executionScheduledToTerminate = true; | 270 m_executionScheduledToTerminate = true; |
271 } | 271 } |
272 | 272 |
273 bool WorkerScriptController::isExecutionTerminating() const | 273 bool IsolatedScriptController::isExecutionTerminating() const |
274 { | 274 { |
275 // See comments in willScheduleExecutionTermination regarding mutex usage. | 275 // See comments in willScheduleExecutionTermination regarding mutex usage. |
276 MutexLocker locker(m_scheduledTerminationMutex); | 276 MutexLocker locker(m_scheduledTerminationMutex); |
277 return m_executionScheduledToTerminate; | 277 return m_executionScheduledToTerminate; |
278 } | 278 } |
279 | 279 |
280 void WorkerScriptController::forbidExecution() | 280 void IsolatedScriptController::forbidExecution() |
281 { | 281 { |
282 ASSERT(m_workerGlobalScope->isContextThread()); | 282 ASSERT(m_executionContext->isContextThread()); |
283 m_executionForbidden = true; | 283 m_executionForbidden = true; |
284 } | 284 } |
285 | 285 |
286 bool WorkerScriptController::isExecutionForbidden() const | 286 bool IsolatedScriptController::isExecutionForbidden() const |
287 { | 287 { |
288 ASSERT(m_workerGlobalScope->isContextThread()); | 288 ASSERT(m_executionContext->isContextThread()); |
289 return m_executionForbidden; | 289 return m_executionForbidden; |
290 } | 290 } |
291 | 291 |
292 void WorkerScriptController::disableEval(const String& errorMessage) | 292 void IsolatedScriptController::disableEval(const String& errorMessage) |
293 { | 293 { |
294 m_disableEvalPending = errorMessage; | 294 m_disableEvalPending = errorMessage; |
295 } | 295 } |
296 | 296 |
297 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) | 297 void IsolatedScriptController::rethrowExceptionFromImportedScript(PassRefPtrWill BeRawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) |
298 { | 298 { |
299 const String& errorMessage = errorEvent->message(); | 299 const String& errorMessage = errorEvent->message(); |
300 if (m_executionState) | 300 if (m_executionState) |
301 m_executionState->m_errorEventFromImportedScript = errorEvent; | 301 m_executionState->m_errorEventFromImportedScript = errorEvent; |
302 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(isola te(), errorMessage)); | 302 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(m_iso late, errorMessage)); |
303 } | 303 } |
304 | 304 |
305 DEFINE_TRACE(WorkerScriptController) | 305 DEFINE_TRACE(IsolatedScriptController) |
306 { | 306 { |
307 visitor->trace(m_workerGlobalScope); | |
haraken
2016/01/05 06:08:06
You need to keep this code, otherwise the oilpan b
ikilpatrick
2016/01/07 22:47:34
Done.
| |
308 visitor->trace(m_rejectedPromises); | 307 visitor->trace(m_rejectedPromises); |
309 } | 308 } |
310 | 309 |
311 } // namespace blink | 310 } // namespace blink |
OLD | NEW |