| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 6 rights reserved. | 6 rights reserved. |
| 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 // A manually set priority acts as a floor. This is used to ensure that | 190 // A manually set priority acts as a floor. This is used to ensure that |
| 191 // synchronous requests are always given the highest possible priority, as | 191 // synchronous requests are always given the highest possible priority, as |
| 192 // well as to ensure that there isn't priority churn if images move in and out | 192 // well as to ensure that there isn't priority churn if images move in and out |
| 193 // of the viewport, or is displayed more than once, both in and out of the | 193 // of the viewport, or is displayed more than once, both in and out of the |
| 194 // viewport. | 194 // viewport. |
| 195 return std::max(context().modifyPriorityForExperiments(priority), | 195 return std::max(context().modifyPriorityForExperiments(priority), |
| 196 request.resourceRequest().priority()); | 196 request.resourceRequest().priority()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 static void populateResourceTiming(ResourceTimingInfo* info, | 199 static void populateTimingInfo(ResourceTimingInfo* info, |
| 200 Resource* resource) { | 200 Resource* resource) { |
| 201 KURL initialURL = resource->response().redirectResponses().isEmpty() | 201 KURL initialURL = resource->response().redirectResponses().isEmpty() |
| 202 ? resource->resourceRequest().url() | 202 ? resource->resourceRequest().url() |
| 203 : resource->response().redirectResponses()[0].url(); | 203 : resource->response().redirectResponses()[0].url(); |
| 204 info->setInitialURL(initialURL); | 204 info->setInitialURL(initialURL); |
| 205 info->setFinalResponse(resource->response()); | 205 info->setFinalResponse(resource->response()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 static WebURLRequest::RequestContext requestContextFromType( | 208 static WebURLRequest::RequestContext requestContextFromType( |
| 209 bool isMainFrame, | 209 bool isMainFrame, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if (isStaticData) | 301 if (isStaticData) |
| 302 return; | 302 return; |
| 303 | 303 |
| 304 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && | 304 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && |
| 305 !m_validatedURLs.contains(request.resourceRequest().url())) { | 305 !m_validatedURLs.contains(request.resourceRequest().url())) { |
| 306 // Resources loaded from memory cache should be reported the first time | 306 // Resources loaded from memory cache should be reported the first time |
| 307 // they're used. | 307 // they're used. |
| 308 std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create( | 308 std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create( |
| 309 request.options().initiatorInfo.name, monotonicallyIncreasingTime(), | 309 request.options().initiatorInfo.name, monotonicallyIncreasingTime(), |
| 310 resource->getType() == Resource::MainResource); | 310 resource->getType() == Resource::MainResource); |
| 311 populateResourceTiming(info.get(), resource); | 311 populateTimingInfo(info.get(), resource); |
| 312 info->clearLoadTimings(); | 312 info->clearLoadTimings(); |
| 313 info->setLoadFinishTime(info->initialTime()); | 313 info->setLoadFinishTime(info->initialTime()); |
| 314 m_scheduledResourceTimingReports.append(std::move(info)); | 314 m_scheduledResourceTimingReports.append(std::move(info)); |
| 315 if (!m_resourceTimingReportTimer.isActive()) | 315 if (!m_resourceTimingReportTimer.isActive()) |
| 316 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); | 316 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { | 319 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { |
| 320 m_validatedURLs.clear(); | 320 m_validatedURLs.clear(); |
| 321 } | 321 } |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 } | 1137 } |
| 1138 DCHECK(!m_loaders.contains(loader)); | 1138 DCHECK(!m_loaders.contains(loader)); |
| 1139 | 1139 |
| 1140 const int64_t encodedDataLength = resource->response().encodedDataLength(); | 1140 const int64_t encodedDataLength = resource->response().encodedDataLength(); |
| 1141 | 1141 |
| 1142 if (resource->getType() == Resource::MainResource) { | 1142 if (resource->getType() == Resource::MainResource) { |
| 1143 DCHECK(m_navigationTimingInfo); | 1143 DCHECK(m_navigationTimingInfo); |
| 1144 // Store redirect responses that were packed inside the final response. | 1144 // Store redirect responses that were packed inside the final response. |
| 1145 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); | 1145 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); |
| 1146 if (resource->response().isHTTP()) { | 1146 if (resource->response().isHTTP()) { |
| 1147 populateTimingInfo(m_navigationTimingInfo.get(), resource); |
| 1147 m_navigationTimingInfo->addFinalTransferSize( | 1148 m_navigationTimingInfo->addFinalTransferSize( |
| 1148 encodedDataLength == -1 ? 0 : encodedDataLength); | 1149 encodedDataLength == -1 ? 0 : encodedDataLength); |
| 1149 } | 1150 } |
| 1150 } | 1151 } |
| 1151 if (std::unique_ptr<ResourceTimingInfo> info = | 1152 if (std::unique_ptr<ResourceTimingInfo> info = |
| 1152 m_resourceTimingInfoMap.take(resource)) { | 1153 m_resourceTimingInfoMap.take(resource)) { |
| 1153 // Store redirect responses that were packed inside the final response. | 1154 // Store redirect responses that were packed inside the final response. |
| 1154 addRedirectsToTimingInfo(resource, info.get()); | 1155 addRedirectsToTimingInfo(resource, info.get()); |
| 1155 | 1156 |
| 1156 if (resource->response().isHTTP() && | 1157 if (resource->response().isHTTP() && |
| 1157 resource->response().httpStatusCode() < 400) { | 1158 resource->response().httpStatusCode() < 400) { |
| 1158 populateResourceTiming(info.get(), resource); | 1159 populateTimingInfo(info.get(), resource); |
| 1159 info->setLoadFinishTime(finishTime); | 1160 info->setLoadFinishTime(finishTime); |
| 1160 // encodedDataLength == -1 means "not available". | 1161 // encodedDataLength == -1 means "not available". |
| 1161 // TODO(ricea): Find cases where it is not available but the | 1162 // TODO(ricea): Find cases where it is not available but the |
| 1162 // PerformanceResourceTiming spec requires it to be available and fix | 1163 // PerformanceResourceTiming spec requires it to be available and fix |
| 1163 // them. | 1164 // them. |
| 1164 info->addFinalTransferSize(encodedDataLength == -1 ? 0 | 1165 info->addFinalTransferSize(encodedDataLength == -1 ? 0 |
| 1165 : encodedDataLength); | 1166 : encodedDataLength); |
| 1166 | 1167 |
| 1167 if (resource->options().requestInitiatorContext == DocumentContext) | 1168 if (resource->options().requestInitiatorContext == DocumentContext) |
| 1168 context().addResourceTiming(*info); | 1169 context().addResourceTiming(*info); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 visitor->trace(m_context); | 1523 visitor->trace(m_context); |
| 1523 visitor->trace(m_archive); | 1524 visitor->trace(m_archive); |
| 1524 visitor->trace(m_loaders); | 1525 visitor->trace(m_loaders); |
| 1525 visitor->trace(m_nonBlockingLoaders); | 1526 visitor->trace(m_nonBlockingLoaders); |
| 1526 visitor->trace(m_documentResources); | 1527 visitor->trace(m_documentResources); |
| 1527 visitor->trace(m_preloads); | 1528 visitor->trace(m_preloads); |
| 1528 visitor->trace(m_resourceTimingInfoMap); | 1529 visitor->trace(m_resourceTimingInfoMap); |
| 1529 } | 1530 } |
| 1530 | 1531 |
| 1531 } // namespace blink | 1532 } // namespace blink |
| OLD | NEW |