Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 561813003: Prepare blink to unify definitions of load completion (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add document.close() to scroll-left-while-loading.html Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | Source/core/fetch/ResourceLoader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 } 1140 }
1141 } 1141 }
1142 1142
1143 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons e& redirectResponse) 1143 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons e& redirectResponse)
1144 { 1144 {
1145 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); 1145 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
1146 if (it != m_resourceTimingInfoMap.end()) 1146 if (it != m_resourceTimingInfoMap.end())
1147 it->value->addRedirect(redirectResponse); 1147 it->value->addRedirect(redirectResponse);
1148 } 1148 }
1149 1149
1150 void ResourceFetcher::didLoadResource(Resource* resource) 1150 void ResourceFetcher::didLoadResource()
1151 { 1151 {
1152 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); 1152 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
1153 RefPtrWillBeRawPtr<Document> protectDocument(m_document.get()); 1153 RefPtrWillBeRawPtr<Document> protectDocument(m_document.get());
1154 1154
1155 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304) && document()) {
1156 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour ce);
1157 if (it != m_resourceTimingInfoMap.end()) {
1158 RefPtr<ResourceTimingInfo> info = it->value;
1159 m_resourceTimingInfoMap.remove(it);
1160 populateResourceTiming(info.get(), resource, false);
1161 reportResourceTiming(info.get(), document(), resource->type() == Res ource::MainResource);
1162 }
1163 }
1164
1165 if (frame()) 1155 if (frame())
1166 frame()->loader().loadDone(); 1156 frame()->loader().loadDone();
1167 scheduleDocumentResourcesGC(); 1157 scheduleDocumentResourcesGC();
1168 } 1158 }
1169 1159
1170 void ResourceFetcher::scheduleDocumentResourcesGC() 1160 void ResourceFetcher::scheduleDocumentResourcesGC()
1171 { 1161 {
1172 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 1162 if (!m_garbageCollectDocumentResourcesTimer.isActive())
1173 m_garbageCollectDocumentResourcesTimer.startOneShot(0, FROM_HERE); 1163 m_garbageCollectDocumentResourcesTimer.startOneShot(0, FROM_HERE);
1174 } 1164 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 1281
1292 for (Resource* resource : *m_preloads) { 1282 for (Resource* resource : *m_preloads) {
1293 resource->decreasePreloadCount(); 1283 resource->decreasePreloadCount();
1294 bool deleted = resource->deleteIfPossible(); 1284 bool deleted = resource->deleteIfPossible();
1295 if (!deleted && resource->preloadResult() == Resource::PreloadNotReferen ced) 1285 if (!deleted && resource->preloadResult() == Resource::PreloadNotReferen ced)
1296 memoryCache()->remove(resource); 1286 memoryCache()->remove(resource);
1297 } 1287 }
1298 m_preloads.clear(); 1288 m_preloads.clear();
1299 } 1289 }
1300 1290
1301 void ResourceFetcher::didFinishLoading(const Resource* resource, double finishTi me, int64_t encodedDataLength) 1291 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in t64_t encodedDataLength)
1302 { 1292 {
1303 TRACE_EVENT_ASYNC_END0("net", "Resource", resource); 1293 TRACE_EVENT_ASYNC_END0("net", "Resource", resource);
1294
1295 if (resource && resource->response().isHTTP() && resource->response().httpSt atusCode() < 400 && document()) {
1296 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour ce);
1297 if (it != m_resourceTimingInfoMap.end()) {
1298 RefPtr<ResourceTimingInfo> info = it->value;
1299 m_resourceTimingInfoMap.remove(it);
1300 populateResourceTiming(info.get(), resource, false);
1301 reportResourceTiming(info.get(), document(), resource->type() == Res ource::MainResource);
1302 }
1303 }
1304 context().dispatchDidFinishLoading(m_documentLoader, resource->identifier(), finishTime, encodedDataLength); 1304 context().dispatchDidFinishLoading(m_documentLoader, resource->identifier(), finishTime, encodedDataLength);
1305 } 1305 }
1306 1306
1307 void ResourceFetcher::didChangeLoadingPriority(const Resource* resource, Resourc eLoadPriority loadPriority, int intraPriorityValue) 1307 void ResourceFetcher::didChangeLoadingPriority(const Resource* resource, Resourc eLoadPriority loadPriority, int intraPriorityValue)
1308 { 1308 {
1309 TRACE_EVENT_ASYNC_STEP_INTO1("net", "Resource", resource, "ChangePriority", "priority", loadPriority); 1309 TRACE_EVENT_ASYNC_STEP_INTO1("net", "Resource", resource, "ChangePriority", "priority", loadPriority);
1310 context().dispatchDidChangeResourcePriority(resource->identifier(), loadPrio rity, intraPriorityValue); 1310 context().dispatchDidChangeResourcePriority(resource->identifier(), loadPrio rity, intraPriorityValue);
1311 } 1311 }
1312 1312
1313 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr or& error) 1313 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr or& error)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 1544
1545 void ResourceFetcher::trace(Visitor* visitor) 1545 void ResourceFetcher::trace(Visitor* visitor)
1546 { 1546 {
1547 visitor->trace(m_document); 1547 visitor->trace(m_document);
1548 visitor->trace(m_loaders); 1548 visitor->trace(m_loaders);
1549 visitor->trace(m_multipartLoaders); 1549 visitor->trace(m_multipartLoaders);
1550 ResourceLoaderHost::trace(visitor); 1550 ResourceLoaderHost::trace(visitor);
1551 } 1551 }
1552 1552
1553 } 1553 }
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | Source/core/fetch/ResourceLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698