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

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

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 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
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 28 matching lines...) Expand all
39 ScriptRunner::ScriptRunner(Document* document) 39 ScriptRunner::ScriptRunner(Document* document)
40 : m_document(document) 40 : m_document(document)
41 , m_taskRunner(Platform::current()->currentThread()->scheduler()->loadingTas kRunner()) 41 , m_taskRunner(Platform::current()->currentThread()->scheduler()->loadingTas kRunner())
42 , m_numberOfInOrderScriptsWithPendingNotification(0) 42 , m_numberOfInOrderScriptsWithPendingNotification(0)
43 , m_isSuspended(false) 43 , m_isSuspended(false)
44 #if !ENABLE(OILPAN) 44 #if !ENABLE(OILPAN)
45 , m_isDisposed(false) 45 , m_isDisposed(false)
46 , m_weakPointerFactoryForTasks(this) 46 , m_weakPointerFactoryForTasks(this)
47 #endif 47 #endif
48 { 48 {
49 ASSERT(document); 49 DCHECK(document);
50 #ifndef NDEBUG 50 #ifndef NDEBUG
51 m_hasEverBeenSuspended = false; 51 m_hasEverBeenSuspended = false;
52 #endif 52 #endif
53 } 53 }
54 54
55 ScriptRunner::~ScriptRunner() 55 ScriptRunner::~ScriptRunner()
56 { 56 {
57 #if !ENABLE(OILPAN) 57 #if !ENABLE(OILPAN)
58 dispose(); 58 dispose();
59 #endif 59 #endif
(...skipping 16 matching lines...) Expand all
76 m_pendingAsyncScripts.clear(); 76 m_pendingAsyncScripts.clear();
77 m_inOrderScriptsToExecuteSoon.clear(); 77 m_inOrderScriptsToExecuteSoon.clear();
78 m_asyncScriptsToExecuteSoon.clear(); 78 m_asyncScriptsToExecuteSoon.clear();
79 m_isDisposed = true; 79 m_isDisposed = true;
80 m_numberOfInOrderScriptsWithPendingNotification = 0; 80 m_numberOfInOrderScriptsWithPendingNotification = 0;
81 } 81 }
82 #endif 82 #endif
83 83
84 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, Execution Type executionType) 84 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, Execution Type executionType)
85 { 85 {
86 ASSERT(scriptLoader); 86 DCHECK(scriptLoader);
87 m_document->incrementLoadEventDelayCount(); 87 m_document->incrementLoadEventDelayCount();
88 switch (executionType) { 88 switch (executionType) {
89 case ASYNC_EXECUTION: 89 case ASYNC_EXECUTION:
90 m_pendingAsyncScripts.add(scriptLoader); 90 m_pendingAsyncScripts.add(scriptLoader);
91 break; 91 break;
92 92
93 case IN_ORDER_EXECUTION: 93 case IN_ORDER_EXECUTION:
94 m_pendingInOrderScripts.append(scriptLoader); 94 m_pendingInOrderScripts.append(scriptLoader);
95 m_numberOfInOrderScriptsWithPendingNotification++; 95 m_numberOfInOrderScriptsWithPendingNotification++;
96 break; 96 break;
(...skipping 13 matching lines...) Expand all
110 { 110 {
111 #ifndef NDEBUG 111 #ifndef NDEBUG
112 m_hasEverBeenSuspended = true; 112 m_hasEverBeenSuspended = true;
113 #endif 113 #endif
114 114
115 m_isSuspended = true; 115 m_isSuspended = true;
116 } 116 }
117 117
118 void ScriptRunner::resume() 118 void ScriptRunner::resume()
119 { 119 {
120 ASSERT(m_isSuspended); 120 DCHECK(m_isSuspended);
121 121
122 m_isSuspended = false; 122 m_isSuspended = false;
123 123
124 for (size_t i = 0; i < m_asyncScriptsToExecuteSoon.size(); ++i) { 124 for (size_t i = 0; i < m_asyncScriptsToExecuteSoon.size(); ++i) {
125 postTask(BLINK_FROM_HERE); 125 postTask(BLINK_FROM_HERE);
126 } 126 }
127 for (size_t i = 0; i < m_inOrderScriptsToExecuteSoon.size(); ++i) { 127 for (size_t i = 0; i < m_inOrderScriptsToExecuteSoon.size(); ++i) {
128 postTask(BLINK_FROM_HERE); 128 postTask(BLINK_FROM_HERE);
129 } 129 }
130 } 130 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Document's contextDocument() method will return no Document if the 218 // Document's contextDocument() method will return no Document if the
219 // following conditions both hold: 219 // following conditions both hold:
220 // 220 //
221 // - The Document wasn't created with an explicit context document 221 // - The Document wasn't created with an explicit context document
222 // and that document is otherwise kept alive. 222 // and that document is otherwise kept alive.
223 // - The Document itself is detached from its frame. 223 // - The Document itself is detached from its frame.
224 // 224 //
225 // The script element's loader is in that case moved to document() and 225 // The script element's loader is in that case moved to document() and
226 // its script runner, which is the non-null Document that contextDocumen t() 226 // its script runner, which is the non-null Document that contextDocumen t()
227 // would return if not detached. 227 // would return if not detached.
228 ASSERT(!newDocument.frame()); 228 DCHECK(!newDocument.frame());
229 newContextDocument = &newDocument; 229 newContextDocument = &newDocument;
230 } 230 }
231 RawPtr<Document> oldContextDocument = oldDocument.contextDocument().get(); 231 RawPtr<Document> oldContextDocument = oldDocument.contextDocument().get();
232 if (!oldContextDocument) { 232 if (!oldContextDocument) {
233 ASSERT(!oldDocument.frame()); 233 DCHECK(!oldDocument.frame());
234 oldContextDocument = &oldDocument; 234 oldContextDocument = &oldDocument;
235 } 235 }
236 if (oldContextDocument != newContextDocument) 236 if (oldContextDocument != newContextDocument)
237 oldContextDocument->scriptRunner()->movePendingScript(newContextDocument ->scriptRunner(), scriptLoader); 237 oldContextDocument->scriptRunner()->movePendingScript(newContextDocument ->scriptRunner(), scriptLoader);
238 } 238 }
239 239
240 void ScriptRunner::movePendingScript(ScriptRunner* newRunner, ScriptLoader* scri ptLoader) 240 void ScriptRunner::movePendingScript(ScriptRunner* newRunner, ScriptLoader* scri ptLoader)
241 { 241 {
242 if (m_pendingAsyncScripts.contains(scriptLoader)) { 242 if (m_pendingAsyncScripts.contains(scriptLoader)) {
243 newRunner->queueScriptForExecution(scriptLoader, ASYNC_EXECUTION); 243 newRunner->queueScriptForExecution(scriptLoader, ASYNC_EXECUTION);
(...skipping 24 matching lines...) Expand all
268 return; 268 return;
269 269
270 if (executeTaskFromQueue(&m_asyncScriptsToExecuteSoon)) 270 if (executeTaskFromQueue(&m_asyncScriptsToExecuteSoon))
271 return; 271 return;
272 272
273 if (executeTaskFromQueue(&m_inOrderScriptsToExecuteSoon)) 273 if (executeTaskFromQueue(&m_inOrderScriptsToExecuteSoon))
274 return; 274 return;
275 275
276 #ifndef NDEBUG 276 #ifndef NDEBUG
277 // Extra tasks should be posted only when we resume after suspending. 277 // Extra tasks should be posted only when we resume after suspending.
278 ASSERT(m_hasEverBeenSuspended); 278 DCHECK(m_hasEverBeenSuspended);
279 #endif 279 #endif
280 } 280 }
281 281
282 DEFINE_TRACE(ScriptRunner) 282 DEFINE_TRACE(ScriptRunner)
283 { 283 {
284 visitor->trace(m_document); 284 visitor->trace(m_document);
285 visitor->trace(m_pendingInOrderScripts); 285 visitor->trace(m_pendingInOrderScripts);
286 visitor->trace(m_pendingAsyncScripts); 286 visitor->trace(m_pendingAsyncScripts);
287 visitor->trace(m_asyncScriptsToExecuteSoon); 287 visitor->trace(m_asyncScriptsToExecuteSoon);
288 visitor->trace(m_inOrderScriptsToExecuteSoon); 288 visitor->trace(m_inOrderScriptsToExecuteSoon);
289 } 289 }
290 290
291 } // namespace blink 291 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698