| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 131 | 131 |
| 132 void ScriptRunner::scheduleReadyInOrderScripts() | |
| 133 { | |
| 134 while (!m_pendingInOrderScripts.isEmpty() && m_pendingInOrderScripts.first()
->isReady()) { | |
| 135 // A ScriptLoader that failed is responsible for cancelling itself | |
| 136 // notifyScriptLoadError(); it continues this draining of ready scripts. | |
| 137 if (m_pendingInOrderScripts.first()->errorOccurred()) | |
| 138 break; | |
| 139 m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFirst()
); | |
| 140 postTask(BLINK_FROM_HERE); | |
| 141 } | |
| 142 } | |
| 143 | |
| 144 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType e
xecutionType) | 132 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType e
xecutionType) |
| 145 { | 133 { |
| 146 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptLoader); | 134 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptLoader); |
| 147 switch (executionType) { | 135 switch (executionType) { |
| 148 case ASYNC_EXECUTION: | 136 case ASYNC_EXECUTION: |
| 149 // RELEASE_ASSERT makes us crash in a controlled way in error cases | 137 // RELEASE_ASSERT makes us crash in a controlled way in error cases |
| 150 // where the ScriptLoader is associated with the wrong ScriptRunner | 138 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 151 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries | 139 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 152 // to detach). | 140 // to detach). |
| 153 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(
scriptLoader)); | 141 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(
scriptLoader)); |
| 154 | 142 |
| 155 m_pendingAsyncScripts.remove(scriptLoader); | 143 m_pendingAsyncScripts.remove(scriptLoader); |
| 156 m_asyncScriptsToExecuteSoon.append(scriptLoader); | 144 m_asyncScriptsToExecuteSoon.append(scriptLoader); |
| 157 | 145 |
| 158 postTask(BLINK_FROM_HERE); | 146 postTask(BLINK_FROM_HERE); |
| 159 | 147 |
| 160 break; | 148 break; |
| 161 | 149 |
| 162 case IN_ORDER_EXECUTION: | 150 case IN_ORDER_EXECUTION: |
| 163 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPen
dingNotification > 0); | 151 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPen
dingNotification > 0); |
| 164 m_numberOfInOrderScriptsWithPendingNotification--; | 152 m_numberOfInOrderScriptsWithPendingNotification--; |
| 165 | 153 |
| 166 scheduleReadyInOrderScripts(); | 154 while (!m_pendingInOrderScripts.isEmpty() && m_pendingInOrderScripts.fir
st()->isReady()) { |
| 155 m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFir
st()); |
| 156 postTask(BLINK_FROM_HERE); |
| 157 } |
| 167 | 158 |
| 168 break; | 159 break; |
| 169 } | 160 } |
| 170 } | 161 } |
| 171 | 162 |
| 172 bool ScriptRunner::removePendingInOrderScript(ScriptLoader* scriptLoader) | 163 bool ScriptRunner::removePendingInOrderScript(ScriptLoader* scriptLoader) |
| 173 { | 164 { |
| 174 for (auto it = m_pendingInOrderScripts.begin(); it != m_pendingInOrderScript
s.end(); ++it) { | 165 for (auto it = m_pendingInOrderScripts.begin(); it != m_pendingInOrderScript
s.end(); ++it) { |
| 175 if (*it == scriptLoader) { | 166 if (*it == scriptLoader) { |
| 176 m_pendingInOrderScripts.remove(it); | 167 m_pendingInOrderScripts.remove(it); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 198 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader); | 189 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader); |
| 199 m_pendingAsyncScripts.remove(scriptLoader); | 190 m_pendingAsyncScripts.remove(scriptLoader); |
| 200 break; | 191 break; |
| 201 } | 192 } |
| 202 case IN_ORDER_EXECUTION: | 193 case IN_ORDER_EXECUTION: |
| 203 bool foundLoader = removePendingInOrderScript(scriptLoader); | 194 bool foundLoader = removePendingInOrderScript(scriptLoader); |
| 204 #if !ENABLE(OILPAN) | 195 #if !ENABLE(OILPAN) |
| 205 foundLoader = foundLoader || m_isDisposed; | 196 foundLoader = foundLoader || m_isDisposed; |
| 206 #endif | 197 #endif |
| 207 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader); | 198 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader); |
| 208 scheduleReadyInOrderScripts(); | |
| 209 break; | 199 break; |
| 210 } | 200 } |
| 211 m_document->decrementLoadEventDelayCount(); | 201 m_document->decrementLoadEventDelayCount(); |
| 212 } | 202 } |
| 213 | 203 |
| 214 void ScriptRunner::movePendingScript(Document& oldDocument, Document& newDocumen
t, ScriptLoader* scriptLoader) | 204 void ScriptRunner::movePendingScript(Document& oldDocument, Document& newDocumen
t, ScriptLoader* scriptLoader) |
| 215 { | 205 { |
| 216 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); | 206 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); |
| 217 if (!newContextDocument) { | 207 if (!newContextDocument) { |
| 218 // Document's contextDocument() method will return no Document if the | 208 // Document's contextDocument() method will return no Document if the |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 #if ENABLE(OILPAN) | 274 #if ENABLE(OILPAN) |
| 285 visitor->trace(m_document); | 275 visitor->trace(m_document); |
| 286 visitor->trace(m_pendingInOrderScripts); | 276 visitor->trace(m_pendingInOrderScripts); |
| 287 visitor->trace(m_pendingAsyncScripts); | 277 visitor->trace(m_pendingAsyncScripts); |
| 288 visitor->trace(m_asyncScriptsToExecuteSoon); | 278 visitor->trace(m_asyncScriptsToExecuteSoon); |
| 289 visitor->trace(m_inOrderScriptsToExecuteSoon); | 279 visitor->trace(m_inOrderScriptsToExecuteSoon); |
| 290 #endif | 280 #endif |
| 291 } | 281 } |
| 292 | 282 |
| 293 } // namespace blink | 283 } // namespace blink |
| OLD | NEW |