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

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

Issue 1644483002: Let notifyScriptLoadError() handle already detached ScriptLoaders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add explanatory comment Created 4 years, 11 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 | « third_party/WebKit/Source/core/dom/ScriptLoader.h ('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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 197 }
198 198
199 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy pe executionType) 199 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy pe executionType)
200 { 200 {
201 switch (executionType) { 201 switch (executionType) {
202 case ASYNC_EXECUTION: { 202 case ASYNC_EXECUTION: {
203 // RELEASE_ASSERT makes us crash in a controlled way in error cases 203 // RELEASE_ASSERT makes us crash in a controlled way in error cases
204 // where the ScriptLoader is associated with the wrong ScriptRunner 204 // where the ScriptLoader is associated with the wrong ScriptRunner
205 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries 205 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries
206 // to detach). 206 // to detach).
207 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains( scriptLoader)); 207 bool foundLoader = m_pendingAsyncScripts.contains(scriptLoader);
208 #if !ENABLE(OILPAN)
209 // If the ScriptRunner has been disposed of, no pending scripts remain.
210 // Verify that the ScriptLoader is in a detached state, if so.
211 foundLoader = foundLoader || (scriptLoader->isDetached() && m_pendingAsy ncScripts.isEmpty());
212 #endif
213 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader);
208 m_pendingAsyncScripts.remove(scriptLoader); 214 m_pendingAsyncScripts.remove(scriptLoader);
209 break; 215 break;
210 } 216 }
211 case IN_ORDER_EXECUTION: 217 case IN_ORDER_EXECUTION:
212 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(removePendingInOrderScript(scri ptLoader)); 218 bool foundLoader = removePendingInOrderScript(scriptLoader);
219 #if !ENABLE(OILPAN)
220 foundLoader = foundLoader || (scriptLoader->isDetached() && m_pendingInO rderScripts.isEmpty());
221 #endif
222 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader);
213 break; 223 break;
214 } 224 }
215 scriptLoader->detach(); 225 scriptLoader->detach();
216 m_document->decrementLoadEventDelayCount(); 226 m_document->decrementLoadEventDelayCount();
217 } 227 }
218 228
219 void ScriptRunner::movePendingScript(Document& oldDocument, Document& newDocumen t, ScriptLoader* scriptLoader) 229 void ScriptRunner::movePendingScript(Document& oldDocument, Document& newDocumen t, ScriptLoader* scriptLoader)
220 { 230 {
221 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen t().get(); 231 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen t().get();
222 if (!newContextDocument) { 232 if (!newContextDocument) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 #if ENABLE(OILPAN) 299 #if ENABLE(OILPAN)
290 visitor->trace(m_document); 300 visitor->trace(m_document);
291 visitor->trace(m_pendingInOrderScripts); 301 visitor->trace(m_pendingInOrderScripts);
292 visitor->trace(m_pendingAsyncScripts); 302 visitor->trace(m_pendingAsyncScripts);
293 visitor->trace(m_asyncScriptsToExecuteSoon); 303 visitor->trace(m_asyncScriptsToExecuteSoon);
294 visitor->trace(m_inOrderScriptsToExecuteSoon); 304 visitor->trace(m_inOrderScriptsToExecuteSoon);
295 #endif 305 #endif
296 } 306 }
297 307
298 } // namespace blink 308 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ScriptLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698