| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // notifyScriptLoadError(); it continues this draining of ready scripts. | 136 // notifyScriptLoadError(); it continues this draining of ready scripts. |
| 137 if (m_pendingInOrderScripts.first()->errorOccurred()) | 137 if (m_pendingInOrderScripts.first()->errorOccurred()) |
| 138 break; | 138 break; |
| 139 m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFirst()
); | 139 m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFirst()
); |
| 140 postTask(BLINK_FROM_HERE); | 140 postTask(BLINK_FROM_HERE); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType e
xecutionType) | 144 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType e
xecutionType) |
| 145 { | 145 { |
| 146 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptLoader); | 146 SECURITY_CHECK(scriptLoader); |
| 147 switch (executionType) { | 147 switch (executionType) { |
| 148 case ASYNC_EXECUTION: | 148 case ASYNC_EXECUTION: |
| 149 // RELEASE_ASSERT makes us crash in a controlled way in error cases | 149 // RELEASE_ASSERT makes us crash in a controlled way in error cases |
| 150 // where the ScriptLoader is associated with the wrong ScriptRunner | 150 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 151 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries | 151 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 152 // to detach). | 152 // to detach). |
| 153 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(
scriptLoader)); | 153 SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); |
| 154 | 154 |
| 155 m_pendingAsyncScripts.remove(scriptLoader); | 155 m_pendingAsyncScripts.remove(scriptLoader); |
| 156 m_asyncScriptsToExecuteSoon.append(scriptLoader); | 156 m_asyncScriptsToExecuteSoon.append(scriptLoader); |
| 157 | 157 |
| 158 postTask(BLINK_FROM_HERE); | 158 postTask(BLINK_FROM_HERE); |
| 159 | 159 |
| 160 break; | 160 break; |
| 161 | 161 |
| 162 case IN_ORDER_EXECUTION: | 162 case IN_ORDER_EXECUTION: |
| 163 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPen
dingNotification > 0); | 163 SECURITY_CHECK(m_numberOfInOrderScriptsWithPendingNotification > 0); |
| 164 m_numberOfInOrderScriptsWithPendingNotification--; | 164 m_numberOfInOrderScriptsWithPendingNotification--; |
| 165 | 165 |
| 166 scheduleReadyInOrderScripts(); | 166 scheduleReadyInOrderScripts(); |
| 167 | 167 |
| 168 break; | 168 break; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool ScriptRunner::removePendingInOrderScript(ScriptLoader* scriptLoader) | 172 bool ScriptRunner::removePendingInOrderScript(ScriptLoader* scriptLoader) |
| 173 { | 173 { |
| 174 for (auto it = m_pendingInOrderScripts.begin(); it != m_pendingInOrderScript
s.end(); ++it) { | 174 for (auto it = m_pendingInOrderScripts.begin(); it != m_pendingInOrderScript
s.end(); ++it) { |
| 175 if (*it == scriptLoader) { | 175 if (*it == scriptLoader) { |
| 176 m_pendingInOrderScripts.remove(it); | 176 m_pendingInOrderScripts.remove(it); |
| 177 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWit
hPendingNotification > 0); | 177 SECURITY_CHECK(m_numberOfInOrderScriptsWithPendingNotification > 0); |
| 178 m_numberOfInOrderScriptsWithPendingNotification--; | 178 m_numberOfInOrderScriptsWithPendingNotification--; |
| 179 return true; | 179 return true; |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 return false; | 182 return false; |
| 183 } | 183 } |
| 184 | 184 |
| 185 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
pe executionType) | 185 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
pe executionType) |
| 186 { | 186 { |
| 187 switch (executionType) { | 187 switch (executionType) { |
| 188 case ASYNC_EXECUTION: { | 188 case ASYNC_EXECUTION: { |
| 189 // RELEASE_ASSERT makes us crash in a controlled way in error cases | 189 // RELEASE_ASSERT makes us crash in a controlled way in error cases |
| 190 // where the ScriptLoader is associated with the wrong ScriptRunner | 190 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 191 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries | 191 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 192 // to detach). | 192 // to detach). |
| 193 bool foundLoader = m_pendingAsyncScripts.contains(scriptLoader); | 193 bool foundLoader = m_pendingAsyncScripts.contains(scriptLoader); |
| 194 #if !ENABLE(OILPAN) | 194 #if !ENABLE(OILPAN) |
| 195 // If the ScriptRunner has been disposed of, no pending scripts remain. | 195 // If the ScriptRunner has been disposed of, no pending scripts remain. |
| 196 foundLoader = foundLoader || m_isDisposed; | 196 foundLoader = foundLoader || m_isDisposed; |
| 197 #endif | 197 #endif |
| 198 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader); | 198 SECURITY_CHECK(foundLoader); |
| 199 m_pendingAsyncScripts.remove(scriptLoader); | 199 m_pendingAsyncScripts.remove(scriptLoader); |
| 200 break; | 200 break; |
| 201 } | 201 } |
| 202 case IN_ORDER_EXECUTION: | 202 case IN_ORDER_EXECUTION: |
| 203 bool foundLoader = removePendingInOrderScript(scriptLoader); | 203 bool foundLoader = removePendingInOrderScript(scriptLoader); |
| 204 #if !ENABLE(OILPAN) | 204 #if !ENABLE(OILPAN) |
| 205 foundLoader = foundLoader || m_isDisposed; | 205 foundLoader = foundLoader || m_isDisposed; |
| 206 #endif | 206 #endif |
| 207 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader); | 207 SECURITY_CHECK(foundLoader); |
| 208 scheduleReadyInOrderScripts(); | 208 scheduleReadyInOrderScripts(); |
| 209 break; | 209 break; |
| 210 } | 210 } |
| 211 m_document->decrementLoadEventDelayCount(); | 211 m_document->decrementLoadEventDelayCount(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void ScriptRunner::movePendingScript(Document& oldDocument, Document& newDocumen
t, ScriptLoader* scriptLoader) | 214 void ScriptRunner::movePendingScript(Document& oldDocument, Document& newDocumen
t, ScriptLoader* scriptLoader) |
| 215 { | 215 { |
| 216 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); | 216 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); |
| 217 if (!newContextDocument) { | 217 if (!newContextDocument) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 #if ENABLE(OILPAN) | 284 #if ENABLE(OILPAN) |
| 285 visitor->trace(m_document); | 285 visitor->trace(m_document); |
| 286 visitor->trace(m_pendingInOrderScripts); | 286 visitor->trace(m_pendingInOrderScripts); |
| 287 visitor->trace(m_pendingAsyncScripts); | 287 visitor->trace(m_pendingAsyncScripts); |
| 288 visitor->trace(m_asyncScriptsToExecuteSoon); | 288 visitor->trace(m_asyncScriptsToExecuteSoon); |
| 289 visitor->trace(m_inOrderScriptsToExecuteSoon); | 289 visitor->trace(m_inOrderScriptsToExecuteSoon); |
| 290 #endif | 290 #endif |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace blink | 293 } // namespace blink |
| OLD | NEW |