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

Side by Side Diff: Source/core/loader/cache/CachedResourceLoader.cpp

Issue 16950017: Reland [Resource Timing] Expose redirect timing information (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebaseline Created 7 years, 5 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/loader/cache/CachedResourceRequest.h" 44 #include "core/loader/cache/CachedResourceRequest.h"
45 #include "core/loader/cache/CachedScript.h" 45 #include "core/loader/cache/CachedScript.h"
46 #include "core/loader/cache/CachedShader.h" 46 #include "core/loader/cache/CachedShader.h"
47 #include "core/loader/cache/CachedTextTrack.h" 47 #include "core/loader/cache/CachedTextTrack.h"
48 #include "core/loader/cache/CachedXSLStyleSheet.h" 48 #include "core/loader/cache/CachedXSLStyleSheet.h"
49 #include "core/loader/cache/MemoryCache.h" 49 #include "core/loader/cache/MemoryCache.h"
50 #include "core/page/ContentSecurityPolicy.h" 50 #include "core/page/ContentSecurityPolicy.h"
51 #include "core/page/DOMWindow.h" 51 #include "core/page/DOMWindow.h"
52 #include "core/page/Frame.h" 52 #include "core/page/Frame.h"
53 #include "core/page/Performance.h" 53 #include "core/page/Performance.h"
54 #include "core/page/ResourceTimingInfo.h"
54 #include "core/page/Settings.h" 55 #include "core/page/Settings.h"
55 #include "core/platform/Logging.h" 56 #include "core/platform/Logging.h"
56 #include "public/platform/Platform.h" 57 #include "public/platform/Platform.h"
57 #include "public/platform/WebURL.h" 58 #include "public/platform/WebURL.h"
58 #include "weborigin/SecurityOrigin.h" 59 #include "weborigin/SecurityOrigin.h"
59 #include "weborigin/SecurityPolicy.h" 60 #include "weborigin/SecurityPolicy.h"
60 #include "wtf/MemoryInstrumentationHashMap.h" 61 #include "wtf/MemoryInstrumentationHashMap.h"
61 #include "wtf/MemoryInstrumentationHashSet.h" 62 #include "wtf/MemoryInstrumentationHashSet.h"
62 #include "wtf/MemoryInstrumentationListHashSet.h" 63 #include "wtf/MemoryInstrumentationListHashSet.h"
63 #include "wtf/text/CString.h" 64 #include "wtf/text/CString.h"
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 memoryCache()->add(resource.get()); 702 memoryCache()->add(resource.get());
702 storeResourceTimingInitiatorInformation(resource, request); 703 storeResourceTimingInitiatorInformation(resource, request);
703 return resource; 704 return resource;
704 } 705 }
705 706
706 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) 707 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request)
707 { 708 {
708 if (request.options().requestInitiatorContext != DocumentContext) 709 if (request.options().requestInitiatorContext != DocumentContext)
709 return; 710 return;
710 711
711 CachedResourceInitiatorInfo info = request.options().initiatorInfo; 712 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.options ().initiatorInfo.name, monotonicallyIncreasingTime());
712 info.startTime = monotonicallyIncreasingTime();
713 713
714 if (resource->type() == CachedResource::MainResource) { 714 if (resource->type() == CachedResource::MainResource) {
715 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. 715 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations.
716 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) { 716 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) {
717 info.name = frame()->ownerElement()->localName(); 717 info->setInitiatorType(frame()->ownerElement()->localName());
718 m_initiatorMap.add(resource.get(), info); 718 m_resourceTimingInfoMap.add(resource.get(), info);
719 frame()->ownerElement()->didLoadNonEmptyDocument(); 719 frame()->ownerElement()->didLoadNonEmptyDocument();
720 } 720 }
721 } else { 721 } else {
722 m_initiatorMap.add(resource.get(), info); 722 m_resourceTimingInfoMap.add(resource.get(), info);
723 } 723 }
724 } 724 }
725 725
726 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st 726 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st
727 { 727 {
728 if (!existingResource) 728 if (!existingResource)
729 return Load; 729 return Load;
730 730
731 // We already have a preload going for this URL. 731 // We already have a preload going for this URL.
732 if (forPreload && existingResource->isPreloaded()) 732 if (forPreload && existingResource->isPreloaded())
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 return CachePolicyVerify; 889 return CachePolicyVerify;
890 890
891 if (type != CachedResource::MainResource) 891 if (type != CachedResource::MainResource)
892 return frame()->loader()->subresourceCachePolicy(); 892 return frame()->loader()->subresourceCachePolicy();
893 893
894 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload) 894 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload)
895 return CachePolicyReload; 895 return CachePolicyReload;
896 return CachePolicyVerify; 896 return CachePolicyVerify;
897 } 897 }
898 898
899 void CachedResourceLoader::redirectReceived(CachedResource* resource, const Reso urceResponse& redirectResponse)
900 {
901 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
902 if (it != m_resourceTimingInfoMap.end())
903 it->value->addRedirect(redirectResponse);
904 }
905
899 void CachedResourceLoader::loadDone(CachedResource* resource) 906 void CachedResourceLoader::loadDone(CachedResource* resource)
900 { 907 {
901 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); 908 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
902 RefPtr<Document> protectDocument(m_document); 909 RefPtr<Document> protectDocument(m_document);
903 910
904 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { 911 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
905 HashMap<CachedResource*, CachedResourceInitiatorInfo>::iterator initiato rIt = m_initiatorMap.find(resource); 912 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour ce);
906 if (initiatorIt != m_initiatorMap.end()) { 913 if (it != m_resourceTimingInfoMap.end()) {
907 ASSERT(document()); 914 ASSERT(document());
908 Document* initiatorDocument = document(); 915 Document* initiatorDocument = document();
909 if (resource->type() == CachedResource::MainResource) 916 if (resource->type() == CachedResource::MainResource)
910 initiatorDocument = document()->parentDocument(); 917 initiatorDocument = document()->parentDocument();
911 ASSERT(initiatorDocument); 918 ASSERT(initiatorDocument);
912 const CachedResourceInitiatorInfo& info = initiatorIt->value; 919 RefPtr<ResourceTimingInfo> info = it->value;
913 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); 920 info->setInitialRequest(resource->resourceRequest());
914 m_initiatorMap.remove(initiatorIt); 921 info->setFinalResponse(resource->response());
922 info->setLoadFinishTime(resource->loadFinishTime());
923 initiatorDocument->domWindow()->performance()->addResourceTiming(*in fo, initiatorDocument);
924 m_resourceTimingInfoMap.remove(it);
915 } 925 }
916 } 926 }
917 927
918 if (frame()) 928 if (frame())
919 frame()->loader()->loadDone(); 929 frame()->loader()->loadDone();
920 performPostLoadActions(); 930 performPostLoadActions();
921 931
922 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 932 if (!m_garbageCollectDocumentResourcesTimer.isActive())
923 m_garbageCollectDocumentResourcesTimer.startOneShot(0); 933 m_garbageCollectDocumentResourcesTimer.startOneShot(0);
924 } 934 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); 1151 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer");
1142 } 1152 }
1143 1153
1144 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) 1154 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( )
1145 { 1155 {
1146 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy, UseDefaul tOriginRestrictionsForType, DocumentContext)); 1156 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy, UseDefaul tOriginRestrictionsForType, DocumentContext));
1147 return options; 1157 return options;
1148 } 1158 }
1149 1159
1150 } 1160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698