| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 // A manually set priority acts as a floor. This is used to ensure that | 189 // A manually set priority acts as a floor. This is used to ensure that |
| 190 // synchronous requests are always given the highest possible priority, as | 190 // synchronous requests are always given the highest possible priority, as |
| 191 // well as to ensure that there isn't priority churn if images move in and out | 191 // well as to ensure that there isn't priority churn if images move in and out |
| 192 // of the viewport, or is displayed more than once, both in and out of the | 192 // of the viewport, or is displayed more than once, both in and out of the |
| 193 // viewport. | 193 // viewport. |
| 194 return std::max(context().modifyPriorityForExperiments(priority), | 194 return std::max(context().modifyPriorityForExperiments(priority), |
| 195 request.resourceRequest().priority()); | 195 request.resourceRequest().priority()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 static void populateResourceTiming(ResourceTimingInfo* info, | 198 static void populateTimingInfo(ResourceTimingInfo* info, |
| 199 Resource* resource) { | 199 Resource* resource) { |
| 200 KURL initialURL = resource->response().redirectResponses().isEmpty() | 200 KURL initialURL = resource->response().redirectResponses().isEmpty() |
| 201 ? resource->resourceRequest().url() | 201 ? resource->resourceRequest().url() |
| 202 : resource->response().redirectResponses()[0].url(); | 202 : resource->response().redirectResponses()[0].url(); |
| 203 info->setInitialURL(initialURL); | 203 info->setInitialURL(initialURL); |
| 204 info->setFinalResponse(resource->response()); | 204 info->setFinalResponse(resource->response()); |
| 205 } | 205 } |
| 206 | 206 |
| 207 static WebURLRequest::RequestContext requestContextFromType( | 207 static WebURLRequest::RequestContext requestContextFromType( |
| 208 bool isMainFrame, | 208 bool isMainFrame, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 if (isStaticData) | 300 if (isStaticData) |
| 301 return; | 301 return; |
| 302 | 302 |
| 303 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && | 303 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && |
| 304 !m_validatedURLs.contains(request.resourceRequest().url())) { | 304 !m_validatedURLs.contains(request.resourceRequest().url())) { |
| 305 // Resources loaded from memory cache should be reported the first time | 305 // Resources loaded from memory cache should be reported the first time |
| 306 // they're used. | 306 // they're used. |
| 307 std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create( | 307 std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create( |
| 308 request.options().initiatorInfo.name, monotonicallyIncreasingTime(), | 308 request.options().initiatorInfo.name, monotonicallyIncreasingTime(), |
| 309 resource->getType() == Resource::MainResource); | 309 resource->getType() == Resource::MainResource); |
| 310 populateResourceTiming(info.get(), resource); | 310 populateTimingInfo(info.get(), resource); |
| 311 info->clearLoadTimings(); | 311 info->clearLoadTimings(); |
| 312 info->setLoadFinishTime(info->initialTime()); | 312 info->setLoadFinishTime(info->initialTime()); |
| 313 m_scheduledResourceTimingReports.push_back(std::move(info)); | 313 m_scheduledResourceTimingReports.push_back(std::move(info)); |
| 314 if (!m_resourceTimingReportTimer.isActive()) | 314 if (!m_resourceTimingReportTimer.isActive()) |
| 315 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); | 315 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 316 } | 316 } |
| 317 | 317 |
| 318 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { | 318 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { |
| 319 m_validatedURLs.clear(); | 319 m_validatedURLs.clear(); |
| 320 } | 320 } |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 } | 1116 } |
| 1117 DCHECK(!m_loaders.contains(loader)); | 1117 DCHECK(!m_loaders.contains(loader)); |
| 1118 | 1118 |
| 1119 const int64_t encodedDataLength = resource->response().encodedDataLength(); | 1119 const int64_t encodedDataLength = resource->response().encodedDataLength(); |
| 1120 | 1120 |
| 1121 if (resource->getType() == Resource::MainResource) { | 1121 if (resource->getType() == Resource::MainResource) { |
| 1122 DCHECK(m_navigationTimingInfo); | 1122 DCHECK(m_navigationTimingInfo); |
| 1123 // Store redirect responses that were packed inside the final response. | 1123 // Store redirect responses that were packed inside the final response. |
| 1124 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); | 1124 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); |
| 1125 if (resource->response().isHTTP()) { | 1125 if (resource->response().isHTTP()) { |
| 1126 populateTimingInfo(m_navigationTimingInfo.get(), resource); |
| 1126 m_navigationTimingInfo->addFinalTransferSize( | 1127 m_navigationTimingInfo->addFinalTransferSize( |
| 1127 encodedDataLength == -1 ? 0 : encodedDataLength); | 1128 encodedDataLength == -1 ? 0 : encodedDataLength); |
| 1128 } | 1129 } |
| 1129 } | 1130 } |
| 1130 if (std::unique_ptr<ResourceTimingInfo> info = | 1131 if (std::unique_ptr<ResourceTimingInfo> info = |
| 1131 m_resourceTimingInfoMap.take(resource)) { | 1132 m_resourceTimingInfoMap.take(resource)) { |
| 1132 // Store redirect responses that were packed inside the final response. | 1133 // Store redirect responses that were packed inside the final response. |
| 1133 addRedirectsToTimingInfo(resource, info.get()); | 1134 addRedirectsToTimingInfo(resource, info.get()); |
| 1134 | 1135 |
| 1135 if (resource->response().isHTTP() && | 1136 if (resource->response().isHTTP() && |
| 1136 resource->response().httpStatusCode() < 400) { | 1137 resource->response().httpStatusCode() < 400) { |
| 1137 populateResourceTiming(info.get(), resource); | 1138 populateTimingInfo(info.get(), resource); |
| 1138 info->setLoadFinishTime(finishTime); | 1139 info->setLoadFinishTime(finishTime); |
| 1139 // encodedDataLength == -1 means "not available". | 1140 // encodedDataLength == -1 means "not available". |
| 1140 // TODO(ricea): Find cases where it is not available but the | 1141 // TODO(ricea): Find cases where it is not available but the |
| 1141 // PerformanceResourceTiming spec requires it to be available and fix | 1142 // PerformanceResourceTiming spec requires it to be available and fix |
| 1142 // them. | 1143 // them. |
| 1143 info->addFinalTransferSize(encodedDataLength == -1 ? 0 | 1144 info->addFinalTransferSize(encodedDataLength == -1 ? 0 |
| 1144 : encodedDataLength); | 1145 : encodedDataLength); |
| 1145 | 1146 |
| 1146 if (resource->options().requestInitiatorContext == DocumentContext) | 1147 if (resource->options().requestInitiatorContext == DocumentContext) |
| 1147 context().addResourceTiming(*info); | 1148 context().addResourceTiming(*info); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 visitor->trace(m_context); | 1502 visitor->trace(m_context); |
| 1502 visitor->trace(m_archive); | 1503 visitor->trace(m_archive); |
| 1503 visitor->trace(m_loaders); | 1504 visitor->trace(m_loaders); |
| 1504 visitor->trace(m_nonBlockingLoaders); | 1505 visitor->trace(m_nonBlockingLoaders); |
| 1505 visitor->trace(m_documentResources); | 1506 visitor->trace(m_documentResources); |
| 1506 visitor->trace(m_preloads); | 1507 visitor->trace(m_preloads); |
| 1507 visitor->trace(m_resourceTimingInfoMap); | 1508 visitor->trace(m_resourceTimingInfoMap); |
| 1508 } | 1509 } |
| 1509 | 1510 |
| 1510 } // namespace blink | 1511 } // namespace blink |
| OLD | NEW |