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