| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } else { | 231 } else { |
| 232 m_globalScopeExecutionState->hadException = false; | 232 m_globalScopeExecutionState->hadException = false; |
| 233 } | 233 } |
| 234 | 234 |
| 235 if (result.IsEmpty() || result->IsUndefined()) | 235 if (result.IsEmpty() || result->IsUndefined()) |
| 236 return ScriptValue(); | 236 return ScriptValue(); |
| 237 | 237 |
| 238 return ScriptValue(m_scriptState.get(), result); | 238 return ScriptValue(m_scriptState.get(), result); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr
WillBeRawPtr<ErrorEvent>* errorEvent) | 241 bool WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr
WillBeRawPtr<ErrorEvent>* errorEvent) |
| 242 { | 242 { |
| 243 if (isExecutionForbidden()) | 243 if (isExecutionForbidden()) |
| 244 return; | 244 return false; |
| 245 | 245 |
| 246 WorkerGlobalScopeExecutionState state(this); | 246 WorkerGlobalScopeExecutionState state(this); |
| 247 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos
ition()); | 247 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos
ition()); |
| 248 if (state.hadException) { | 248 if (state.hadException) { |
| 249 if (errorEvent) { | 249 if (errorEvent) { |
| 250 if (state.m_errorEventFromImportedScript) { | 250 if (state.m_errorEventFromImportedScript) { |
| 251 // Propagate inner error event outwards. | 251 // Propagate inner error event outwards. |
| 252 *errorEvent = state.m_errorEventFromImportedScript.release(); | 252 *errorEvent = state.m_errorEventFromImportedScript.release(); |
| 253 return; | 253 return false; |
| 254 } | 254 } |
| 255 if (m_workerGlobalScope.shouldSanitizeScriptError(state.sourceURL, N
otSharableCrossOrigin)) | 255 if (m_workerGlobalScope.shouldSanitizeScriptError(state.sourceURL, N
otSharableCrossOrigin)) |
| 256 *errorEvent = ErrorEvent::createSanitizedError(m_world.get()); | 256 *errorEvent = ErrorEvent::createSanitizedError(m_world.get()); |
| 257 else | 257 else |
| 258 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc
eURL, state.lineNumber, state.columnNumber, m_world.get()); | 258 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc
eURL, state.lineNumber, state.columnNumber, m_world.get()); |
| 259 V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_isolate, errorEv
ent->get(), state.exception.v8Value(), m_scriptState->context()->Global()); | 259 V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_isolate, errorEv
ent->get(), state.exception.v8Value(), m_scriptState->context()->Global()); |
| 260 } else { | 260 } else { |
| 261 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR
L, NotSharableCrossOrigin)); | 261 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR
L, NotSharableCrossOrigin)); |
| 262 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; | 262 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; |
| 263 if (state.m_errorEventFromImportedScript) | 263 if (state.m_errorEventFromImportedScript) |
| 264 event = state.m_errorEventFromImportedScript.release(); | 264 event = state.m_errorEventFromImportedScript.release(); |
| 265 else | 265 else |
| 266 event = ErrorEvent::create(state.errorMessage, state.sourceURL,
state.lineNumber, state.columnNumber, m_world.get()); | 266 event = ErrorEvent::create(state.errorMessage, state.sourceURL,
state.lineNumber, state.columnNumber, m_world.get()); |
| 267 m_workerGlobalScope.reportException(event, 0, nullptr, NotSharableCr
ossOrigin); | 267 m_workerGlobalScope.reportException(event, 0, nullptr, NotSharableCr
ossOrigin); |
| 268 } | 268 } |
| 269 return false; |
| 269 } | 270 } |
| 271 return true; |
| 270 } | 272 } |
| 271 | 273 |
| 272 void WorkerScriptController::scheduleExecutionTermination() | 274 void WorkerScriptController::scheduleExecutionTermination() |
| 273 { | 275 { |
| 274 // The mutex provides a memory barrier to ensure that once | 276 // The mutex provides a memory barrier to ensure that once |
| 275 // termination is scheduled, isExecutionTerminating will | 277 // termination is scheduled, isExecutionTerminating will |
| 276 // accurately reflect that state when called from another thread. | 278 // accurately reflect that state when called from another thread. |
| 277 { | 279 { |
| 278 MutexLocker locker(m_scheduledTerminationMutex); | 280 MutexLocker locker(m_scheduledTerminationMutex); |
| 279 m_executionScheduledToTerminate = true; | 281 m_executionScheduledToTerminate = true; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 307 | 309 |
| 308 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) | 310 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) |
| 309 { | 311 { |
| 310 const String& errorMessage = errorEvent->message(); | 312 const String& errorMessage = errorEvent->message(); |
| 311 if (m_globalScopeExecutionState) | 313 if (m_globalScopeExecutionState) |
| 312 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent
; | 314 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent
; |
| 313 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(m_iso
late, errorMessage)); | 315 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(m_iso
late, errorMessage)); |
| 314 } | 316 } |
| 315 | 317 |
| 316 } // namespace blink | 318 } // namespace blink |
| OLD | NEW |