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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // WorkerGlobalScope. Other objects keep the worker global scope | 204 // WorkerGlobalScope. Other objects keep the worker global scope |
205 // alive because they need its thread field to check that work is | 205 // alive because they need its thread field to check that work is |
206 // being carried out on the right thread. We therefore cannot clear | 206 // being carried out on the right thread. We therefore cannot clear |
207 // the thread field before all references to the worker global | 207 // the thread field before all references to the worker global |
208 // scope are gone. | 208 // scope are gone. |
209 } | 209 } |
210 | 210 |
211 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) | 211 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) |
212 { | 212 { |
213 ASSERT(contentSecurityPolicy()); | 213 ASSERT(contentSecurityPolicy()); |
| 214 ASSERT(executionContext()); |
| 215 |
| 216 ExecutionContext& executionContext = *this->executionContext(); |
| 217 |
214 Vector<String>::const_iterator urlsEnd = urls.end(); | 218 Vector<String>::const_iterator urlsEnd = urls.end(); |
215 Vector<KURL> completedURLs; | 219 Vector<KURL> completedURLs; |
216 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ | 220 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ |
217 const KURL& url = executionContext()->completeURL(*it); | 221 const KURL& url = executionContext.completeURL(*it); |
218 if (!url.isValid()) { | 222 if (!url.isValid()) { |
219 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "'
is invalid."); | 223 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "'
is invalid."); |
220 return; | 224 return; |
221 } | 225 } |
222 completedURLs.append(url); | 226 completedURLs.append(url); |
223 } | 227 } |
224 Vector<KURL>::const_iterator end = completedURLs.end(); | 228 Vector<KURL>::const_iterator end = completedURLs.end(); |
225 | 229 |
226 for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++i
t) { | 230 for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++i
t) { |
227 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create()); | 231 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create()); |
228 scriptLoader->setTargetType(ResourceRequest::TargetIsScript); | 232 scriptLoader->setTargetType(ResourceRequest::TargetIsScript); |
229 scriptLoader->loadSynchronously(executionContext(), *it, AllowCrossOrigi
nRequests); | 233 scriptLoader->loadSynchronously(executionContext, *it, AllowCrossOriginR
equests); |
230 | 234 |
231 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. | 235 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. |
232 if (scriptLoader->failed()) { | 236 if (scriptLoader->failed()) { |
233 exceptionState.throwDOMException(NetworkError, "The script at '" + i
t->elidedString() + "' failed to load."); | 237 exceptionState.throwDOMException(NetworkError, "The script at '" + i
t->elidedString() + "' failed to load."); |
234 return; | 238 return; |
235 } | 239 } |
236 | 240 |
237 InspectorInstrumentation::scriptImported(executionContext(), scriptLoade
r->identifier(), scriptLoader->script()); | 241 InspectorInstrumentation::scriptImported(&executionContext, scriptLoader
->identifier(), scriptLoader->script()); |
238 | 242 |
239 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = nullptr; | 243 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = nullptr; |
240 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent); | 244 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent); |
241 if (errorEvent) { | 245 if (errorEvent) { |
242 m_script->rethrowExceptionFromImportedScript(errorEvent.release()); | 246 m_script->rethrowExceptionFromImportedScript(errorEvent.release()); |
243 return; | 247 return; |
244 } | 248 } |
245 } | 249 } |
246 } | 250 } |
247 | 251 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 { | 307 { |
304 visitor->trace(m_console); | 308 visitor->trace(m_console); |
305 visitor->trace(m_location); | 309 visitor->trace(m_location); |
306 visitor->trace(m_navigator); | 310 visitor->trace(m_navigator); |
307 #if ENABLE(OILPAN) | 311 #if ENABLE(OILPAN) |
308 HeapSupplementable<WorkerGlobalScope>::trace(visitor); | 312 HeapSupplementable<WorkerGlobalScope>::trace(visitor); |
309 #endif | 313 #endif |
310 } | 314 } |
311 | 315 |
312 } // namespace WebCore | 316 } // namespace WebCore |
OLD | NEW |