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 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 } | 1149 } |
1150 } | 1150 } |
1151 | 1151 |
1152 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons
e& redirectResponse) | 1152 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons
e& redirectResponse) |
1153 { | 1153 { |
1154 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); | 1154 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); |
1155 if (it != m_resourceTimingInfoMap.end()) | 1155 if (it != m_resourceTimingInfoMap.end()) |
1156 it->value->addRedirect(redirectResponse); | 1156 it->value->addRedirect(redirectResponse); |
1157 } | 1157 } |
1158 | 1158 |
1159 void ResourceFetcher::didLoadResource(Resource* resource) | 1159 void ResourceFetcher::didLoadResource() |
1160 { | 1160 { |
1161 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); | 1161 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); |
1162 RefPtrWillBeRawPtr<Document> protectDocument(m_document.get()); | 1162 RefPtrWillBeRawPtr<Document> protectDocument(m_document.get()); |
1163 | 1163 |
1164 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred(
) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)
&& document()) { | |
1165 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); | |
1166 if (it != m_resourceTimingInfoMap.end()) { | |
1167 RefPtr<ResourceTimingInfo> info = it->value; | |
1168 m_resourceTimingInfoMap.remove(it); | |
1169 populateResourceTiming(info.get(), resource, false); | |
1170 reportResourceTiming(info.get(), document(), resource->type() == Res
ource::MainResource); | |
1171 } | |
1172 } | |
1173 | |
1174 if (frame()) | 1164 if (frame()) |
1175 frame()->loader().loadDone(); | 1165 frame()->loader().loadDone(); |
1176 scheduleDocumentResourcesGC(); | 1166 scheduleDocumentResourcesGC(); |
1177 } | 1167 } |
1178 | 1168 |
1179 void ResourceFetcher::scheduleDocumentResourcesGC() | 1169 void ResourceFetcher::scheduleDocumentResourcesGC() |
1180 { | 1170 { |
1181 if (!m_garbageCollectDocumentResourcesTimer.isActive()) | 1171 if (!m_garbageCollectDocumentResourcesTimer.isActive()) |
1182 m_garbageCollectDocumentResourcesTimer.startOneShot(0, FROM_HERE); | 1172 m_garbageCollectDocumentResourcesTimer.startOneShot(0, FROM_HERE); |
1183 } | 1173 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 | 1290 |
1301 for (Resource* resource : *m_preloads) { | 1291 for (Resource* resource : *m_preloads) { |
1302 resource->decreasePreloadCount(); | 1292 resource->decreasePreloadCount(); |
1303 bool deleted = resource->deleteIfPossible(); | 1293 bool deleted = resource->deleteIfPossible(); |
1304 if (!deleted && resource->preloadResult() == Resource::PreloadNotReferen
ced) | 1294 if (!deleted && resource->preloadResult() == Resource::PreloadNotReferen
ced) |
1305 memoryCache()->remove(resource); | 1295 memoryCache()->remove(resource); |
1306 } | 1296 } |
1307 m_preloads.clear(); | 1297 m_preloads.clear(); |
1308 } | 1298 } |
1309 | 1299 |
1310 void ResourceFetcher::didFinishLoading(const Resource* resource, double finishTi
me, int64_t encodedDataLength) | 1300 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength) |
1311 { | 1301 { |
1312 TRACE_EVENT_ASYNC_END0("net", "Resource", resource); | 1302 TRACE_EVENT_ASYNC_END0("net", "Resource", resource); |
| 1303 |
| 1304 if (resource && resource->response().isHTTP() && resource->response().httpSt
atusCode() < 400 && document()) { |
| 1305 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); |
| 1306 if (it != m_resourceTimingInfoMap.end()) { |
| 1307 RefPtr<ResourceTimingInfo> info = it->value; |
| 1308 m_resourceTimingInfoMap.remove(it); |
| 1309 populateResourceTiming(info.get(), resource, false); |
| 1310 reportResourceTiming(info.get(), document(), resource->type() == Res
ource::MainResource); |
| 1311 } |
| 1312 } |
1313 context().dispatchDidFinishLoading(m_documentLoader, resource->identifier(),
finishTime, encodedDataLength); | 1313 context().dispatchDidFinishLoading(m_documentLoader, resource->identifier(),
finishTime, encodedDataLength); |
1314 } | 1314 } |
1315 | 1315 |
1316 void ResourceFetcher::didChangeLoadingPriority(const Resource* resource, Resourc
eLoadPriority loadPriority, int intraPriorityValue) | 1316 void ResourceFetcher::didChangeLoadingPriority(const Resource* resource, Resourc
eLoadPriority loadPriority, int intraPriorityValue) |
1317 { | 1317 { |
1318 TRACE_EVENT_ASYNC_STEP_INTO1("net", "Resource", resource, "ChangePriority",
"priority", loadPriority); | 1318 TRACE_EVENT_ASYNC_STEP_INTO1("net", "Resource", resource, "ChangePriority",
"priority", loadPriority); |
1319 context().dispatchDidChangeResourcePriority(resource->identifier(), loadPrio
rity, intraPriorityValue); | 1319 context().dispatchDidChangeResourcePriority(resource->identifier(), loadPrio
rity, intraPriorityValue); |
1320 } | 1320 } |
1321 | 1321 |
1322 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr
or& error) | 1322 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr
or& error) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 | 1560 |
1561 void ResourceFetcher::trace(Visitor* visitor) | 1561 void ResourceFetcher::trace(Visitor* visitor) |
1562 { | 1562 { |
1563 visitor->trace(m_document); | 1563 visitor->trace(m_document); |
1564 visitor->trace(m_loaders); | 1564 visitor->trace(m_loaders); |
1565 visitor->trace(m_multipartLoaders); | 1565 visitor->trace(m_multipartLoaders); |
1566 ResourceLoaderHost::trace(visitor); | 1566 ResourceLoaderHost::trace(visitor); |
1567 } | 1567 } |
1568 | 1568 |
1569 } | 1569 } |
OLD | NEW |