OLD | NEW |
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
pe executionType) | 125 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
pe executionType) |
126 { | 126 { |
127 switch (executionType) { | 127 switch (executionType) { |
128 case ASYNC_EXECUTION: | 128 case ASYNC_EXECUTION: |
129 // RELEASE_ASSERT makes us crash in a controlled way in error cases | 129 // RELEASE_ASSERT makes us crash in a controlled way in error cases |
130 // where the ScriptLoader is associated with the wrong ScriptRunner | 130 // where the ScriptLoader is associated with the wrong ScriptRunner |
131 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries | 131 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
132 // to detach). | 132 // to detach). |
133 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(
scriptLoader)); | 133 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(
scriptLoader)); |
134 m_pendingAsyncScripts.remove(scriptLoader); | 134 m_pendingAsyncScripts.remove(scriptLoader); |
135 scriptLoader->detach(); | |
136 m_document->decrementLoadEventDelayCount(); | |
137 break; | 135 break; |
138 | 136 |
139 case IN_ORDER_EXECUTION: | 137 case IN_ORDER_EXECUTION: |
140 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!m_scriptsToExecuteInOrder.isEm
pty()); | 138 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>>::iterator it = m_scrip
tsToExecuteInOrder.begin(); |
| 139 while (it != m_scriptsToExecuteInOrder.end()) { |
| 140 if (*it == scriptLoader) { |
| 141 m_scriptsToExecuteInOrder.remove(it); |
| 142 break; |
| 143 } |
| 144 ++it; |
| 145 } |
| 146 // Verifies same condition as above, but for in-order script loads. |
| 147 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(it != m_scriptsToExecuteInOrder
.end()); |
141 break; | 148 break; |
142 } | 149 } |
| 150 scriptLoader->detach(); |
| 151 m_document->decrementLoadEventDelayCount(); |
143 } | 152 } |
144 | 153 |
145 void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDo
cument, ScriptLoader* scriptLoader) | 154 void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDo
cument, ScriptLoader* scriptLoader) |
146 { | 155 { |
147 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); | 156 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); |
148 if (!newContextDocument) { | 157 if (!newContextDocument) { |
149 // Document's contextDocument() method will return no Document if the | 158 // Document's contextDocument() method will return no Document if the |
150 // following conditions both hold: | 159 // following conditions both hold: |
151 // | 160 // |
152 // - The Document wasn't created with an explicit context document | 161 // - The Document wasn't created with an explicit context document |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 { | 244 { |
236 #if ENABLE(OILPAN) | 245 #if ENABLE(OILPAN) |
237 visitor->trace(m_document); | 246 visitor->trace(m_document); |
238 visitor->trace(m_scriptsToExecuteInOrder); | 247 visitor->trace(m_scriptsToExecuteInOrder); |
239 visitor->trace(m_scriptsToExecuteSoon); | 248 visitor->trace(m_scriptsToExecuteSoon); |
240 visitor->trace(m_pendingAsyncScripts); | 249 visitor->trace(m_pendingAsyncScripts); |
241 #endif | 250 #endif |
242 } | 251 } |
243 | 252 |
244 } | 253 } |
OLD | NEW |