| 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
rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
| 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 if (request.priority() != ResourceLoadPriorityUnresolved) | 137 if (request.priority() != ResourceLoadPriorityUnresolved) |
| 138 return request.priority(); | 138 return request.priority(); |
| 139 | 139 |
| 140 // Synchronous requests should always be max priority, lest they hang the re
nderer. | 140 // Synchronous requests should always be max priority, lest they hang the re
nderer. |
| 141 if (request.options().synchronousPolicy == RequestSynchronously) | 141 if (request.options().synchronousPolicy == RequestSynchronously) |
| 142 return ResourceLoadPriorityHighest; | 142 return ResourceLoadPriorityHighest; |
| 143 | 143 |
| 144 return context().modifyPriorityForExperiments(typeToPriority(type), type, re
quest, visibility); | 144 return context().modifyPriorityForExperiments(typeToPriority(type), type, re
quest, visibility); |
| 145 } | 145 } |
| 146 | 146 |
| 147 static void populateResourceTiming(ResourceTimingInfo* info, Resource* resource,
bool clearLoadTimings) | 147 static void populateResourceTiming(ResourceTimingInfo* info, Resource* resource) |
| 148 { | 148 { |
| 149 info->setInitialRequest(resource->resourceRequest()); | 149 info->setInitialRequest(resource->resourceRequest()); |
| 150 info->setFinalResponse(resource->response()); | 150 info->setFinalResponse(resource->response()); |
| 151 if (clearLoadTimings) { | |
| 152 info->clearLoadTimings(); | |
| 153 info->setLoadFinishTime(info->initialTime()); | |
| 154 } else { | |
| 155 info->setLoadFinishTime(resource->loadFinishTime()); | |
| 156 } | |
| 157 } | 151 } |
| 158 | 152 |
| 159 static WebURLRequest::RequestContext requestContextFromType(bool isMainFrame, Re
source::Type type) | 153 static WebURLRequest::RequestContext requestContextFromType(bool isMainFrame, Re
source::Type type) |
| 160 { | 154 { |
| 161 switch (type) { | 155 switch (type) { |
| 162 case Resource::MainResource: | 156 case Resource::MainResource: |
| 163 if (!isMainFrame) | 157 if (!isMainFrame) |
| 164 return WebURLRequest::RequestContextIframe; | 158 return WebURLRequest::RequestContextIframe; |
| 165 // FIXME: Change this to a context frame type (once we introduce them):
http://fetch.spec.whatwg.org/#concept-request-context-frame-type | 159 // FIXME: Change this to a context frame type (once we introduce them):
http://fetch.spec.whatwg.org/#concept-request-context-frame-type |
| 166 return WebURLRequest::RequestContextHyperlink; | 160 return WebURLRequest::RequestContextHyperlink; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 { | 267 { |
| 274 if (type == ResourceLoadingFromCache && resource->getStatus() == Resource::C
ached && !m_validatedURLs.contains(resource->url())) | 268 if (type == ResourceLoadingFromCache && resource->getStatus() == Resource::C
ached && !m_validatedURLs.contains(resource->url())) |
| 275 context().dispatchDidLoadResourceFromMemoryCache(resource, request.resou
rceRequest().frameType(), request.resourceRequest().requestContext()); | 269 context().dispatchDidLoadResourceFromMemoryCache(resource, request.resou
rceRequest().frameType(), request.resourceRequest().requestContext()); |
| 276 | 270 |
| 277 if (isStaticData) | 271 if (isStaticData) |
| 278 return; | 272 return; |
| 279 | 273 |
| 280 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { | 274 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { |
| 281 // Resources loaded from memory cache should be reported the first time
they're used. | 275 // Resources loaded from memory cache should be reported the first time
they're used. |
| 282 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.opt
ions().initiatorInfo.name, monotonicallyIncreasingTime(), resource->getType() ==
Resource::MainResource); | 276 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.opt
ions().initiatorInfo.name, monotonicallyIncreasingTime(), resource->getType() ==
Resource::MainResource); |
| 283 populateResourceTiming(info.get(), resource, true); | 277 populateResourceTiming(info.get(), resource); |
| 278 info->clearLoadTimings(); |
| 279 info->setLoadFinishTime(info->initialTime()); |
| 284 m_scheduledResourceTimingReports.append(info.release()); | 280 m_scheduledResourceTimingReports.append(info.release()); |
| 285 if (!m_resourceTimingReportTimer.isActive()) | 281 if (!m_resourceTimingReportTimer.isActive()) |
| 286 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); | 282 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 287 } | 283 } |
| 288 | 284 |
| 289 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { | 285 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { |
| 290 m_validatedURLs.clear(); | 286 m_validatedURLs.clear(); |
| 291 } | 287 } |
| 292 m_validatedURLs.add(request.resourceRequest().url()); | 288 m_validatedURLs.add(request.resourceRequest().url()); |
| 293 } | 289 } |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 { | 889 { |
| 894 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); | 890 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); |
| 895 // The ResourceLoader might be in |m_nonBlockingLoaders| for multipart respo
nses. | 891 // The ResourceLoader might be in |m_nonBlockingLoaders| for multipart respo
nses. |
| 896 ASSERT(!(m_loaders && m_loaders->contains(resource->loader()))); | 892 ASSERT(!(m_loaders && m_loaders->contains(resource->loader()))); |
| 897 | 893 |
| 898 if (resource && resource->response().isHTTP() && resource->response().httpSt
atusCode() < 400) { | 894 if (resource && resource->response().isHTTP() && resource->response().httpSt
atusCode() < 400) { |
| 899 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); | 895 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); |
| 900 if (it != m_resourceTimingInfoMap.end()) { | 896 if (it != m_resourceTimingInfoMap.end()) { |
| 901 OwnPtr<ResourceTimingInfo> info = it->value.release(); | 897 OwnPtr<ResourceTimingInfo> info = it->value.release(); |
| 902 m_resourceTimingInfoMap.remove(it); | 898 m_resourceTimingInfoMap.remove(it); |
| 903 populateResourceTiming(info.get(), resource, false); | 899 populateResourceTiming(info.get(), resource); |
| 900 info->setLoadFinishTime(finishTime); |
| 904 if (resource->options().requestInitiatorContext == DocumentContext) | 901 if (resource->options().requestInitiatorContext == DocumentContext) |
| 905 context().addResourceTiming(*info); | 902 context().addResourceTiming(*info); |
| 906 resource->reportResourceTimingToClients(*info); | 903 resource->reportResourceTimingToClients(*info); |
| 907 } | 904 } |
| 908 } | 905 } |
| 909 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); | 906 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); |
| 910 } | 907 } |
| 911 | 908 |
| 912 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr
or& error) | 909 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr
or& error) |
| 913 { | 910 { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 visitor->trace(m_context); | 1173 visitor->trace(m_context); |
| 1177 visitor->trace(m_archive); | 1174 visitor->trace(m_archive); |
| 1178 visitor->trace(m_loaders); | 1175 visitor->trace(m_loaders); |
| 1179 visitor->trace(m_nonBlockingLoaders); | 1176 visitor->trace(m_nonBlockingLoaders); |
| 1180 visitor->trace(m_documentResources); | 1177 visitor->trace(m_documentResources); |
| 1181 visitor->trace(m_preloads); | 1178 visitor->trace(m_preloads); |
| 1182 visitor->trace(m_resourceTimingInfoMap); | 1179 visitor->trace(m_resourceTimingInfoMap); |
| 1183 } | 1180 } |
| 1184 | 1181 |
| 1185 } // namespace blink | 1182 } // namespace blink |
| OLD | NEW |