| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 m_progressValue = 0; | 100 m_progressValue = 0; |
| 101 m_lastNotifiedProgressValue = 0; | 101 m_lastNotifiedProgressValue = 0; |
| 102 m_lastNotifiedProgressTime = 0; | 102 m_lastNotifiedProgressTime = 0; |
| 103 m_finalProgressChangedSent = false; | 103 m_finalProgressChangedSent = false; |
| 104 m_numProgressTrackedFrames = 0; | 104 m_numProgressTrackedFrames = 0; |
| 105 m_originatingProgressFrame = 0; | 105 m_originatingProgressFrame = 0; |
| 106 } | 106 } |
| 107 | 107 |
| 108 void ProgressTracker::progressStarted(Frame* frame) | 108 void ProgressTracker::progressStarted(Frame* frame) |
| 109 { | 109 { |
| 110 LOG(Progress, "Progress started (%p) - frame %p(\"%s\"), value %f, tracked f
rames %d, originating frame %p", this, frame, frame->tree()->uniqueName().string
().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProg
ressFrame.get()); | 110 LOG_INFO(Progress, "Progress started (%p) - frame %p(\"%s\"), value %f, trac
ked frames %d, originating frame %p", |
| 111 this, frame, frame->tree()->uniqueName().string().utf8().data(), m_
progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get()); |
| 111 | 112 |
| 112 frame->loader()->client()->willChangeEstimatedProgress(); | 113 frame->loader()->client()->willChangeEstimatedProgress(); |
| 113 | 114 |
| 114 if (m_numProgressTrackedFrames == 0 || m_originatingProgressFrame == frame)
{ | 115 if (m_numProgressTrackedFrames == 0 || m_originatingProgressFrame == frame)
{ |
| 115 reset(); | 116 reset(); |
| 116 m_progressValue = initialProgressValue; | 117 m_progressValue = initialProgressValue; |
| 117 m_originatingProgressFrame = frame; | 118 m_originatingProgressFrame = frame; |
| 118 | 119 |
| 119 m_originatingProgressFrame->loader()->client()->postProgressStartedNotif
ication(); | 120 m_originatingProgressFrame->loader()->client()->postProgressStartedNotif
ication(); |
| 120 } | 121 } |
| 121 m_numProgressTrackedFrames++; | 122 m_numProgressTrackedFrames++; |
| 122 | 123 |
| 123 frame->loader()->client()->didChangeEstimatedProgress(); | 124 frame->loader()->client()->didChangeEstimatedProgress(); |
| 124 InspectorInstrumentation::frameStartedLoading(frame); | 125 InspectorInstrumentation::frameStartedLoading(frame); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void ProgressTracker::progressCompleted(Frame* frame) | 128 void ProgressTracker::progressCompleted(Frame* frame) |
| 128 { | 129 { |
| 129 LOG(Progress, "Progress completed (%p) - frame %p(\"%s\"), value %f, tracked
frames %d, originating frame %p", this, frame, frame->tree()->uniqueName().stri
ng().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingPr
ogressFrame.get()); | 130 LOG_INFO(Progress, "Progress completed (%p) - frame %p(\"%s\"), value %f, tr
acked frames %d, originating frame %p", |
| 131 this, frame, frame->tree()->uniqueName().string().utf8().data(), m_
progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get()); |
| 130 | 132 |
| 131 if (m_numProgressTrackedFrames <= 0) | 133 if (m_numProgressTrackedFrames <= 0) |
| 132 return; | 134 return; |
| 133 | 135 |
| 134 frame->loader()->client()->willChangeEstimatedProgress(); | 136 frame->loader()->client()->willChangeEstimatedProgress(); |
| 135 | 137 |
| 136 m_numProgressTrackedFrames--; | 138 m_numProgressTrackedFrames--; |
| 137 if (!m_numProgressTrackedFrames || m_originatingProgressFrame == frame) | 139 if (!m_numProgressTrackedFrames || m_originatingProgressFrame == frame) |
| 138 finalProgressComplete(); | 140 finalProgressComplete(); |
| 139 | 141 |
| 140 frame->loader()->client()->didChangeEstimatedProgress(); | 142 frame->loader()->client()->didChangeEstimatedProgress(); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void ProgressTracker::finalProgressComplete() | 145 void ProgressTracker::finalProgressComplete() |
| 144 { | 146 { |
| 145 LOG(Progress, "Final progress complete (%p)", this); | 147 LOG_INFO(Progress, "Final progress complete (%p)", this); |
| 146 | 148 |
| 147 RefPtr<Frame> frame = m_originatingProgressFrame.release(); | 149 RefPtr<Frame> frame = m_originatingProgressFrame.release(); |
| 148 | 150 |
| 149 // Before resetting progress value be sure to send client a least one notifi
cation | 151 // Before resetting progress value be sure to send client a least one notifi
cation |
| 150 // with final progress value. | 152 // with final progress value. |
| 151 if (!m_finalProgressChangedSent) { | 153 if (!m_finalProgressChangedSent) { |
| 152 m_progressValue = 1; | 154 m_progressValue = 1; |
| 153 frame->loader()->client()->postProgressEstimateChangedNotification(); | 155 frame->loader()->client()->postProgressEstimateChangedNotification(); |
| 154 } | 156 } |
| 155 | 157 |
| 156 reset(); | 158 reset(); |
| 157 | 159 |
| 158 frame->loader()->client()->setMainFrameDocumentReady(true); | 160 frame->loader()->client()->setMainFrameDocumentReady(true); |
| 159 frame->loader()->client()->postProgressFinishedNotification(); | 161 frame->loader()->client()->postProgressFinishedNotification(); |
| 160 InspectorInstrumentation::frameStoppedLoading(frame.get()); | 162 InspectorInstrumentation::frameStoppedLoading(frame.get()); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void ProgressTracker::incrementProgress(unsigned long identifier, const Resource
Response& response) | 165 void ProgressTracker::incrementProgress(unsigned long identifier, const Resource
Response& response) |
| 164 { | 166 { |
| 165 LOG(Progress, "Progress incremented (%p) - value %f, tracked frames %d, orig
inating frame %p", this, m_progressValue, m_numProgressTrackedFrames, m_originat
ingProgressFrame.get()); | 167 LOG_INFO(Progress, "Progress incremented (%p) - value %f, tracked frames %d,
originating frame %p", this, m_progressValue, m_numProgressTrackedFrames, m_ori
ginatingProgressFrame.get()); |
| 166 | 168 |
| 167 if (m_numProgressTrackedFrames <= 0) | 169 if (m_numProgressTrackedFrames <= 0) |
| 168 return; | 170 return; |
| 169 | 171 |
| 170 long long estimatedLength = response.expectedContentLength(); | 172 long long estimatedLength = response.expectedContentLength(); |
| 171 if (estimatedLength < 0) | 173 if (estimatedLength < 0) |
| 172 estimatedLength = progressItemDefaultEstimatedLength; | 174 estimatedLength = progressItemDefaultEstimatedLength; |
| 173 | 175 |
| 174 m_totalPageAndResourceBytesToLoad += estimatedLength; | 176 m_totalPageAndResourceBytesToLoad += estimatedLength; |
| 175 | 177 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 increment = (maxProgressValue - m_progressValue) * percentOfRemainingBytes; | 220 increment = (maxProgressValue - m_progressValue) * percentOfRemainingBytes; |
| 219 m_progressValue += increment; | 221 m_progressValue += increment; |
| 220 m_progressValue = min(m_progressValue, maxProgressValue); | 222 m_progressValue = min(m_progressValue, maxProgressValue); |
| 221 ASSERT(m_progressValue >= initialProgressValue); | 223 ASSERT(m_progressValue >= initialProgressValue); |
| 222 | 224 |
| 223 m_totalBytesReceived += bytesReceived; | 225 m_totalBytesReceived += bytesReceived; |
| 224 | 226 |
| 225 double now = currentTime(); | 227 double now = currentTime(); |
| 226 double notifiedProgressTimeDelta = now - m_lastNotifiedProgressTime; | 228 double notifiedProgressTimeDelta = now - m_lastNotifiedProgressTime; |
| 227 | 229 |
| 228 LOG(Progress, "Progress incremented (%p) - value %f, tracked frames %d", thi
s, m_progressValue, m_numProgressTrackedFrames); | 230 LOG_INFO(Progress, "Progress incremented (%p) - value %f, tracked frames %d"
, this, m_progressValue, m_numProgressTrackedFrames); |
| 229 double notificationProgressDelta = m_progressValue - m_lastNotifiedProgressV
alue; | 231 double notificationProgressDelta = m_progressValue - m_lastNotifiedProgressV
alue; |
| 230 if ((notificationProgressDelta >= m_progressNotificationInterval || | 232 if ((notificationProgressDelta >= m_progressNotificationInterval || |
| 231 notifiedProgressTimeDelta >= m_progressNotificationTimeInterval) && | 233 notifiedProgressTimeDelta >= m_progressNotificationTimeInterval) && |
| 232 m_numProgressTrackedFrames > 0) { | 234 m_numProgressTrackedFrames > 0) { |
| 233 if (!m_finalProgressChangedSent) { | 235 if (!m_finalProgressChangedSent) { |
| 234 if (m_progressValue == 1) | 236 if (m_progressValue == 1) |
| 235 m_finalProgressChangedSent = true; | 237 m_finalProgressChangedSent = true; |
| 236 | 238 |
| 237 frame->loader()->client()->postProgressEstimateChangedNotification()
; | 239 frame->loader()->client()->postProgressEstimateChangedNotification()
; |
| 238 | 240 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 259 m_progressItems.remove(identifier); | 261 m_progressItems.remove(identifier); |
| 260 } | 262 } |
| 261 | 263 |
| 262 unsigned long ProgressTracker::createUniqueIdentifier() | 264 unsigned long ProgressTracker::createUniqueIdentifier() |
| 263 { | 265 { |
| 264 return ++s_uniqueIdentifier; | 266 return ++s_uniqueIdentifier; |
| 265 } | 267 } |
| 266 | 268 |
| 267 | 269 |
| 268 } | 270 } |
| OLD | NEW |