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/GlobalScopeScriptController.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" | |
49 #include "core/workers/WorkerObjectProxy.h" | 48 #include "core/workers/WorkerObjectProxy.h" |
50 #include "core/workers/WorkerThread.h" | |
51 #include "platform/heap/ThreadState.h" | 49 #include "platform/heap/ThreadState.h" |
52 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
53 #include <v8.h> | 51 #include <v8.h> |
54 | 52 |
55 namespace blink { | 53 namespace blink { |
56 | 54 |
57 class WorkerScriptController::WorkerGlobalScopeExecutionState final { | 55 class GlobalScopeScriptController::ExecutionState final { |
kinuko
2015/12/24 04:45:51
nit: this renaming change could be probably landed
| |
58 STACK_ALLOCATED(); | 56 STACK_ALLOCATED(); |
59 public: | 57 public: |
60 explicit WorkerGlobalScopeExecutionState(WorkerScriptController* controller) | 58 explicit ExecutionState(GlobalScopeScriptController* controller) |
61 : hadException(false) | 59 : hadException(false) |
62 , lineNumber(0) | 60 , lineNumber(0) |
63 , columnNumber(0) | 61 , columnNumber(0) |
64 , m_controller(controller) | 62 , m_controller(controller) |
65 , m_outerState(controller->m_globalScopeExecutionState) | 63 , m_outerState(controller->m_executionState) |
66 { | 64 { |
67 m_controller->m_globalScopeExecutionState = this; | 65 m_controller->m_executionState = this; |
68 } | 66 } |
69 | 67 |
70 ~WorkerGlobalScopeExecutionState() | 68 ~ExecutionState() |
71 { | 69 { |
72 m_controller->m_globalScopeExecutionState = m_outerState; | 70 m_controller->m_executionState = m_outerState; |
73 } | 71 } |
74 | 72 |
75 DEFINE_INLINE_TRACE() | 73 DEFINE_INLINE_TRACE() |
76 { | 74 { |
77 visitor->trace(m_errorEventFromImportedScript); | 75 visitor->trace(m_errorEventFromImportedScript); |
78 visitor->trace(m_controller); | 76 visitor->trace(m_controller); |
79 } | 77 } |
80 | 78 |
81 bool hadException; | 79 bool hadException; |
82 String errorMessage; | 80 String errorMessage; |
83 int lineNumber; | 81 int lineNumber; |
84 int columnNumber; | 82 int columnNumber; |
85 String sourceURL; | 83 String sourceURL; |
86 ScriptValue exception; | 84 ScriptValue exception; |
87 RefPtrWillBeMember<ErrorEvent> m_errorEventFromImportedScript; | 85 RefPtrWillBeMember<ErrorEvent> m_errorEventFromImportedScript; |
88 | 86 |
89 // A WorkerGlobalScopeExecutionState context is stack allocated by | 87 // A ExecutionState context is stack allocated by |
90 // WorkerScriptController::evaluate(), with the contoller using it | 88 // GlobalScopeScriptController::evaluate(), with the contoller using it |
91 // during script evaluation. To handle nested evaluate() uses, | 89 // during script evaluation. To handle nested evaluate() uses, |
92 // WorkerGlobalScopeExecutionStates are chained together; | 90 // ExecutionStates are chained together; |
93 // |m_outerState| keeps a pointer to the context object one level out | 91 // |m_outerState| keeps a pointer to the context object one level out |
94 // (or 0, if outermost.) Upon return from evaluate(), the | 92 // (or 0, if outermost.) Upon return from evaluate(), the |
95 // WorkerScriptController's WorkerGlobalScopeExecutionState is popped | 93 // GlobalScopeScriptController's ExecutionState is popped and the previous |
96 // and the previous one restored (see above dtor.) | 94 // one restored (see above dtor.) |
97 // | 95 // |
98 // With Oilpan, |m_outerState| isn't traced. It'll be "up the stack" | 96 // With Oilpan, |m_outerState| isn't traced. It'll be "up the stack" |
99 // and its fields will be traced when scanning the stack. | 97 // and its fields will be traced when scanning the stack. |
100 RawPtrWillBeMember<WorkerScriptController> m_controller; | 98 RawPtrWillBeMember<GlobalScopeScriptController> m_controller; |
101 WorkerGlobalScopeExecutionState* m_outerState; | 99 ExecutionState* m_outerState; |
102 }; | 100 }; |
103 | 101 |
104 PassOwnPtrWillBeRawPtr<WorkerScriptController> WorkerScriptController::create(Wo rkerGlobalScope* workerGlobalScope, v8::Isolate* isolate) | 102 GlobalScopeScriptController::GlobalScopeScriptController(v8::Isolate* isolate) |
105 { | 103 : m_executionForbidden(false) |
106 return adoptPtrWillBeNoop(new WorkerScriptController(workerGlobalScope, isol ate)); | |
107 } | |
108 | |
109 WorkerScriptController::WorkerScriptController(WorkerGlobalScope* workerGlobalSc ope, v8::Isolate* isolate) | |
110 : m_workerGlobalScope(workerGlobalScope) | |
111 , m_executionForbidden(false) | |
112 , m_executionScheduledToTerminate(false) | 104 , m_executionScheduledToTerminate(false) |
113 , m_rejectedPromises(RejectedPromises::create()) | 105 , m_rejectedPromises(RejectedPromises::create()) |
114 , m_globalScopeExecutionState(0) | 106 , m_executionState(0) |
115 { | 107 { |
116 ASSERT(isolate); | 108 ASSERT(isolate); |
117 m_world = DOMWrapperWorld::create(isolate, WorkerWorldId); | 109 m_world = DOMWrapperWorld::create(isolate, WorkerWorldId); |
118 } | 110 } |
119 | 111 |
120 WorkerScriptController::~WorkerScriptController() | 112 GlobalScopeScriptController::~GlobalScopeScriptController() |
121 { | 113 { |
122 ASSERT(!m_rejectedPromises); | 114 ASSERT(!m_rejectedPromises); |
123 } | 115 } |
124 | 116 |
125 void WorkerScriptController::dispose() | 117 void GlobalScopeScriptController::dispose() |
126 { | 118 { |
127 m_rejectedPromises->dispose(); | 119 m_rejectedPromises->dispose(); |
128 m_rejectedPromises.release(); | 120 m_rejectedPromises.release(); |
129 | 121 |
130 m_world->dispose(); | 122 m_world->dispose(); |
131 | 123 |
132 // The corresponding call to didStartRunLoop() is in WorkerThread::initializ e(). | 124 // The corresponding call to didStartRunLoop() is in WorkerThread::initializ e(). |
133 // See http://webkit.org/b/83104#c14 for why this is here. | 125 // See http://webkit.org/b/83104#c14 for why this is here. |
134 m_workerGlobalScope->thread()->didStopRunLoop(); | 126 didStopRunLoop(); |
135 | 127 |
136 if (isContextInitialized()) | 128 if (isContextInitialized()) |
137 m_scriptState->disposePerContextData(); | 129 m_scriptState->disposePerContextData(); |
138 } | 130 } |
139 | 131 |
140 bool WorkerScriptController::initializeContextIfNeeded() | 132 bool GlobalScopeScriptController::initializeContextIfNeeded() |
141 { | 133 { |
142 v8::HandleScope handleScope(isolate()); | 134 v8::HandleScope handleScope(isolate()); |
143 | 135 |
144 if (isContextInitialized()) | 136 if (isContextInitialized()) |
145 return true; | 137 return true; |
146 | 138 |
147 v8::Local<v8::Context> context = v8::Context::New(isolate()); | 139 v8::Local<v8::Context> context = v8::Context::New(isolate()); |
148 if (context.IsEmpty()) | 140 if (context.IsEmpty()) |
149 return false; | 141 return false; |
150 | 142 |
151 m_scriptState = ScriptState::create(context, m_world); | 143 m_scriptState = ScriptState::create(context, m_world); |
152 | 144 |
153 ScriptState::Scope scope(m_scriptState.get()); | 145 ScriptState::Scope scope(m_scriptState.get()); |
154 | 146 |
155 // Name new context for debugging. | 147 // Name new context for debugging. |
156 WorkerThreadDebugger::setContextDebugData(context); | 148 WorkerThreadDebugger::setContextDebugData(context); |
157 | 149 |
158 // Create a new JS object and use it as the prototype for the shadow global object. | 150 // Create a new JS object and use it as the prototype for the shadow global object. |
159 const WrapperTypeInfo* wrapperTypeInfo = m_workerGlobalScope->wrapperTypeInf o(); | 151 const WrapperTypeInfo* wrapperTypeInfo = wrapperTypeInfoForGlobalScope(); |
160 v8::Local<v8::Function> workerGlobalScopeConstructor = m_scriptState->perCon textData()->constructorForType(wrapperTypeInfo); | 152 |
161 if (workerGlobalScopeConstructor.IsEmpty()) | 153 v8::Local<v8::Function> isolatedGlobalScopeConstructor = m_scriptState->perC ontextData()->constructorForType(wrapperTypeInfo); |
154 if (isolatedGlobalScopeConstructor.IsEmpty()) | |
162 return false; | 155 return false; |
163 v8::Local<v8::Object> jsWorkerGlobalScope; | 156 |
164 if (!V8ObjectConstructor::newInstance(isolate(), workerGlobalScopeConstructo r).ToLocal(&jsWorkerGlobalScope)) { | 157 v8::Local<v8::Object> jsGlobalScope; |
158 if (!V8ObjectConstructor::newInstance(isolate(), isolatedGlobalScopeConstruc tor).ToLocal(&jsGlobalScope)) { | |
165 m_scriptState->disposePerContextData(); | 159 m_scriptState->disposePerContextData(); |
166 return false; | 160 return false; |
167 } | 161 } |
168 | 162 |
169 jsWorkerGlobalScope = V8DOMWrapper::associateObjectWithWrapper(isolate(), m_ workerGlobalScope, wrapperTypeInfo, jsWorkerGlobalScope); | 163 jsGlobalScope = associateGlobalScopeWithWrapper(wrapperTypeInfo, jsGlobalSco pe); |
170 | 164 |
171 // Insert the object instance as the prototype of the shadow object. | 165 // Insert the object instance as the prototype of the shadow object. |
172 v8::Local<v8::Object> globalObject = v8::Local<v8::Object>::Cast(m_scriptSta te->context()->Global()->GetPrototype()); | 166 v8::Local<v8::Object> globalObject = v8::Local<v8::Object>::Cast(m_scriptSta te->context()->Global()->GetPrototype()); |
173 return v8CallBoolean(globalObject->SetPrototype(context, jsWorkerGlobalScope )); | 167 return v8CallBoolean(globalObject->SetPrototype(context, jsGlobalScope)); |
174 } | 168 } |
175 | 169 |
176 v8::Isolate* WorkerScriptController::isolate() const | 170 ScriptValue GlobalScopeScriptController::evaluate(const String& script, const St ring& fileName, const TextPosition& scriptStartPosition, CachedMetadataHandler* cacheHandler, V8CacheOptions v8CacheOptions) |
177 { | |
178 return m_workerGlobalScope->thread()->isolate(); | |
179 } | |
180 | |
181 ScriptValue WorkerScriptController::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, CachedMetadataHandler* cache Handler, V8CacheOptions v8CacheOptions) | |
182 { | 171 { |
183 if (!initializeContextIfNeeded()) | 172 if (!initializeContextIfNeeded()) |
184 return ScriptValue(); | 173 return ScriptValue(); |
185 | 174 |
186 ScriptState::Scope scope(m_scriptState.get()); | 175 ScriptState::Scope scope(m_scriptState.get()); |
187 | 176 |
188 if (!m_disableEvalPending.isEmpty()) { | 177 if (!m_disableEvalPending.isEmpty()) { |
189 m_scriptState->context()->AllowCodeGenerationFromStrings(false); | 178 m_scriptState->context()->AllowCodeGenerationFromStrings(false); |
190 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8 String(isolate(), m_disableEvalPending)); | 179 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8 String(isolate(), m_disableEvalPending)); |
191 m_disableEvalPending = String(); | 180 m_disableEvalPending = String(); |
192 } | 181 } |
193 | 182 |
194 v8::TryCatch block(isolate()); | 183 v8::TryCatch block(isolate()); |
195 | 184 |
196 v8::Local<v8::Script> compiledScript; | 185 v8::Local<v8::Script> compiledScript; |
197 v8::MaybeLocal<v8::Value> maybeResult; | 186 v8::MaybeLocal<v8::Value> maybeResult; |
198 if (v8Call(V8ScriptRunner::compileScript(script, fileName, String(), scriptS tartPosition, isolate(), cacheHandler, SharableCrossOrigin, v8CacheOptions), com piledScript, block)) | 187 if (v8Call(V8ScriptRunner::compileScript(script, fileName, String(), scriptS tartPosition, isolate(), cacheHandler, SharableCrossOrigin, v8CacheOptions), com piledScript, block)) |
199 maybeResult = V8ScriptRunner::runCompiledScript(isolate(), compiledScrip t, m_workerGlobalScope); | 188 maybeResult = runCompiledScript(compiledScript); |
200 | 189 |
201 if (!block.CanContinue()) { | 190 if (!block.CanContinue()) { |
202 forbidExecution(); | 191 forbidExecution(); |
203 return ScriptValue(); | 192 return ScriptValue(); |
204 } | 193 } |
205 | 194 |
206 if (block.HasCaught()) { | 195 if (block.HasCaught()) { |
207 v8::Local<v8::Message> message = block.Message(); | 196 v8::Local<v8::Message> message = block.Message(); |
208 m_globalScopeExecutionState->hadException = true; | 197 m_executionState->hadException = true; |
209 m_globalScopeExecutionState->errorMessage = toCoreString(message->Get()) ; | 198 m_executionState->errorMessage = toCoreString(message->Get()); |
210 if (v8Call(message->GetLineNumber(m_scriptState->context()), m_globalSco peExecutionState->lineNumber) | 199 if (v8Call(message->GetLineNumber(m_scriptState->context()), m_execution State->lineNumber) |
211 && v8Call(message->GetStartColumn(m_scriptState->context()), m_globa lScopeExecutionState->columnNumber)) { | 200 && v8Call(message->GetStartColumn(m_scriptState->context()), m_execu tionState->columnNumber)) { |
212 ++m_globalScopeExecutionState->columnNumber; | 201 ++m_executionState->columnNumber; |
213 } else { | 202 } else { |
214 m_globalScopeExecutionState->lineNumber = 0; | 203 m_executionState->lineNumber = 0; |
215 m_globalScopeExecutionState->columnNumber = 0; | 204 m_executionState->columnNumber = 0; |
216 } | 205 } |
217 | 206 |
218 TOSTRING_DEFAULT(V8StringResource<>, sourceURL, message->GetScriptOrigin ().ResourceName(), ScriptValue()); | 207 TOSTRING_DEFAULT(V8StringResource<>, sourceURL, message->GetScriptOrigin ().ResourceName(), ScriptValue()); |
219 m_globalScopeExecutionState->sourceURL = sourceURL; | 208 m_executionState->sourceURL = sourceURL; |
220 m_globalScopeExecutionState->exception = ScriptValue(m_scriptState.get() , block.Exception()); | 209 m_executionState->exception = ScriptValue(m_scriptState.get(), block.Exc eption()); |
221 block.Reset(); | 210 block.Reset(); |
222 } else { | 211 } else { |
223 m_globalScopeExecutionState->hadException = false; | 212 m_executionState->hadException = false; |
224 } | 213 } |
225 | 214 |
226 v8::Local<v8::Value> result; | 215 v8::Local<v8::Value> result; |
227 if (!maybeResult.ToLocal(&result) || result->IsUndefined()) | 216 if (!maybeResult.ToLocal(&result) || result->IsUndefined()) |
228 return ScriptValue(); | 217 return ScriptValue(); |
229 | 218 |
230 return ScriptValue(m_scriptState.get(), result); | 219 return ScriptValue(m_scriptState.get(), result); |
231 } | 220 } |
232 | 221 |
233 bool WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr WillBeRawPtr<ErrorEvent>* errorEvent, CachedMetadataHandler* cacheHandler, V8Cac heOptions v8CacheOptions) | 222 bool GlobalScopeScriptController::evaluate(const ScriptSourceCode& sourceCode, R efPtrWillBeRawPtr<ErrorEvent>* errorEvent, CachedMetadataHandler* cacheHandler, V8CacheOptions v8CacheOptions) |
234 { | 223 { |
235 if (isExecutionForbidden()) | 224 if (isExecutionForbidden()) |
236 return false; | 225 return false; |
237 | 226 |
238 WorkerGlobalScopeExecutionState state(this); | 227 ExecutionState state(this); |
239 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), cacheHandler, v8CacheOptions); | 228 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), cacheHandler, v8CacheOptions); |
240 if (isExecutionForbidden()) | 229 if (isExecutionForbidden()) |
241 return false; | 230 return false; |
242 if (state.hadException) { | 231 if (state.hadException) { |
243 if (errorEvent) { | 232 if (errorEvent) { |
244 if (state.m_errorEventFromImportedScript) { | 233 if (state.m_errorEventFromImportedScript) { |
245 // Propagate inner error event outwards. | 234 // Propagate inner error event outwards. |
246 *errorEvent = state.m_errorEventFromImportedScript.release(); | 235 *errorEvent = state.m_errorEventFromImportedScript.release(); |
247 return false; | 236 return false; |
248 } | 237 } |
249 if (m_workerGlobalScope->shouldSanitizeScriptError(state.sourceURL, NotSharableCrossOrigin)) | 238 if (shouldSanitizeScriptError(state.sourceURL, NotSharableCrossOrigi n)) |
250 *errorEvent = ErrorEvent::createSanitizedError(m_world.get()); | 239 *errorEvent = ErrorEvent::createSanitizedError(m_world.get()); |
251 else | 240 else |
252 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc eURL, state.lineNumber, state.columnNumber, m_world.get()); | 241 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc eURL, state.lineNumber, state.columnNumber, m_world.get()); |
253 V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_scriptState.get( ), errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Globa l()); | 242 V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_scriptState.get( ), errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Globa l()); |
254 } else { | 243 } else { |
255 ASSERT(!m_workerGlobalScope->shouldSanitizeScriptError(state.sourceU RL, NotSharableCrossOrigin)); | 244 ASSERT(!shouldSanitizeScriptError(state.sourceURL, NotSharableCrossO rigin)); |
256 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; | 245 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; |
257 if (state.m_errorEventFromImportedScript) | 246 if (state.m_errorEventFromImportedScript) |
258 event = state.m_errorEventFromImportedScript.release(); | 247 event = state.m_errorEventFromImportedScript.release(); |
259 else | 248 else |
260 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get()); | 249 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get()); |
261 m_workerGlobalScope->reportException(event, 0, nullptr, NotSharableC rossOrigin); | 250 reportException(event, 0, nullptr, NotSharableCrossOrigin); |
262 } | 251 } |
263 return false; | 252 return false; |
264 } | 253 } |
265 return true; | 254 return true; |
266 } | 255 } |
267 | 256 |
268 void WorkerScriptController::willScheduleExecutionTermination() | 257 void GlobalScopeScriptController::willScheduleExecutionTermination() |
269 { | 258 { |
270 // The mutex provides a memory barrier to ensure that once | 259 // The mutex provides a memory barrier to ensure that once |
271 // termination is scheduled, isExecutionTerminating will | 260 // termination is scheduled, isExecutionTerminating will |
272 // accurately reflect that state when called from another thread. | 261 // accurately reflect that state when called from another thread. |
273 MutexLocker locker(m_scheduledTerminationMutex); | 262 MutexLocker locker(m_scheduledTerminationMutex); |
274 m_executionScheduledToTerminate = true; | 263 m_executionScheduledToTerminate = true; |
275 } | 264 } |
276 | 265 |
277 bool WorkerScriptController::isExecutionTerminating() const | 266 bool GlobalScopeScriptController::isExecutionTerminating() const |
278 { | 267 { |
279 // See comments in willScheduleExecutionTermination regarding mutex usage. | 268 // See comments in willScheduleExecutionTermination regarding mutex usage. |
280 MutexLocker locker(m_scheduledTerminationMutex); | 269 MutexLocker locker(m_scheduledTerminationMutex); |
281 return m_executionScheduledToTerminate; | 270 return m_executionScheduledToTerminate; |
282 } | 271 } |
283 | 272 |
284 void WorkerScriptController::forbidExecution() | 273 void GlobalScopeScriptController::forbidExecution() |
285 { | 274 { |
286 ASSERT(m_workerGlobalScope->isContextThread()); | 275 ASSERT(isContextThread()); |
287 m_executionForbidden = true; | 276 m_executionForbidden = true; |
288 } | 277 } |
289 | 278 |
290 bool WorkerScriptController::isExecutionForbidden() const | 279 bool GlobalScopeScriptController::isExecutionForbidden() const |
291 { | 280 { |
292 ASSERT(m_workerGlobalScope->isContextThread()); | 281 ASSERT(isContextThread()); |
293 return m_executionForbidden; | 282 return m_executionForbidden; |
294 } | 283 } |
295 | 284 |
296 void WorkerScriptController::disableEval(const String& errorMessage) | 285 void GlobalScopeScriptController::disableEval(const String& errorMessage) |
297 { | 286 { |
298 m_disableEvalPending = errorMessage; | 287 m_disableEvalPending = errorMessage; |
299 } | 288 } |
300 | 289 |
301 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) | 290 void GlobalScopeScriptController::rethrowExceptionFromImportedScript(PassRefPtrW illBeRawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) |
302 { | 291 { |
303 const String& errorMessage = errorEvent->message(); | 292 const String& errorMessage = errorEvent->message(); |
304 if (m_globalScopeExecutionState) | 293 if (m_executionState) |
305 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent ; | 294 m_executionState->m_errorEventFromImportedScript = errorEvent; |
306 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(isola te(), errorMessage)); | 295 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(isola te(), errorMessage)); |
307 } | 296 } |
308 | 297 |
309 DEFINE_TRACE(WorkerScriptController) | 298 DEFINE_TRACE(GlobalScopeScriptController) |
310 { | 299 { |
311 visitor->trace(m_workerGlobalScope); | |
312 visitor->trace(m_rejectedPromises); | 300 visitor->trace(m_rejectedPromises); |
313 } | 301 } |
314 | 302 |
315 } // namespace blink | 303 } // namespace blink |
OLD | NEW |