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

Side by Side Diff: third_party/WebKit/Source/core/loader/ProgressTracker.cpp

Issue 2557053002: Use LocalFrame::client() than getting the FrameLoader and then call client() on it. (Closed)
Patch Set: Rebase Created 3 years, 11 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/loader/ProgressTracker.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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 void ProgressTracker::reset() { 94 void ProgressTracker::reset() {
95 m_progressItems.clear(); 95 m_progressItems.clear();
96 m_progressValue = 0; 96 m_progressValue = 0;
97 m_lastNotifiedProgressValue = 0; 97 m_lastNotifiedProgressValue = 0;
98 m_lastNotifiedProgressTime = 0; 98 m_lastNotifiedProgressTime = 0;
99 m_finishedParsing = false; 99 m_finishedParsing = false;
100 } 100 }
101 101
102 FrameLoaderClient* ProgressTracker::frameLoaderClient() const {
103 return m_frame->client();
104 }
105
102 void ProgressTracker::progressStarted() { 106 void ProgressTracker::progressStarted() {
103 if (!m_frame->isLoading()) 107 if (!m_frame->isLoading())
104 m_frame->loader().client()->didStartLoading(NavigationToDifferentDocument); 108 frameLoaderClient()->didStartLoading(NavigationToDifferentDocument);
105 reset(); 109 reset();
106 m_progressValue = initialProgressValue; 110 m_progressValue = initialProgressValue;
107 m_frame->setIsLoading(true); 111 m_frame->setIsLoading(true);
108 InspectorInstrumentation::frameStartedLoading(m_frame); 112 InspectorInstrumentation::frameStartedLoading(m_frame);
109 } 113 }
110 114
111 void ProgressTracker::progressCompleted() { 115 void ProgressTracker::progressCompleted() {
112 DCHECK(m_frame->isLoading()); 116 DCHECK(m_frame->isLoading());
113 m_frame->setIsLoading(false); 117 m_frame->setIsLoading(false);
114 sendFinalProgress(); 118 sendFinalProgress();
115 reset(); 119 reset();
116 m_frame->loader().client()->didStopLoading(); 120 frameLoaderClient()->didStopLoading();
117 InspectorInstrumentation::frameStoppedLoading(m_frame); 121 InspectorInstrumentation::frameStoppedLoading(m_frame);
118 } 122 }
119 123
120 void ProgressTracker::finishedParsing() { 124 void ProgressTracker::finishedParsing() {
121 m_finishedParsing = true; 125 m_finishedParsing = true;
122 maybeSendProgress(); 126 maybeSendProgress();
123 } 127 }
124 128
125 void ProgressTracker::sendFinalProgress() { 129 void ProgressTracker::sendFinalProgress() {
126 if (m_progressValue == 1) 130 if (m_progressValue == 1)
127 return; 131 return;
128 m_progressValue = 1; 132 m_progressValue = 1;
129 m_frame->loader().client()->progressEstimateChanged(m_progressValue); 133 frameLoaderClient()->progressEstimateChanged(m_progressValue);
130 } 134 }
131 135
132 void ProgressTracker::willStartLoading(unsigned long identifier, 136 void ProgressTracker::willStartLoading(unsigned long identifier,
133 ResourceLoadPriority priority) { 137 ResourceLoadPriority priority) {
134 if (!m_frame->isLoading()) 138 if (!m_frame->isLoading())
135 return; 139 return;
136 // All of the progress bar completion policies besides LoadEvent instead block 140 // All of the progress bar completion policies besides LoadEvent instead block
137 // on parsing completion, which corresponds to finishing parsing. For those 141 // on parsing completion, which corresponds to finishing parsing. For those
138 // policies, don't consider resource load that start after DOMContentLoaded 142 // policies, don't consider resource load that start after DOMContentLoaded
139 // finishes. 143 // finishes.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (m_progressValue < m_lastNotifiedProgressValue) 217 if (m_progressValue < m_lastNotifiedProgressValue)
214 return; 218 return;
215 219
216 double now = currentTime(); 220 double now = currentTime();
217 double notifiedProgressTimeDelta = now - m_lastNotifiedProgressTime; 221 double notifiedProgressTimeDelta = now - m_lastNotifiedProgressTime;
218 222
219 double notificationProgressDelta = 223 double notificationProgressDelta =
220 m_progressValue - m_lastNotifiedProgressValue; 224 m_progressValue - m_lastNotifiedProgressValue;
221 if (notificationProgressDelta >= progressNotificationInterval || 225 if (notificationProgressDelta >= progressNotificationInterval ||
222 notifiedProgressTimeDelta >= progressNotificationTimeInterval) { 226 notifiedProgressTimeDelta >= progressNotificationTimeInterval) {
223 m_frame->loader().client()->progressEstimateChanged(m_progressValue); 227 frameLoaderClient()->progressEstimateChanged(m_progressValue);
224 m_lastNotifiedProgressValue = m_progressValue; 228 m_lastNotifiedProgressValue = m_progressValue;
225 m_lastNotifiedProgressTime = now; 229 m_lastNotifiedProgressTime = now;
226 } 230 }
227 } 231 }
228 232
229 void ProgressTracker::completeProgress(unsigned long identifier) { 233 void ProgressTracker::completeProgress(unsigned long identifier) {
230 ProgressItem* item = m_progressItems.get(identifier); 234 ProgressItem* item = m_progressItems.get(identifier);
231 if (!item) 235 if (!item)
232 return; 236 return;
233 237
234 item->estimatedLength = item->bytesReceived; 238 item->estimatedLength = item->bytesReceived;
235 maybeSendProgress(); 239 maybeSendProgress();
236 } 240 }
237 241
238 } // namespace blink 242 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/ProgressTracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698