| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ProgressTracker::willStartLoading(unsigned long identifier, | 132 void ProgressTracker::willStartLoading(unsigned long identifier, |
| 133 ResourceLoadPriority priority) { | 133 ResourceLoadPriority priority) { |
| 134 if (!m_frame->isLoading()) | 134 if (!m_frame->isLoading()) |
| 135 return; | 135 return; |
| 136 // All of the progress bar completion policies besides LoadEvent instead block | 136 // All of the progress bar completion policies besides LoadEvent instead block |
| 137 // on parsing completion, which corresponds to finishing parsing. For those | 137 // on parsing completion, which corresponds to finishing parsing. For those |
| 138 // policies, don't consider resource load that start after DOMContentLoaded | 138 // policies, don't consider resource load that start after DOMContentLoaded |
| 139 // finishes. | 139 // finishes. |
| 140 if (m_frame->settings()->progressBarCompletion() != | 140 if (m_frame->settings()->getProgressBarCompletion() != |
| 141 ProgressBarCompletion::LoadEvent && | 141 ProgressBarCompletion::LoadEvent && |
| 142 (m_finishedParsing || priority < ResourceLoadPriorityHigh)) | 142 (m_finishedParsing || priority < ResourceLoadPriorityHigh)) |
| 143 return; | 143 return; |
| 144 m_progressItems.set(identifier, WTF::makeUnique<ProgressItem>( | 144 m_progressItems.set(identifier, WTF::makeUnique<ProgressItem>( |
| 145 progressItemDefaultEstimatedLength)); | 145 progressItemDefaultEstimatedLength)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void ProgressTracker::incrementProgress(unsigned long identifier, | 148 void ProgressTracker::incrementProgress(unsigned long identifier, |
| 149 const ResourceResponse& response) { | 149 const ResourceResponse& response) { |
| 150 ProgressItem* item = m_progressItems.get(identifier); | 150 ProgressItem* item = m_progressItems.get(identifier); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 180 long long bytesReceived = 0; | 180 long long bytesReceived = 0; |
| 181 long long estimatedBytesForPendingRequests = 0; | 181 long long estimatedBytesForPendingRequests = 0; |
| 182 for (const auto& progressItem : m_progressItems) { | 182 for (const auto& progressItem : m_progressItems) { |
| 183 bytesReceived += progressItem.value->bytesReceived; | 183 bytesReceived += progressItem.value->bytesReceived; |
| 184 estimatedBytesForPendingRequests += progressItem.value->estimatedLength; | 184 estimatedBytesForPendingRequests += progressItem.value->estimatedLength; |
| 185 } | 185 } |
| 186 DCHECK_GE(estimatedBytesForPendingRequests, 0); | 186 DCHECK_GE(estimatedBytesForPendingRequests, 0); |
| 187 DCHECK_GE(estimatedBytesForPendingRequests, bytesReceived); | 187 DCHECK_GE(estimatedBytesForPendingRequests, bytesReceived); |
| 188 | 188 |
| 189 if (m_finishedParsing) { | 189 if (m_finishedParsing) { |
| 190 if (m_frame->settings()->progressBarCompletion() == | 190 if (m_frame->settings()->getProgressBarCompletion() == |
| 191 ProgressBarCompletion::DOMContentLoaded) { | 191 ProgressBarCompletion::DOMContentLoaded) { |
| 192 sendFinalProgress(); | 192 sendFinalProgress(); |
| 193 return; | 193 return; |
| 194 } | 194 } |
| 195 if (m_frame->settings()->progressBarCompletion() != | 195 if (m_frame->settings()->getProgressBarCompletion() != |
| 196 ProgressBarCompletion::LoadEvent && | 196 ProgressBarCompletion::LoadEvent && |
| 197 estimatedBytesForPendingRequests == bytesReceived) { | 197 estimatedBytesForPendingRequests == bytesReceived) { |
| 198 sendFinalProgress(); | 198 sendFinalProgress(); |
| 199 return; | 199 return; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 double percentOfBytesReceived = | 203 double percentOfBytesReceived = |
| 204 !estimatedBytesForPendingRequests | 204 !estimatedBytesForPendingRequests |
| 205 ? 1.0 | 205 ? 1.0 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 229 void ProgressTracker::completeProgress(unsigned long identifier) { | 229 void ProgressTracker::completeProgress(unsigned long identifier) { |
| 230 ProgressItem* item = m_progressItems.get(identifier); | 230 ProgressItem* item = m_progressItems.get(identifier); |
| 231 if (!item) | 231 if (!item) |
| 232 return; | 232 return; |
| 233 | 233 |
| 234 item->estimatedLength = item->bytesReceived; | 234 item->estimatedLength = item->bytesReceived; |
| 235 maybeSendProgress(); | 235 maybeSendProgress(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace blink | 238 } // namespace blink |
| OLD | NEW |