Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: Source/core/workers/WorkerGlobalScope.cpp

Issue 204983007: Make ThreadableLoader class to use references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/workers/Worker.cpp ('k') | Source/core/workers/WorkerScriptLoader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/workers/Worker.cpp ('k') | Source/core/workers/WorkerScriptLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698