| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 AsyncExecutionType executionType) { | 108 AsyncExecutionType executionType) { |
| 109 SECURITY_CHECK(scriptLoader); | 109 SECURITY_CHECK(scriptLoader); |
| 110 switch (executionType) { | 110 switch (executionType) { |
| 111 case Async: | 111 case Async: |
| 112 // RELEASE_ASSERT makes us crash in a controlled way in error cases | 112 // RELEASE_ASSERT makes us crash in a controlled way in error cases |
| 113 // where the ScriptLoader is associated with the wrong ScriptRunner | 113 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 114 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries | 114 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 115 // to detach). | 115 // to detach). |
| 116 SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); | 116 SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); |
| 117 | 117 |
| 118 m_pendingAsyncScripts.remove(scriptLoader); | 118 m_pendingAsyncScripts.erase(scriptLoader); |
| 119 m_asyncScriptsToExecuteSoon.append(scriptLoader); | 119 m_asyncScriptsToExecuteSoon.append(scriptLoader); |
| 120 | 120 |
| 121 postTask(BLINK_FROM_HERE); | 121 postTask(BLINK_FROM_HERE); |
| 122 | 122 |
| 123 break; | 123 break; |
| 124 | 124 |
| 125 case InOrder: | 125 case InOrder: |
| 126 SECURITY_CHECK(m_numberOfInOrderScriptsWithPendingNotification > 0); | 126 SECURITY_CHECK(m_numberOfInOrderScriptsWithPendingNotification > 0); |
| 127 m_numberOfInOrderScriptsWithPendingNotification--; | 127 m_numberOfInOrderScriptsWithPendingNotification--; |
| 128 | 128 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 150 | 150 |
| 151 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, | 151 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, |
| 152 AsyncExecutionType executionType) { | 152 AsyncExecutionType executionType) { |
| 153 switch (executionType) { | 153 switch (executionType) { |
| 154 case Async: { | 154 case Async: { |
| 155 // SECURITY_CHECK makes us crash in a controlled way in error cases | 155 // SECURITY_CHECK makes us crash in a controlled way in error cases |
| 156 // where the ScriptLoader is associated with the wrong ScriptRunner | 156 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 157 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries | 157 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 158 // to detach). | 158 // to detach). |
| 159 SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); | 159 SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); |
| 160 m_pendingAsyncScripts.remove(scriptLoader); | 160 m_pendingAsyncScripts.erase(scriptLoader); |
| 161 break; | 161 break; |
| 162 } | 162 } |
| 163 case InOrder: | 163 case InOrder: |
| 164 SECURITY_CHECK(removePendingInOrderScript(scriptLoader)); | 164 SECURITY_CHECK(removePendingInOrderScript(scriptLoader)); |
| 165 scheduleReadyInOrderScripts(); | 165 scheduleReadyInOrderScripts(); |
| 166 break; | 166 break; |
| 167 case None: | 167 case None: |
| 168 NOTREACHED(); | 168 NOTREACHED(); |
| 169 break; | 169 break; |
| 170 } | 170 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 196 } | 196 } |
| 197 if (oldContextDocument != newContextDocument) | 197 if (oldContextDocument != newContextDocument) |
| 198 oldContextDocument->scriptRunner()->movePendingScript( | 198 oldContextDocument->scriptRunner()->movePendingScript( |
| 199 newContextDocument->scriptRunner(), scriptLoader); | 199 newContextDocument->scriptRunner(), scriptLoader); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void ScriptRunner::movePendingScript(ScriptRunner* newRunner, | 202 void ScriptRunner::movePendingScript(ScriptRunner* newRunner, |
| 203 ScriptLoader* scriptLoader) { | 203 ScriptLoader* scriptLoader) { |
| 204 if (m_pendingAsyncScripts.contains(scriptLoader)) { | 204 if (m_pendingAsyncScripts.contains(scriptLoader)) { |
| 205 newRunner->queueScriptForExecution(scriptLoader, Async); | 205 newRunner->queueScriptForExecution(scriptLoader, Async); |
| 206 m_pendingAsyncScripts.remove(scriptLoader); | 206 m_pendingAsyncScripts.erase(scriptLoader); |
| 207 m_document->decrementLoadEventDelayCount(); | 207 m_document->decrementLoadEventDelayCount(); |
| 208 return; | 208 return; |
| 209 } | 209 } |
| 210 if (removePendingInOrderScript(scriptLoader)) { | 210 if (removePendingInOrderScript(scriptLoader)) { |
| 211 newRunner->queueScriptForExecution(scriptLoader, InOrder); | 211 newRunner->queueScriptForExecution(scriptLoader, InOrder); |
| 212 m_document->decrementLoadEventDelayCount(); | 212 m_document->decrementLoadEventDelayCount(); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Returns true if task was run, and false otherwise. | 216 // Returns true if task was run, and false otherwise. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 242 | 242 |
| 243 DEFINE_TRACE(ScriptRunner) { | 243 DEFINE_TRACE(ScriptRunner) { |
| 244 visitor->trace(m_document); | 244 visitor->trace(m_document); |
| 245 visitor->trace(m_pendingInOrderScripts); | 245 visitor->trace(m_pendingInOrderScripts); |
| 246 visitor->trace(m_pendingAsyncScripts); | 246 visitor->trace(m_pendingAsyncScripts); |
| 247 visitor->trace(m_asyncScriptsToExecuteSoon); | 247 visitor->trace(m_asyncScriptsToExecuteSoon); |
| 248 visitor->trace(m_inOrderScriptsToExecuteSoon); | 248 visitor->trace(m_inOrderScriptsToExecuteSoon); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // namespace blink | 251 } // namespace blink |
| OLD | NEW |