| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, | 51 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, |
| 52 AsyncExecutionType executionType) { | 52 AsyncExecutionType executionType) { |
| 53 DCHECK(scriptLoader); | 53 DCHECK(scriptLoader); |
| 54 m_document->incrementLoadEventDelayCount(); | 54 m_document->incrementLoadEventDelayCount(); |
| 55 switch (executionType) { | 55 switch (executionType) { |
| 56 case Async: | 56 case Async: |
| 57 m_pendingAsyncScripts.insert(scriptLoader); | 57 m_pendingAsyncScripts.insert(scriptLoader); |
| 58 break; | 58 break; |
| 59 | 59 |
| 60 case InOrder: | 60 case InOrder: |
| 61 m_pendingInOrderScripts.append(scriptLoader); | 61 m_pendingInOrderScripts.push_back(scriptLoader); |
| 62 m_numberOfInOrderScriptsWithPendingNotification++; | 62 m_numberOfInOrderScriptsWithPendingNotification++; |
| 63 break; | 63 break; |
| 64 case None: | 64 case None: |
| 65 NOTREACHED(); | 65 NOTREACHED(); |
| 66 break; | 66 break; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ScriptRunner::postTask(const WebTraceLocation& webTraceLocation) { | 70 void ScriptRunner::postTask(const WebTraceLocation& webTraceLocation) { |
| 71 m_taskRunner->postTask(webTraceLocation, WTF::bind(&ScriptRunner::executeTask, | 71 m_taskRunner->postTask(webTraceLocation, WTF::bind(&ScriptRunner::executeTask, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ScriptRunner::scheduleReadyInOrderScripts() { | 96 void ScriptRunner::scheduleReadyInOrderScripts() { |
| 97 while (!m_pendingInOrderScripts.isEmpty() && | 97 while (!m_pendingInOrderScripts.isEmpty() && |
| 98 m_pendingInOrderScripts.first()->isReady()) { | 98 m_pendingInOrderScripts.first()->isReady()) { |
| 99 // A ScriptLoader that failed is responsible for cancelling itself | 99 // A ScriptLoader that failed is responsible for cancelling itself |
| 100 // notifyScriptLoadError(); it continues this draining of ready scripts. | 100 // notifyScriptLoadError(); it continues this draining of ready scripts. |
| 101 if (m_pendingInOrderScripts.first()->errorOccurred()) | 101 if (m_pendingInOrderScripts.first()->errorOccurred()) |
| 102 break; | 102 break; |
| 103 m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFirst()); | 103 m_inOrderScriptsToExecuteSoon.push_back( |
| 104 m_pendingInOrderScripts.takeFirst()); |
| 104 postTask(BLINK_FROM_HERE); | 105 postTask(BLINK_FROM_HERE); |
| 105 } | 106 } |
| 106 } | 107 } |
| 107 | 108 |
| 108 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, | 109 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, |
| 109 AsyncExecutionType executionType) { | 110 AsyncExecutionType executionType) { |
| 110 SECURITY_CHECK(scriptLoader); | 111 SECURITY_CHECK(scriptLoader); |
| 111 switch (executionType) { | 112 switch (executionType) { |
| 112 case Async: | 113 case Async: |
| 113 // SECURITY_CHECK() makes us crash in a controlled way in error cases | 114 // SECURITY_CHECK() makes us crash in a controlled way in error cases |
| 114 // where the ScriptLoader is associated with the wrong ScriptRunner | 115 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 115 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries | 116 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 116 // to detach). | 117 // to detach). |
| 117 SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); | 118 SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); |
| 118 | 119 |
| 119 m_pendingAsyncScripts.erase(scriptLoader); | 120 m_pendingAsyncScripts.erase(scriptLoader); |
| 120 m_asyncScriptsToExecuteSoon.append(scriptLoader); | 121 m_asyncScriptsToExecuteSoon.push_back(scriptLoader); |
| 121 | 122 |
| 122 postTask(BLINK_FROM_HERE); | 123 postTask(BLINK_FROM_HERE); |
| 123 | 124 |
| 124 break; | 125 break; |
| 125 | 126 |
| 126 case InOrder: | 127 case InOrder: |
| 127 SECURITY_CHECK(m_numberOfInOrderScriptsWithPendingNotification > 0); | 128 SECURITY_CHECK(m_numberOfInOrderScriptsWithPendingNotification > 0); |
| 128 m_numberOfInOrderScriptsWithPendingNotification--; | 129 m_numberOfInOrderScriptsWithPendingNotification--; |
| 129 | 130 |
| 130 scheduleReadyInOrderScripts(); | 131 scheduleReadyInOrderScripts(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 242 |
| 242 DEFINE_TRACE(ScriptRunner) { | 243 DEFINE_TRACE(ScriptRunner) { |
| 243 visitor->trace(m_document); | 244 visitor->trace(m_document); |
| 244 visitor->trace(m_pendingInOrderScripts); | 245 visitor->trace(m_pendingInOrderScripts); |
| 245 visitor->trace(m_pendingAsyncScripts); | 246 visitor->trace(m_pendingAsyncScripts); |
| 246 visitor->trace(m_asyncScriptsToExecuteSoon); | 247 visitor->trace(m_asyncScriptsToExecuteSoon); |
| 247 visitor->trace(m_inOrderScriptsToExecuteSoon); | 248 visitor->trace(m_inOrderScriptsToExecuteSoon); |
| 248 } | 249 } |
| 249 | 250 |
| 250 } // namespace blink | 251 } // namespace blink |
| OLD | NEW |