Chromium Code Reviews| 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 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1145 } | 1145 } |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons e& redirectResponse) | 1148 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons e& redirectResponse) |
| 1149 { | 1149 { |
| 1150 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); | 1150 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); |
| 1151 if (it != m_resourceTimingInfoMap.end()) | 1151 if (it != m_resourceTimingInfoMap.end()) |
| 1152 it->value->addRedirect(redirectResponse); | 1152 it->value->addRedirect(redirectResponse); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 void ResourceFetcher::didLoadResource(Resource* resource) | 1155 void ResourceFetcher::didLoadResource(Resource* resource) |
|
dcheng
2014/10/20 19:28:04
This can be const now, right?
Nate Chapin
2014/10/21 22:00:09
We can actually drop the Resource* parameter entir
| |
| 1156 { | 1156 { |
| 1157 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); | 1157 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); |
| 1158 RefPtrWillBeRawPtr<Document> protectDocument(m_document.get()); | 1158 RefPtrWillBeRawPtr<Document> protectDocument(m_document.get()); |
| 1159 | 1159 |
| 1160 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304) && document()) { | |
| 1161 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour ce); | |
| 1162 if (it != m_resourceTimingInfoMap.end()) { | |
| 1163 RefPtr<ResourceTimingInfo> info = it->value; | |
| 1164 m_resourceTimingInfoMap.remove(it); | |
| 1165 populateResourceTiming(info.get(), resource, false); | |
| 1166 reportResourceTiming(info.get(), document(), resource->type() == Res ource::MainResource); | |
| 1167 } | |
| 1168 } | |
| 1169 | |
| 1170 if (frame()) | 1160 if (frame()) |
| 1171 frame()->loader().loadDone(); | 1161 frame()->loader().loadDone(); |
| 1172 scheduleDocumentResourcesGC(); | 1162 scheduleDocumentResourcesGC(); |
| 1173 } | 1163 } |
| 1174 | 1164 |
| 1175 void ResourceFetcher::scheduleDocumentResourcesGC() | 1165 void ResourceFetcher::scheduleDocumentResourcesGC() |
| 1176 { | 1166 { |
| 1177 if (!m_garbageCollectDocumentResourcesTimer.isActive()) | 1167 if (!m_garbageCollectDocumentResourcesTimer.isActive()) |
| 1178 m_garbageCollectDocumentResourcesTimer.startOneShot(0, FROM_HERE); | 1168 m_garbageCollectDocumentResourcesTimer.startOneShot(0, FROM_HERE); |
| 1179 } | 1169 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1300 for (ListHashSet<Resource*>::iterator it = m_preloads->begin(); it != end; + +it) { | 1290 for (ListHashSet<Resource*>::iterator it = m_preloads->begin(); it != end; + +it) { |
| 1301 Resource* res = *it; | 1291 Resource* res = *it; |
| 1302 res->decreasePreloadCount(); | 1292 res->decreasePreloadCount(); |
| 1303 bool deleted = res->deleteIfPossible(); | 1293 bool deleted = res->deleteIfPossible(); |
| 1304 if (!deleted && res->preloadResult() == Resource::PreloadNotReferenced) | 1294 if (!deleted && res->preloadResult() == Resource::PreloadNotReferenced) |
| 1305 memoryCache()->remove(res); | 1295 memoryCache()->remove(res); |
| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1553 | 1553 |
| 1554 void ResourceFetcher::trace(Visitor* visitor) | 1554 void ResourceFetcher::trace(Visitor* visitor) |
| 1555 { | 1555 { |
| 1556 visitor->trace(m_document); | 1556 visitor->trace(m_document); |
| 1557 visitor->trace(m_loaders); | 1557 visitor->trace(m_loaders); |
| 1558 visitor->trace(m_multipartLoaders); | 1558 visitor->trace(m_multipartLoaders); |
| 1559 ResourceLoaderHost::trace(visitor); | 1559 ResourceLoaderHost::trace(visitor); |
| 1560 } | 1560 } |
| 1561 | 1561 |
| 1562 } | 1562 } |
| OLD | NEW |