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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptRunner.cpp

Issue 1424703007: Upon load failure, remove sync script from pending queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add release assert Created 5 years, 1 month 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 | « third_party/WebKit/LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror-expected.txt ('k') | no next file » | 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) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy pe executionType) 193 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy pe executionType)
194 { 194 {
195 switch (executionType) { 195 switch (executionType) {
196 case ASYNC_EXECUTION: 196 case ASYNC_EXECUTION:
197 // RELEASE_ASSERT makes us crash in a controlled way in error cases 197 // RELEASE_ASSERT makes us crash in a controlled way in error cases
198 // where the ScriptLoader is associated with the wrong ScriptRunner 198 // where the ScriptLoader is associated with the wrong ScriptRunner
199 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries 199 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries
200 // to detach). 200 // to detach).
201 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains( scriptLoader)); 201 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains( scriptLoader));
202 m_pendingAsyncScripts.remove(scriptLoader); 202 m_pendingAsyncScripts.remove(scriptLoader);
203 scriptLoader->detach();
204 m_document->decrementLoadEventDelayCount();
205 break; 203 break;
206 204
207 case IN_ORDER_EXECUTION: 205 case IN_ORDER_EXECUTION:
208 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPen dingNotification > 0); 206 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPen dingNotification > 0);
209 m_numberOfInOrderScriptsWithPendingNotification--; 207 m_numberOfInOrderScriptsWithPendingNotification--;
210 208
209 auto it = m_pendingInOrderScripts.begin();
210 for (; it != m_pendingInOrderScripts.end(); ++it) {
211 if (*it == scriptLoader) {
212 m_pendingInOrderScripts.remove(it);
213 break;
214 }
215 }
216 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(it != m_pendingInOrderScripts.e nd());
211 break; 217 break;
212 } 218 }
219 scriptLoader->detach();
220 m_document->decrementLoadEventDelayCount();
213 } 221 }
214 222
215 void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDo cument, ScriptLoader* scriptLoader) 223 void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDo cument, ScriptLoader* scriptLoader)
216 { 224 {
217 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen t().get(); 225 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen t().get();
218 if (!newContextDocument) { 226 if (!newContextDocument) {
219 // Document's contextDocument() method will return no Document if the 227 // Document's contextDocument() method will return no Document if the
220 // following conditions both hold: 228 // following conditions both hold:
221 // 229 //
222 // - The Document wasn't created with an explicit context document 230 // - The Document wasn't created with an explicit context document
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 #if ENABLE(OILPAN) 288 #if ENABLE(OILPAN)
281 visitor->trace(m_document); 289 visitor->trace(m_document);
282 visitor->trace(m_pendingInOrderScripts); 290 visitor->trace(m_pendingInOrderScripts);
283 visitor->trace(m_pendingAsyncScripts); 291 visitor->trace(m_pendingAsyncScripts);
284 visitor->trace(m_asyncScriptsToExecuteSoon); 292 visitor->trace(m_asyncScriptsToExecuteSoon);
285 visitor->trace(m_inOrderScriptsToExecuteSoon); 293 visitor->trace(m_inOrderScriptsToExecuteSoon);
286 #endif 294 #endif
287 } 295 }
288 296
289 } // namespace blink 297 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698