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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (!block.CanContinue()) { | 158 if (!block.CanContinue()) { |
159 m_workerGlobalScope->script()->forbidExecution(); | 159 m_workerGlobalScope->script()->forbidExecution(); |
160 return ScriptValue(); | 160 return ScriptValue(); |
161 } | 161 } |
162 | 162 |
163 if (block.HasCaught()) { | 163 if (block.HasCaught()) { |
164 v8::Local<v8::Message> message = block.Message(); | 164 v8::Local<v8::Message> message = block.Message(); |
165 state->hadException = true; | 165 state->hadException = true; |
166 state->errorMessage = toWebCoreString(message->Get()); | 166 state->errorMessage = toWebCoreString(message->Get()); |
167 state->lineNumber = message->GetLineNumber(); | 167 state->lineNumber = message->GetLineNumber(); |
| 168 state->columnNumber = message->GetStartColumn(); |
168 state->sourceURL = toWebCoreString(message->GetScriptResourceName()); | 169 state->sourceURL = toWebCoreString(message->GetScriptResourceName()); |
169 if (m_workerGlobalScope->sanitizeScriptError(state->errorMessage, state-
>lineNumber, state->sourceURL)) | 170 if (m_workerGlobalScope->sanitizeScriptError(state->errorMessage, state-
>lineNumber, state->columnNumber, state->sourceURL)) |
170 state->exception = throwError(v8GeneralError, state->errorMessage.ut
f8().data(), m_isolate); | 171 state->exception = throwError(v8GeneralError, state->errorMessage.ut
f8().data(), m_isolate); |
171 else | 172 else |
172 state->exception = ScriptValue(block.Exception()); | 173 state->exception = ScriptValue(block.Exception()); |
173 | 174 |
174 block.Reset(); | 175 block.Reset(); |
175 } else | 176 } else |
176 state->hadException = false; | 177 state->hadException = false; |
177 | 178 |
178 if (result.IsEmpty() || result->IsUndefined()) | 179 if (result.IsEmpty() || result->IsUndefined()) |
179 return ScriptValue(); | 180 return ScriptValue(); |
180 | 181 |
181 return ScriptValue(result); | 182 return ScriptValue(result); |
182 } | 183 } |
183 | 184 |
184 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script
Value* exception) | 185 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script
Value* exception) |
185 { | 186 { |
186 if (isExecutionForbidden()) | 187 if (isExecutionForbidden()) |
187 return; | 188 return; |
188 | 189 |
189 WorkerGlobalScopeExecutionState state; | 190 WorkerGlobalScopeExecutionState state; |
190 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos
ition(), &state); | 191 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos
ition(), &state); |
191 if (state.hadException) { | 192 if (state.hadException) { |
192 if (exception) | 193 if (exception) |
193 *exception = state.exception; | 194 *exception = state.exception; |
194 else | 195 else |
195 m_workerGlobalScope->reportException(state.errorMessage, state.lineN
umber, state.sourceURL, 0); | 196 m_workerGlobalScope->reportException(state.errorMessage, state.lineN
umber, state.columnNumber, state.sourceURL, 0); |
196 } | 197 } |
197 } | 198 } |
198 | 199 |
199 void WorkerScriptController::scheduleExecutionTermination() | 200 void WorkerScriptController::scheduleExecutionTermination() |
200 { | 201 { |
201 // The mutex provides a memory barrier to ensure that once | 202 // The mutex provides a memory barrier to ensure that once |
202 // termination is scheduled, isExecutionTerminating will | 203 // termination is scheduled, isExecutionTerminating will |
203 // accurately reflect that state when called from another thread. | 204 // accurately reflect that state when called from another thread. |
204 { | 205 { |
205 MutexLocker locker(m_scheduledTerminationMutex); | 206 MutexLocker locker(m_scheduledTerminationMutex); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 v8::Handle<v8::Object> global = context->Global(); | 247 v8::Handle<v8::Object> global = context->Global(); |
247 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla
te(context->GetIsolate(), WorkerWorld)); | 248 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla
te(context->GetIsolate(), WorkerWorld)); |
248 // Return 0 if the current executing context is not the worker context. | 249 // Return 0 if the current executing context is not the worker context. |
249 if (global.IsEmpty()) | 250 if (global.IsEmpty()) |
250 return 0; | 251 return 0; |
251 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global)
; | 252 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global)
; |
252 return workerGlobalScope->script(); | 253 return workerGlobalScope->script(); |
253 } | 254 } |
254 | 255 |
255 } // namespace WebCore | 256 } // namespace WebCore |
OLD | NEW |