Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "bindings/v8/WorkerScriptController.h" | 33 #include "bindings/v8/WorkerScriptController.h" |
| 34 | 34 |
| 35 #include "V8DedicatedWorkerGlobalScope.h" | 35 #include "V8DedicatedWorkerGlobalScope.h" |
| 36 #include "V8SharedWorkerGlobalScope.h" | 36 #include "V8SharedWorkerGlobalScope.h" |
| 37 #include "V8WorkerGlobalScope.h" | 37 #include "V8WorkerGlobalScope.h" |
| 38 #include "bindings/v8/ScriptSourceCode.h" | 38 #include "bindings/v8/ScriptSourceCode.h" |
| 39 #include "bindings/v8/ScriptValue.h" | 39 #include "bindings/v8/ScriptValue.h" |
| 40 #include "bindings/v8/V8ErrorHandler.h" | |
| 40 #include "bindings/v8/V8GCController.h" | 41 #include "bindings/v8/V8GCController.h" |
| 41 #include "bindings/v8/V8Initializer.h" | 42 #include "bindings/v8/V8Initializer.h" |
| 42 #include "bindings/v8/V8ObjectConstructor.h" | 43 #include "bindings/v8/V8ObjectConstructor.h" |
| 43 #include "bindings/v8/V8ScriptRunner.h" | 44 #include "bindings/v8/V8ScriptRunner.h" |
| 44 #include "bindings/v8/WrapperTypeInfo.h" | 45 #include "bindings/v8/WrapperTypeInfo.h" |
| 45 #include "core/inspector/ScriptCallStack.h" | 46 #include "core/inspector/ScriptCallStack.h" |
| 46 #include "core/page/DOMTimer.h" | 47 #include "core/page/DOMTimer.h" |
| 47 #include "core/workers/WorkerGlobalScope.h" | 48 #include "core/workers/WorkerGlobalScope.h" |
| 48 #include "core/workers/WorkerObjectProxy.h" | 49 #include "core/workers/WorkerObjectProxy.h" |
| 49 #include "core/workers/WorkerThread.h" | 50 #include "core/workers/WorkerThread.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 return ScriptValue(); | 161 return ScriptValue(); |
| 161 } | 162 } |
| 162 | 163 |
| 163 if (block.HasCaught()) { | 164 if (block.HasCaught()) { |
| 164 v8::Local<v8::Message> message = block.Message(); | 165 v8::Local<v8::Message> message = block.Message(); |
| 165 state->hadException = true; | 166 state->hadException = true; |
| 166 state->errorMessage = toWebCoreString(message->Get()); | 167 state->errorMessage = toWebCoreString(message->Get()); |
| 167 state->lineNumber = message->GetLineNumber(); | 168 state->lineNumber = message->GetLineNumber(); |
| 168 state->columnNumber = message->GetStartColumn(); | 169 state->columnNumber = message->GetStartColumn(); |
| 169 state->sourceURL = toWebCoreString(message->GetScriptResourceName()); | 170 state->sourceURL = toWebCoreString(message->GetScriptResourceName()); |
| 171 state->exception = ScriptValue(block.Exception()); | |
| 170 block.Reset(); | 172 block.Reset(); |
| 171 } else | 173 } else |
| 172 state->hadException = false; | 174 state->hadException = false; |
| 173 | 175 |
| 174 if (result.IsEmpty() || result->IsUndefined()) | 176 if (result.IsEmpty() || result->IsUndefined()) |
| 175 return ScriptValue(); | 177 return ScriptValue(); |
| 176 | 178 |
| 177 return ScriptValue(result); | 179 return ScriptValue(result); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr <ErrorEvent>* errorEvent) | 182 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr <ErrorEvent>* errorEvent) |
| 181 { | 183 { |
| 182 if (isExecutionForbidden()) | 184 if (isExecutionForbidden()) |
| 183 return; | 185 return; |
| 184 | 186 |
| 185 WorkerGlobalScopeExecutionState state; | 187 WorkerGlobalScopeExecutionState state; |
| 186 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state); | 188 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state); |
| 187 if (state.hadException) { | 189 if (state.hadException) { |
| 188 if (errorEvent) { | 190 if (errorEvent) { |
| 189 *errorEvent = m_workerGlobalScope->shouldSanitizeScriptError(state.s ourceURL, NotSharableCrossOrigin) ? | 191 *errorEvent = m_workerGlobalScope->shouldSanitizeScriptError(state.s ourceURL, NotSharableCrossOrigin) ? |
| 190 ErrorEvent::createSanitizedError() : ErrorEvent::create(state.er rorMessage, state.sourceURL, state.lineNumber, state.columnNumber); | 192 ErrorEvent::createSanitizedError() : ErrorEvent::create(state.er rorMessage, state.sourceURL, state.lineNumber, state.columnNumber); |
| 193 V8ErrorHandler::storeExceptionOnErrorEventWrapper(workerGlobalScope( ), errorEvent->get(), state.exception.v8Value(), m_isolate); | |
| 191 } else { | 194 } else { |
| 192 ASSERT(!m_workerGlobalScope->shouldSanitizeScriptError(state.sourceU RL, NotSharableCrossOrigin)); | 195 ASSERT(!m_workerGlobalScope->shouldSanitizeScriptError(state.sourceU RL, NotSharableCrossOrigin)); |
| 193 RefPtr<ErrorEvent> event = m_errorEventFromImportedScript ? m_errorE ventFromImportedScript.release() : ErrorEvent::create(state.errorMessage, state. sourceURL, state.lineNumber, state.columnNumber); | 196 RefPtr<ErrorEvent> event = m_errorEventFromImportedScript ? m_errorE ventFromImportedScript.release() : ErrorEvent::create(state.errorMessage, state. sourceURL, state.lineNumber, state.columnNumber); |
| 194 m_errorEventFromImportedScript.clear(); | |
|
adamk
2013/08/09 17:11:32
Looks like this line was a no-op because of the .r
Mike West
2013/08/09 20:34:51
Correct. I inadvertently left it in a previous CL.
| |
| 195 m_workerGlobalScope->reportException(event, 0, NotSharableCrossOrigi n); | 197 m_workerGlobalScope->reportException(event, 0, NotSharableCrossOrigi n); |
| 196 } | 198 } |
| 197 } | 199 } |
| 198 } | 200 } |
| 199 | 201 |
| 200 void WorkerScriptController::scheduleExecutionTermination() | 202 void WorkerScriptController::scheduleExecutionTermination() |
| 201 { | 203 { |
| 202 // The mutex provides a memory barrier to ensure that once | 204 // The mutex provides a memory barrier to ensure that once |
| 203 // termination is scheduled, isExecutionTerminating will | 205 // termination is scheduled, isExecutionTerminating will |
| 204 // accurately reflect that state when called from another thread. | 206 // accurately reflect that state when called from another thread. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 v8::Handle<v8::Object> global = context->Global(); | 250 v8::Handle<v8::Object> global = context->Global(); |
| 249 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla te(context->GetIsolate(), WorkerWorld)); | 251 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla te(context->GetIsolate(), WorkerWorld)); |
| 250 // Return 0 if the current executing context is not the worker context. | 252 // Return 0 if the current executing context is not the worker context. |
| 251 if (global.IsEmpty()) | 253 if (global.IsEmpty()) |
| 252 return 0; | 254 return 0; |
| 253 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global) ; | 255 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global) ; |
| 254 return workerGlobalScope->script(); | 256 return workerGlobalScope->script(); |
| 255 } | 257 } |
| 256 | 258 |
| 257 } // namespace WebCore | 259 } // namespace WebCore |
| OLD | NEW |