OLD | NEW |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 DEFINE_TRACE(ProgressTracker) | 85 DEFINE_TRACE(ProgressTracker) |
86 { | 86 { |
87 visitor->trace(m_frame); | 87 visitor->trace(m_frame); |
88 } | 88 } |
89 | 89 |
90 void ProgressTracker::dispose() | 90 void ProgressTracker::dispose() |
91 { | 91 { |
92 if (m_frame->isLoading()) | 92 if (m_frame->isLoading()) |
93 progressCompleted(); | 93 progressCompleted(); |
94 ASSERT(!m_frame->isLoading()); | 94 DCHECK(!m_frame->isLoading()); |
95 } | 95 } |
96 | 96 |
97 double ProgressTracker::estimatedProgress() const | 97 double ProgressTracker::estimatedProgress() const |
98 { | 98 { |
99 return m_progressValue; | 99 return m_progressValue; |
100 } | 100 } |
101 | 101 |
102 void ProgressTracker::reset() | 102 void ProgressTracker::reset() |
103 { | 103 { |
104 m_progressItems.clear(); | 104 m_progressItems.clear(); |
105 m_progressValue = 0; | 105 m_progressValue = 0; |
106 m_lastNotifiedProgressValue = 0; | 106 m_lastNotifiedProgressValue = 0; |
107 m_lastNotifiedProgressTime = 0; | 107 m_lastNotifiedProgressTime = 0; |
108 m_finishedParsing = false; | 108 m_finishedParsing = false; |
109 } | 109 } |
110 | 110 |
111 void ProgressTracker::progressStarted() | 111 void ProgressTracker::progressStarted() |
112 { | 112 { |
113 if (!m_frame->isLoading()) | 113 if (!m_frame->isLoading()) |
114 m_frame->loader().client()->didStartLoading(NavigationToDifferentDocumen
t); | 114 m_frame->loader().client()->didStartLoading(NavigationToDifferentDocumen
t); |
115 reset(); | 115 reset(); |
116 m_progressValue = initialProgressValue; | 116 m_progressValue = initialProgressValue; |
117 m_frame->setIsLoading(true); | 117 m_frame->setIsLoading(true); |
118 InspectorInstrumentation::frameStartedLoading(m_frame); | 118 InspectorInstrumentation::frameStartedLoading(m_frame); |
119 } | 119 } |
120 | 120 |
121 void ProgressTracker::progressCompleted() | 121 void ProgressTracker::progressCompleted() |
122 { | 122 { |
123 ASSERT(m_frame->isLoading()); | 123 DCHECK(m_frame->isLoading()); |
124 m_frame->setIsLoading(false); | 124 m_frame->setIsLoading(false); |
125 sendFinalProgress(); | 125 sendFinalProgress(); |
126 reset(); | 126 reset(); |
127 m_frame->loader().client()->didStopLoading(); | 127 m_frame->loader().client()->didStopLoading(); |
128 InspectorInstrumentation::frameStoppedLoading(m_frame); | 128 InspectorInstrumentation::frameStoppedLoading(m_frame); |
129 } | 129 } |
130 | 130 |
131 void ProgressTracker::finishedParsing() | 131 void ProgressTracker::finishedParsing() |
132 { | 132 { |
133 m_finishedParsing = true; | 133 m_finishedParsing = true; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return; | 205 return; |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 double percentOfBytesReceived = !estimatedBytesForPendingRequests ? 1.0 : (d
ouble)bytesReceived / (double)estimatedBytesForPendingRequests; | 209 double percentOfBytesReceived = !estimatedBytesForPendingRequests ? 1.0 : (d
ouble)bytesReceived / (double)estimatedBytesForPendingRequests; |
210 m_progressValue += percentOfBytesReceived / 2; | 210 m_progressValue += percentOfBytesReceived / 2; |
211 | 211 |
212 DCHECK_GE(m_progressValue, initialProgressValue); | 212 DCHECK_GE(m_progressValue, initialProgressValue); |
213 // Always leave space at the end. This helps show the user that we're not | 213 // Always leave space at the end. This helps show the user that we're not |
214 // done until we're done. | 214 // done until we're done. |
215 DCHECK(m_progressValue <= 0.9); | 215 DCHECK_LE(m_progressValue, 0.9); |
216 if (m_progressValue < m_lastNotifiedProgressValue) | 216 if (m_progressValue < m_lastNotifiedProgressValue) |
217 return; | 217 return; |
218 | 218 |
219 double now = currentTime(); | 219 double now = currentTime(); |
220 double notifiedProgressTimeDelta = now - m_lastNotifiedProgressTime; | 220 double notifiedProgressTimeDelta = now - m_lastNotifiedProgressTime; |
221 | 221 |
222 double notificationProgressDelta = m_progressValue - m_lastNotifiedProgressV
alue; | 222 double notificationProgressDelta = m_progressValue - m_lastNotifiedProgressV
alue; |
223 if (notificationProgressDelta >= progressNotificationInterval || notifiedPro
gressTimeDelta >= progressNotificationTimeInterval) { | 223 if (notificationProgressDelta >= progressNotificationInterval || notifiedPro
gressTimeDelta >= progressNotificationTimeInterval) { |
224 m_frame->loader().client()->progressEstimateChanged(m_progressValue); | 224 m_frame->loader().client()->progressEstimateChanged(m_progressValue); |
225 m_lastNotifiedProgressValue = m_progressValue; | 225 m_lastNotifiedProgressValue = m_progressValue; |
226 m_lastNotifiedProgressTime = now; | 226 m_lastNotifiedProgressTime = now; |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 void ProgressTracker::completeProgress(unsigned long identifier) | 230 void ProgressTracker::completeProgress(unsigned long identifier) |
231 { | 231 { |
232 ProgressItem* item = m_progressItems.get(identifier); | 232 ProgressItem* item = m_progressItems.get(identifier); |
233 if (!item) | 233 if (!item) |
234 return; | 234 return; |
235 | 235 |
236 item->estimatedLength = item->bytesReceived; | 236 item->estimatedLength = item->bytesReceived; |
237 maybeSendProgress(); | 237 maybeSendProgress(); |
238 } | 238 } |
239 | 239 |
240 } // namespace blink | 240 } // namespace blink |
OLD | NEW |