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

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

Issue 2536553002: Simplify: remove PendingScript::releaseElementAndClear (Closed)
Patch Set: Created 4 years 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
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 m_parserBlockingLoadStartTime(0), 45 m_parserBlockingLoadStartTime(0),
46 m_client(nullptr) { 46 m_client(nullptr) {
47 setScriptResource(resource); 47 setScriptResource(resource);
48 ThreadState::current()->registerPreFinalizer(this); 48 ThreadState::current()->registerPreFinalizer(this);
49 MemoryCoordinator::instance().registerClient(this); 49 MemoryCoordinator::instance().registerClient(this);
50 } 50 }
51 51
52 PendingScript::~PendingScript() {} 52 PendingScript::~PendingScript() {}
53 53
54 void PendingScript::dispose() { 54 void PendingScript::dispose() {
55 if (!m_client) 55 if (m_client)
sof 2016/11/28 16:17:59 stopWatchingForLoad() already checks for not being
kouhei (in TOK) 2016/11/29 00:49:05 Done.
56 return; 56 stopWatchingForLoad();
57 stopWatchingForLoad(); 57
58 releaseElementAndClear(); 58 DCHECK(!m_client);
59 setScriptResource(nullptr);
60 m_watchingForLoad = false;
sof 2016/11/28 16:17:59 This ought to be redundant now.
kouhei (in TOK) 2016/11/29 00:49:04 Done.
61 m_startingPosition = TextPosition::belowRangePosition();
62 m_integrityFailure = false;
63 m_parserBlockingLoadStartTime = 0;
64 if (m_streamer)
65 m_streamer->cancel();
66 m_streamer = nullptr;
67 m_element = nullptr;
59 } 68 }
60 69
61 void PendingScript::watchForLoad(ScriptResourceClient* client) { 70 void PendingScript::watchForLoad(ScriptResourceClient* client) {
62 DCHECK(!m_watchingForLoad); 71 DCHECK(!m_watchingForLoad);
63 // addClient() will call streamingFinished() if the load is complete. Callers 72 // addClient() will call streamingFinished() if the load is complete. Callers
64 // who do not expect to be re-entered from this call should not call 73 // who do not expect to be re-entered from this call should not call
65 // watchForLoad for a PendingScript which isReady. We also need to set 74 // watchForLoad for a PendingScript which isReady. We also need to set
66 // m_watchingForLoad early, since addClient() can result in calling 75 // m_watchingForLoad early, since addClient() can result in calling
67 // notifyFinished and further stopWatchingForLoad(). 76 // notifyFinished and further stopWatchingForLoad().
68 m_watchingForLoad = true; 77 m_watchingForLoad = true;
(...skipping 15 matching lines...) Expand all
84 void PendingScript::streamingFinished() { 93 void PendingScript::streamingFinished() {
85 DCHECK(resource()); 94 DCHECK(resource());
86 if (m_client) 95 if (m_client)
87 m_client->notifyFinished(resource()); 96 m_client->notifyFinished(resource());
88 } 97 }
89 98
90 void PendingScript::setElement(Element* element) { 99 void PendingScript::setElement(Element* element) {
91 m_element = element; 100 m_element = element;
92 } 101 }
93 102
94 Element* PendingScript::releaseElementAndClear() {
95 setScriptResource(0);
96 m_watchingForLoad = false;
97 m_startingPosition = TextPosition::belowRangePosition();
98 m_integrityFailure = false;
99 m_parserBlockingLoadStartTime = 0;
100 if (m_streamer)
101 m_streamer->cancel();
102 m_streamer.release();
103 return m_element.release();
104 }
105
106 void PendingScript::setScriptResource(ScriptResource* resource) { 103 void PendingScript::setScriptResource(ScriptResource* resource) {
107 setResource(resource); 104 setResource(resource);
108 } 105 }
109 106
110 void PendingScript::markParserBlockingLoadStartTime() { 107 void PendingScript::markParserBlockingLoadStartTime() {
111 DCHECK_EQ(m_parserBlockingLoadStartTime, 0.0); 108 DCHECK_EQ(m_parserBlockingLoadStartTime, 0.0);
112 m_parserBlockingLoadStartTime = monotonicallyIncreasingTime(); 109 m_parserBlockingLoadStartTime = monotonicallyIncreasingTime();
113 } 110 }
114 111
115 void PendingScript::notifyFinished(Resource* resource) { 112 void PendingScript::notifyFinished(Resource* resource) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 220
224 void PendingScript::onMemoryStateChange(MemoryState state) { 221 void PendingScript::onMemoryStateChange(MemoryState state) {
225 if (state != MemoryState::SUSPENDED) 222 if (state != MemoryState::SUSPENDED)
226 return; 223 return;
227 if (!m_streamer) 224 if (!m_streamer)
228 return; 225 return;
229 m_streamer->cancel(); 226 m_streamer->cancel();
230 } 227 }
231 228
232 } // namespace blink 229 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698