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

Side by Side Diff: third_party/WebKit/Source/core/dom/PendingScript.cpp

Issue 2268153002: Make PendingScript MemoryCoordinatorClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 | « third_party/WebKit/Source/core/dom/PendingScript.h ('k') | no next file » | 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 30 matching lines...) Expand all
41 41
42 PendingScript::PendingScript(Element* element, ScriptResource* resource) 42 PendingScript::PendingScript(Element* element, ScriptResource* resource)
43 : m_watchingForLoad(false) 43 : m_watchingForLoad(false)
44 , m_element(element) 44 , m_element(element)
45 , m_integrityFailure(false) 45 , m_integrityFailure(false)
46 , m_parserBlockingLoadStartTime(0) 46 , m_parserBlockingLoadStartTime(0)
47 , m_client(nullptr) 47 , m_client(nullptr)
48 { 48 {
49 setScriptResource(resource); 49 setScriptResource(resource);
50 ThreadState::current()->registerPreFinalizer(this); 50 ThreadState::current()->registerPreFinalizer(this);
51 MemoryCoordinator::instance().registerClient(this);
51 } 52 }
52 53
53 PendingScript::~PendingScript() 54 PendingScript::~PendingScript()
54 { 55 {
56 MemoryCoordinator::instance().unregisterClient(this);
haraken 2016/08/24 06:11:12 You don't need to (shouldn't) call this. Oilpan's
tasak 2016/08/24 07:44:54 Done.
55 } 57 }
56 58
57 void PendingScript::dispose() 59 void PendingScript::dispose()
58 { 60 {
59 if (!m_client) 61 if (!m_client)
60 return; 62 return;
61 stopWatchingForLoad(); 63 stopWatchingForLoad();
62 releaseElementAndClear(); 64 releaseElementAndClear();
63 } 65 }
64 66
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (m_streamer) 182 if (m_streamer)
181 m_streamer->notifyAppendData(resource); 183 m_streamer->notifyAppendData(resource);
182 } 184 }
183 185
184 DEFINE_TRACE(PendingScript) 186 DEFINE_TRACE(PendingScript)
185 { 187 {
186 visitor->trace(m_element); 188 visitor->trace(m_element);
187 visitor->trace(m_streamer); 189 visitor->trace(m_streamer);
188 visitor->trace(m_client); 190 visitor->trace(m_client);
189 ResourceOwner<ScriptResource>::trace(visitor); 191 ResourceOwner<ScriptResource>::trace(visitor);
192 MemoryCoordinatorClient::trace(visitor);
190 } 193 }
191 194
192 ScriptSourceCode PendingScript::getSource(const KURL& documentURL, bool& errorOc curred) const 195 ScriptSourceCode PendingScript::getSource(const KURL& documentURL, bool& errorOc curred) const
193 { 196 {
194 if (resource()) { 197 if (resource()) {
195 errorOccurred = resource()->errorOccurred() || m_integrityFailure; 198 errorOccurred = resource()->errorOccurred() || m_integrityFailure;
196 DCHECK(resource()->isLoaded()); 199 DCHECK(resource()->isLoaded());
197 if (m_streamer && !m_streamer->streamingSuppressed()) 200 if (m_streamer && !m_streamer->streamingSuppressed())
198 return ScriptSourceCode(m_streamer, resource()); 201 return ScriptSourceCode(m_streamer, resource());
199 return ScriptSourceCode(resource()); 202 return ScriptSourceCode(resource());
(...skipping 20 matching lines...) Expand all
220 223
221 bool PendingScript::errorOccurred() const 224 bool PendingScript::errorOccurred() const
222 { 225 {
223 if (resource()) 226 if (resource())
224 return resource()->errorOccurred(); 227 return resource()->errorOccurred();
225 if (m_streamer && m_streamer->resource()) 228 if (m_streamer && m_streamer->resource())
226 return m_streamer->resource()->errorOccurred(); 229 return m_streamer->resource()->errorOccurred();
227 return false; 230 return false;
228 } 231 }
229 232
233 void PendingScript::prepareToSuspend()
234 {
235 if (resource() && resource()->isLoaded())
haraken 2016/08/24 06:11:12 Would you help me understand why we need this chec
tasak 2016/08/24 07:44:53 When I chatted with hiroshige@, he said that Scrip
marja 2016/08/24 09:02:55 If the resource is loaded we might still be parsin
tasak 2016/08/24 11:01:03 In the case, I would like to update ScriptResource
236 return;
237 if (!m_streamer)
238 return;
239 m_streamer->cancel();
240 }
241
230 } // namespace blink 242 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/PendingScript.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698