| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) | 188 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) |
| 189 { | 189 { |
| 190 thread()->runLoop().postTask(task); | 190 thread()->runLoop().postTask(task); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void WorkerGlobalScope::clearInspector() | 193 void WorkerGlobalScope::clearInspector() |
| 194 { | 194 { |
| 195 m_workerInspectorController.clear(); | 195 m_workerInspectorController.clear(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& es) | 198 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) |
| 199 { | 199 { |
| 200 ASSERT(contentSecurityPolicy()); | 200 ASSERT(contentSecurityPolicy()); |
| 201 Vector<String>::const_iterator urlsEnd = urls.end(); | 201 Vector<String>::const_iterator urlsEnd = urls.end(); |
| 202 Vector<KURL> completedURLs; | 202 Vector<KURL> completedURLs; |
| 203 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ | 203 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ |
| 204 const KURL& url = executionContext()->completeURL(*it); | 204 const KURL& url = executionContext()->completeURL(*it); |
| 205 if (!url.isValid()) { | 205 if (!url.isValid()) { |
| 206 es.throwDOMException(SyntaxError, "Failed to execute 'importScripts'
: the URL '" + *it + "' is invalid."); | 206 exceptionState.throwDOMException(SyntaxError, "Failed to execute 'im
portScripts': the URL '" + *it + "' is invalid."); |
| 207 return; | 207 return; |
| 208 } | 208 } |
| 209 completedURLs.append(url); | 209 completedURLs.append(url); |
| 210 } | 210 } |
| 211 Vector<KURL>::const_iterator end = completedURLs.end(); | 211 Vector<KURL>::const_iterator end = completedURLs.end(); |
| 212 | 212 |
| 213 for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++i
t) { | 213 for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++i
t) { |
| 214 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create()); | 214 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create()); |
| 215 scriptLoader->setTargetType(ResourceRequest::TargetIsScript); | 215 scriptLoader->setTargetType(ResourceRequest::TargetIsScript); |
| 216 scriptLoader->loadSynchronously(executionContext(), *it, AllowCrossOrigi
nRequests); | 216 scriptLoader->loadSynchronously(executionContext(), *it, AllowCrossOrigi
nRequests); |
| 217 | 217 |
| 218 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. | 218 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. |
| 219 if (scriptLoader->failed()) { | 219 if (scriptLoader->failed()) { |
| 220 es.throwDOMException(NetworkError, "Failed to execute 'importScripts
': the script at '" + it->elidedString() + "' failed to load."); | 220 exceptionState.throwDOMException(NetworkError, "Failed to execute 'i
mportScripts': the script at '" + it->elidedString() + "' failed to load."); |
| 221 return; | 221 return; |
| 222 } | 222 } |
| 223 | 223 |
| 224 InspectorInstrumentation::scriptImported(executionContext(), scriptLoade
r->identifier(), scriptLoader->script()); | 224 InspectorInstrumentation::scriptImported(executionContext(), scriptLoade
r->identifier(), scriptLoader->script()); |
| 225 | 225 |
| 226 RefPtr<ErrorEvent> errorEvent; | 226 RefPtr<ErrorEvent> errorEvent; |
| 227 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent); | 227 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent); |
| 228 if (errorEvent) { | 228 if (errorEvent) { |
| 229 m_script->rethrowExceptionFromImportedScript(errorEvent.release()); | 229 m_script->rethrowExceptionFromImportedScript(errorEvent.release()); |
| 230 return; | 230 return; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 { | 327 { |
| 328 return script()->idleNotification(); | 328 return script()->idleNotification(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 WorkerEventQueue* WorkerGlobalScope::eventQueue() const | 331 WorkerEventQueue* WorkerGlobalScope::eventQueue() const |
| 332 { | 332 { |
| 333 return m_eventQueue.get(); | 333 return m_eventQueue.get(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 } // namespace WebCore | 336 } // namespace WebCore |
| OLD | NEW |