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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void ScriptRunner::resume() | 83 void ScriptRunner::resume() |
84 { | 84 { |
85 if (hasPendingScripts()) | 85 if (hasPendingScripts()) |
86 m_timer.startOneShot(0, FROM_HERE); | 86 m_timer.startOneShot(0, FROM_HERE); |
87 } | 87 } |
88 | 88 |
89 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType e
xecutionType) | 89 void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType e
xecutionType) |
90 { | 90 { |
91 switch (executionType) { | 91 switch (executionType) { |
92 case ASYNC_EXECUTION: | 92 case ASYNC_EXECUTION: |
93 ASSERT(m_pendingAsyncScripts.contains(scriptLoader)); | 93 // RELEASE_ASSERT makes us crash in a controlled way in error cases |
| 94 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 95 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 96 // to detach). |
| 97 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(
scriptLoader)); |
94 m_scriptsToExecuteSoon.append(scriptLoader); | 98 m_scriptsToExecuteSoon.append(scriptLoader); |
95 m_pendingAsyncScripts.remove(scriptLoader); | 99 m_pendingAsyncScripts.remove(scriptLoader); |
96 break; | 100 break; |
97 | 101 |
98 case IN_ORDER_EXECUTION: | 102 case IN_ORDER_EXECUTION: |
99 ASSERT(!m_scriptsToExecuteInOrder.isEmpty()); | 103 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!m_scriptsToExecuteInOrder.isEm
pty()); |
100 break; | 104 break; |
101 } | 105 } |
102 m_timer.startOneShot(0, FROM_HERE); | 106 m_timer.startOneShot(0, FROM_HERE); |
103 } | 107 } |
104 | 108 |
105 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
pe executionType) | 109 void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
pe executionType) |
106 { | 110 { |
107 switch (executionType) { | 111 switch (executionType) { |
108 case ASYNC_EXECUTION: | 112 case ASYNC_EXECUTION: |
109 ASSERT(m_pendingAsyncScripts.contains(scriptLoader)); | 113 // RELEASE_ASSERT makes us crash in a controlled way in error cases |
| 114 // where the ScriptLoader is associated with the wrong ScriptRunner |
| 115 // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries |
| 116 // to detach). |
| 117 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(
scriptLoader)); |
110 m_pendingAsyncScripts.remove(scriptLoader); | 118 m_pendingAsyncScripts.remove(scriptLoader); |
111 scriptLoader->detach(); | 119 scriptLoader->detach(); |
112 m_document->decrementLoadEventDelayCount(); | 120 m_document->decrementLoadEventDelayCount(); |
113 break; | 121 break; |
114 | 122 |
115 case IN_ORDER_EXECUTION: | 123 case IN_ORDER_EXECUTION: |
116 ASSERT(!m_scriptsToExecuteInOrder.isEmpty()); | 124 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!m_scriptsToExecuteInOrder.isEm
pty()); |
117 break; | 125 break; |
118 } | 126 } |
119 } | 127 } |
120 | 128 |
121 void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDo
cument, ScriptLoader* scriptLoader) | 129 void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDo
cument, ScriptLoader* scriptLoader) |
122 { | 130 { |
123 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); | 131 RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocumen
t().get(); |
124 if (!newContextDocument) { | 132 if (!newContextDocument) { |
125 // Document's contextDocument() method will return no Document if the | 133 // Document's contextDocument() method will return no Document if the |
126 // following conditions both hold: | 134 // following conditions both hold: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 { | 187 { |
180 #if ENABLE(OILPAN) | 188 #if ENABLE(OILPAN) |
181 visitor->trace(m_document); | 189 visitor->trace(m_document); |
182 visitor->trace(m_scriptsToExecuteInOrder); | 190 visitor->trace(m_scriptsToExecuteInOrder); |
183 visitor->trace(m_scriptsToExecuteSoon); | 191 visitor->trace(m_scriptsToExecuteSoon); |
184 visitor->trace(m_pendingAsyncScripts); | 192 visitor->trace(m_pendingAsyncScripts); |
185 #endif | 193 #endif |
186 } | 194 } |
187 | 195 |
188 } | 196 } |
OLD | NEW |