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

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

Issue 1955243002: Trim ResourceTimingInfoMap of non-relevant entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove resources that fail to load also Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 resource->setCacheIdentifier(cacheIdentifier); 574 resource->setCacheIdentifier(cacheIdentifier);
575 575
576 // Don't add main resource to cache to prevent reuse. 576 // Don't add main resource to cache to prevent reuse.
577 if (factory.type() != Resource::MainResource) 577 if (factory.type() != Resource::MainResource)
578 memoryCache()->add(resource); 578 memoryCache()->add(resource);
579 return resource; 579 return resource;
580 } 580 }
581 581
582 void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource ) 582 void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource )
583 { 583 {
584 if (resource->options().initiatorInfo.name == FetchInitiatorTypeNames::inter nal) 584 const AtomicString& fetchInitiator = resource->options().initiatorInfo.name;
585 if (fetchInitiator == FetchInitiatorTypeNames::internal)
585 return; 586 return;
586 587
587 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(resource->optio ns().initiatorInfo.name, monotonicallyIncreasingTime(), resource->getType() == R esource::MainResource); 588 bool isMainResource = resource->getType() == Resource::MainResource;
589 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(fetchInitiator, monotonicallyIncreasingTime(), isMainResource);
588 590
589 if (resource->isCacheValidator()) { 591 if (resource->isCacheValidator()) {
590 const AtomicString& timingAllowOrigin = resource->response().httpHeaderF ield(HTTPNames::Timing_Allow_Origin); 592 const AtomicString& timingAllowOrigin = resource->response().httpHeaderF ield(HTTPNames::Timing_Allow_Origin);
591 if (!timingAllowOrigin.isEmpty()) 593 if (!timingAllowOrigin.isEmpty())
592 info->setOriginalTimingAllowOrigin(timingAllowOrigin); 594 info->setOriginalTimingAllowOrigin(timingAllowOrigin);
593 } 595 }
594 596
595 if (resource->getType() != Resource::MainResource || context().updateTimingI nfoForIFrameNavigation(info.get())) 597 if (!isMainResource || context().updateTimingInfoForIFrameNavigation(info.ge t()))
596 m_resourceTimingInfoMap.add(resource, info.release()); 598 m_resourceTimingInfoMap.add(resource, info.release());
597 } 599 }
598 600
599 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy (Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour ce, bool isStaticData) const 601 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy (Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour ce, bool isStaticData) const
600 { 602 {
601 const ResourceRequest& request = fetchRequest.resourceRequest(); 603 const ResourceRequest& request = fetchRequest.resourceRequest();
602 604
603 if (!existingResource) 605 if (!existingResource)
604 return Load; 606 return Load;
605 607
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 if (!context().isMainFrame()) 884 if (!context().isMainFrame())
883 return nullptr; 885 return nullptr;
884 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer() ); 886 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer() );
885 return m_archive ? m_archive->mainResource() : nullptr; 887 return m_archive ? m_archive->mainResource() : nullptr;
886 } 888 }
887 889
888 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in t64_t encodedDataLength) 890 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in t64_t encodedDataLength)
889 { 891 {
890 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); 892 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource);
891 // The ResourceLoader might be in |m_nonBlockingLoaders| for multipart respo nses. 893 // The ResourceLoader might be in |m_nonBlockingLoaders| for multipart respo nses.
894 ASSERT(resource);
892 ASSERT(!(m_loaders && m_loaders->contains(resource->loader()))); 895 ASSERT(!(m_loaders && m_loaders->contains(resource->loader())));
893 896
894 if (resource && resource->response().isHTTP() && resource->response().httpSt atusCode() < 400) { 897 if (OwnPtr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take(resource) ) {
895 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour ce); 898 if (resource->response().isHTTP() && resource->response().httpStatusCode () < 400) {
896 if (it != m_resourceTimingInfoMap.end()) {
897 OwnPtr<ResourceTimingInfo> info = it->value.release();
898 m_resourceTimingInfoMap.remove(it);
899 populateResourceTiming(info.get(), resource); 899 populateResourceTiming(info.get(), resource);
900 info->setLoadFinishTime(finishTime); 900 info->setLoadFinishTime(finishTime);
901 if (resource->options().requestInitiatorContext == DocumentContext) 901 if (resource->options().requestInitiatorContext == DocumentContext)
902 context().addResourceTiming(*info); 902 context().addResourceTiming(*info);
903 resource->reportResourceTimingToClients(*info); 903 resource->reportResourceTimingToClients(*info);
904 } 904 }
905 } 905 }
906 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod edDataLength); 906 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod edDataLength);
907 } 907 }
908 908
909 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr or& error) 909 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr or& error)
910 { 910 {
911 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); 911 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource);
912 removeResourceLoader(resource->loader()); 912 removeResourceLoader(resource->loader());
913 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource));
913 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit iatorTypeNames::internal; 914 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit iatorTypeNames::internal;
914 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); 915 context().dispatchDidFail(resource->identifier(), error, isInternalRequest);
915 } 916 }
916 917
917 void ResourceFetcher::didReceiveResponse(const Resource* resource, const Resourc eResponse& response) 918 void ResourceFetcher::didReceiveResponse(const Resource* resource, const Resourc eResponse& response)
918 { 919 {
919 // If the response is fetched via ServiceWorker, the original URL of the res ponse could be different from the URL of the request. 920 // If the response is fetched via ServiceWorker, the original URL of the res ponse could be different from the URL of the request.
920 // We check the URL not to load the resources which are forbidden by the pag e CSP. 921 // We check the URL not to load the resources which are forbidden by the pag e CSP.
921 // https://w3c.github.io/webappsec-csp/#should-block-response 922 // https://w3c.github.io/webappsec-csp/#should-block-response
922 if (response.wasFetchedViaServiceWorker()) { 923 if (response.wasFetchedViaServiceWorker()) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 visitor->trace(m_context); 1174 visitor->trace(m_context);
1174 visitor->trace(m_archive); 1175 visitor->trace(m_archive);
1175 visitor->trace(m_loaders); 1176 visitor->trace(m_loaders);
1176 visitor->trace(m_nonBlockingLoaders); 1177 visitor->trace(m_nonBlockingLoaders);
1177 visitor->trace(m_documentResources); 1178 visitor->trace(m_documentResources);
1178 visitor->trace(m_preloads); 1179 visitor->trace(m_preloads);
1179 visitor->trace(m_resourceTimingInfoMap); 1180 visitor->trace(m_resourceTimingInfoMap);
1180 } 1181 }
1181 1182
1182 } // namespace blink 1183 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698