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

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

Issue 644663004: Use C++11 features in core/workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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/WorkerEventQueue.cpp ('k') | Source/core/workers/WorkerInspectorProxy.cpp » ('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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // scope are gone. 215 // scope are gone.
216 } 216 }
217 217
218 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState & exceptionState) 218 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState & exceptionState)
219 { 219 {
220 ASSERT(contentSecurityPolicy()); 220 ASSERT(contentSecurityPolicy());
221 ASSERT(executionContext()); 221 ASSERT(executionContext());
222 222
223 ExecutionContext& executionContext = *this->executionContext(); 223 ExecutionContext& executionContext = *this->executionContext();
224 224
225 Vector<String>::const_iterator urlsEnd = urls.end();
226 Vector<KURL> completedURLs; 225 Vector<KURL> completedURLs;
227 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) { 226 for (const String& urlString : urls) {
228 const KURL& url = executionContext.completeURL(*it); 227 const KURL& url = executionContext.completeURL(urlString);
229 if (!url.isValid()) { 228 if (!url.isValid()) {
230 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "' is invalid."); 229 exceptionState.throwDOMException(SyntaxError, "The URL '" + urlStrin g + "' is invalid.");
231 return; 230 return;
232 } 231 }
233 if (!contentSecurityPolicy()->allowScriptFromSource(url)) { 232 if (!contentSecurityPolicy()->allowScriptFromSource(url)) {
234 exceptionState.throwDOMException(NetworkError, "The script at '" + u rl.elidedString() + "' failed to load."); 233 exceptionState.throwDOMException(NetworkError, "The script at '" + u rl.elidedString() + "' failed to load.");
235 return; 234 return;
236 } 235 }
237 completedURLs.append(url); 236 completedURLs.append(url);
238 } 237 }
239 Vector<KURL>::const_iterator end = completedURLs.end();
240 238
241 for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++i t) { 239 for (const KURL& completeURL : completedURLs) {
242 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create()); 240 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create());
243 scriptLoader->setRequestContext(blink::WebURLRequest::RequestContextScri pt); 241 scriptLoader->setRequestContext(blink::WebURLRequest::RequestContextScri pt);
244 scriptLoader->loadSynchronously(executionContext, *it, AllowCrossOriginR equests); 242 scriptLoader->loadSynchronously(executionContext, completeURL, AllowCros sOriginRequests);
245 243
246 // If the fetching attempt failed, throw a NetworkError exception and ab ort all these steps. 244 // If the fetching attempt failed, throw a NetworkError exception and ab ort all these steps.
247 if (scriptLoader->failed()) { 245 if (scriptLoader->failed()) {
248 exceptionState.throwDOMException(NetworkError, "The script at '" + i t->elidedString() + "' failed to load."); 246 exceptionState.throwDOMException(NetworkError, "The script at '" + c ompleteURL.elidedString() + "' failed to load.");
249 return; 247 return;
250 } 248 }
251 249
252 InspectorInstrumentation::scriptImported(&executionContext, scriptLoader ->identifier(), scriptLoader->script()); 250 InspectorInstrumentation::scriptImported(&executionContext, scriptLoader ->identifier(), scriptLoader->script());
253 251
254 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = nullptr; 252 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = nullptr;
255 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader ->responseURL()), &errorEvent); 253 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader ->responseURL()), &errorEvent);
256 if (errorEvent) { 254 if (errorEvent) {
257 m_script->rethrowExceptionFromImportedScript(errorEvent.release(), e xceptionState); 255 m_script->rethrowExceptionFromImportedScript(errorEvent.release(), e xceptionState);
258 return; 256 return;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 visitor->trace(m_eventQueue); 335 visitor->trace(m_eventQueue);
338 visitor->trace(m_workerClients); 336 visitor->trace(m_workerClients);
339 visitor->trace(m_messageStorage); 337 visitor->trace(m_messageStorage);
340 HeapSupplementable<WorkerGlobalScope>::trace(visitor); 338 HeapSupplementable<WorkerGlobalScope>::trace(visitor);
341 #endif 339 #endif
342 ExecutionContext::trace(visitor); 340 ExecutionContext::trace(visitor);
343 EventTargetWithInlineData::trace(visitor); 341 EventTargetWithInlineData::trace(visitor);
344 } 342 }
345 343
346 } // namespace blink 344 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerEventQueue.cpp ('k') | Source/core/workers/WorkerInspectorProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698