Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: Source/core/dom/ScriptRunner.cpp

Issue 660233002: Oilpan: move ScriptLoader to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: No detachment of ScriptLoaders when finalizing ScriptRunner Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/dom/ScriptRunner.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 35
36 ScriptRunner::ScriptRunner(Document* document) 36 ScriptRunner::ScriptRunner(Document* document)
37 : m_document(document) 37 : m_document(document)
38 , m_timer(this, &ScriptRunner::timerFired) 38 , m_timer(this, &ScriptRunner::timerFired)
39 { 39 {
40 ASSERT(document); 40 ASSERT(document);
41 } 41 }
42 42
43 ScriptRunner::~ScriptRunner() 43 ScriptRunner::~ScriptRunner()
44 { 44 {
45 #if !ENABLE(OILPAN)
45 // Make sure that ScriptLoaders don't keep their PendingScripts alive. 46 // Make sure that ScriptLoaders don't keep their PendingScripts alive.
46 for (size_t i = 0; i < m_scriptsToExecuteInOrder.size(); ++i) 47 for (ScriptLoader* scriptLoader : m_scriptsToExecuteInOrder)
47 m_scriptsToExecuteInOrder[i]->detach(); 48 scriptLoader->detach();
48 for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i) 49 for (ScriptLoader* scriptLoader : m_scriptsToExecuteSoon)
49 m_scriptsToExecuteSoon[i]->detach(); 50 scriptLoader->detach();
50 for (HashSet<ScriptLoader*>::iterator it = m_pendingAsyncScripts.begin(); it != m_pendingAsyncScripts.end(); ++it) 51 for (ScriptLoader* scriptLoader : m_pendingAsyncScripts)
51 (*it)->detach(); 52 scriptLoader->detach();
53 #endif
52 } 54 }
53 55
54 void ScriptRunner::addPendingAsyncScript(ScriptLoader* scriptLoader) 56 void ScriptRunner::addPendingAsyncScript(ScriptLoader* scriptLoader)
55 { 57 {
56 m_document->incrementLoadEventDelayCount(); 58 m_document->incrementLoadEventDelayCount();
57 m_pendingAsyncScripts.add(scriptLoader); 59 m_pendingAsyncScripts.add(scriptLoader);
58 } 60 }
59 61
60 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, Execution Type executionType) 62 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, Execution Type executionType)
61 { 63 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 m_document->decrementLoadEventDelayCount(); 126 m_document->decrementLoadEventDelayCount();
125 } 127 }
126 } 128 }
127 129
128 void ScriptRunner::timerFired(Timer<ScriptRunner>* timer) 130 void ScriptRunner::timerFired(Timer<ScriptRunner>* timer)
129 { 131 {
130 ASSERT_UNUSED(timer, timer == &m_timer); 132 ASSERT_UNUSED(timer, timer == &m_timer);
131 133
132 RefPtrWillBeRawPtr<Document> protect(m_document.get()); 134 RefPtrWillBeRawPtr<Document> protect(m_document.get());
133 135
134 Vector<ScriptLoader*> scriptLoaders; 136 WillBeHeapVector<RawPtrWillBeMember<ScriptLoader> > scriptLoaders;
135 scriptLoaders.swap(m_scriptsToExecuteSoon); 137 scriptLoaders.swap(m_scriptsToExecuteSoon);
136 138
137 size_t numInOrderScriptsToExecute = 0; 139 size_t numInOrderScriptsToExecute = 0;
138 for (; numInOrderScriptsToExecute < m_scriptsToExecuteInOrder.size() && m_sc riptsToExecuteInOrder[numInOrderScriptsToExecute]->isReady(); ++numInOrderScript sToExecute) 140 for (; numInOrderScriptsToExecute < m_scriptsToExecuteInOrder.size() && m_sc riptsToExecuteInOrder[numInOrderScriptsToExecute]->isReady(); ++numInOrderScript sToExecute)
139 scriptLoaders.append(m_scriptsToExecuteInOrder[numInOrderScriptsToExecut e]); 141 scriptLoaders.append(m_scriptsToExecuteInOrder[numInOrderScriptsToExecut e]);
140 if (numInOrderScriptsToExecute) 142 if (numInOrderScriptsToExecute)
141 m_scriptsToExecuteInOrder.remove(0, numInOrderScriptsToExecute); 143 m_scriptsToExecuteInOrder.remove(0, numInOrderScriptsToExecute);
142 144
143 size_t size = scriptLoaders.size(); 145 size_t size = scriptLoaders.size();
144 for (size_t i = 0; i < size; ++i) { 146 for (size_t i = 0; i < size; ++i) {
145 scriptLoaders[i]->execute(); 147 scriptLoaders[i]->execute();
146 m_document->decrementLoadEventDelayCount(); 148 m_document->decrementLoadEventDelayCount();
147 } 149 }
148 } 150 }
149 151
150 void ScriptRunner::trace(Visitor* visitor) 152 void ScriptRunner::trace(Visitor* visitor)
151 { 153 {
152 #if ENABLE(OILPAN) 154 #if ENABLE(OILPAN)
153 visitor->trace(m_document); 155 visitor->trace(m_document);
154 visitor->trace(m_scriptsToExecuteInOrder); 156 visitor->trace(m_scriptsToExecuteInOrder);
155 visitor->trace(m_scriptsToExecuteSoon); 157 visitor->trace(m_scriptsToExecuteSoon);
156 visitor->trace(m_pendingAsyncScripts); 158 visitor->trace(m_pendingAsyncScripts);
157 #endif 159 #endif
158 } 160 }
159 161
160 } 162 }
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptRunner.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698