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

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: rebase 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
« no previous file with comments | « Source/core/loader/cache/CachedResourceLoader.h ('k') | Source/core/page/Performance.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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "core/loader/cache/CachedResourceRequest.h" 46 #include "core/loader/cache/CachedResourceRequest.h"
47 #include "core/loader/cache/CachedScript.h" 47 #include "core/loader/cache/CachedScript.h"
48 #include "core/loader/cache/CachedShader.h" 48 #include "core/loader/cache/CachedShader.h"
49 #include "core/loader/cache/CachedTextTrack.h" 49 #include "core/loader/cache/CachedTextTrack.h"
50 #include "core/loader/cache/CachedXSLStyleSheet.h" 50 #include "core/loader/cache/CachedXSLStyleSheet.h"
51 #include "core/loader/cache/MemoryCache.h" 51 #include "core/loader/cache/MemoryCache.h"
52 #include "core/page/ContentSecurityPolicy.h" 52 #include "core/page/ContentSecurityPolicy.h"
53 #include "core/page/DOMWindow.h" 53 #include "core/page/DOMWindow.h"
54 #include "core/page/Frame.h" 54 #include "core/page/Frame.h"
55 #include "core/page/Performance.h" 55 #include "core/page/Performance.h"
56 #include "core/page/ResourceTimingInfo.h"
56 #include "core/page/Settings.h" 57 #include "core/page/Settings.h"
57 #include "core/platform/Logging.h" 58 #include "core/platform/Logging.h"
58 #include "public/platform/Platform.h" 59 #include "public/platform/Platform.h"
59 #include "public/platform/WebURL.h" 60 #include "public/platform/WebURL.h"
60 #include "weborigin/SecurityOrigin.h" 61 #include "weborigin/SecurityOrigin.h"
61 #include "weborigin/SecurityPolicy.h" 62 #include "weborigin/SecurityPolicy.h"
62 #include "wtf/text/CString.h" 63 #include "wtf/text/CString.h"
63 #include "wtf/text/WTFString.h" 64 #include "wtf/text/WTFString.h"
64 65
65 #define PRELOAD_DEBUG 0 66 #define PRELOAD_DEBUG 0
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 memoryCache()->add(resource.get()); 701 memoryCache()->add(resource.get());
701 storeResourceTimingInitiatorInformation(resource, request); 702 storeResourceTimingInitiatorInformation(resource, request);
702 return resource; 703 return resource;
703 } 704 }
704 705
705 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) 706 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request)
706 { 707 {
707 if (request.options().requestInitiatorContext != DocumentContext) 708 if (request.options().requestInitiatorContext != DocumentContext)
708 return; 709 return;
709 710
710 CachedResourceInitiatorInfo info = request.options().initiatorInfo; 711 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.options ().initiatorInfo.name, monotonicallyIncreasingTime());
711 info.startTime = monotonicallyIncreasingTime();
712 712
713 if (resource->type() == CachedResource::MainResource) { 713 if (resource->type() == CachedResource::MainResource) {
714 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. 714 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations.
715 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) { 715 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) {
716 info.name = frame()->ownerElement()->localName(); 716 info->setInitiatorType(frame()->ownerElement()->localName());
717 m_initiatorMap.add(resource.get(), info); 717 m_resourceTimingInfoMap.add(resource.get(), info);
718 frame()->ownerElement()->didLoadNonEmptyDocument(); 718 frame()->ownerElement()->didLoadNonEmptyDocument();
719 } 719 }
720 } else { 720 } else {
721 m_initiatorMap.add(resource.get(), info); 721 m_resourceTimingInfoMap.add(resource.get(), info);
722 } 722 }
723 } 723 }
724 724
725 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st 725 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st
726 { 726 {
727 if (!existingResource) 727 if (!existingResource)
728 return Load; 728 return Load;
729 729
730 // We already have a preload going for this URL. 730 // We already have a preload going for this URL.
731 if (forPreload && existingResource->isPreloaded()) 731 if (forPreload && existingResource->isPreloaded())
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 return CachePolicyVerify; 888 return CachePolicyVerify;
889 889
890 if (type != CachedResource::MainResource) 890 if (type != CachedResource::MainResource)
891 return frame()->loader()->subresourceCachePolicy(); 891 return frame()->loader()->subresourceCachePolicy();
892 892
893 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload) 893 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload)
894 return CachePolicyReload; 894 return CachePolicyReload;
895 return CachePolicyVerify; 895 return CachePolicyVerify;
896 } 896 }
897 897
898 void CachedResourceLoader::redirectReceived(CachedResource* resource, const Reso urceResponse& redirectResponse)
899 {
900 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
901 if (it != m_resourceTimingInfoMap.end())
902 it->value->addRedirect(redirectResponse);
903 }
904
898 void CachedResourceLoader::didLoadResource(CachedResource* resource) 905 void CachedResourceLoader::didLoadResource(CachedResource* resource)
899 { 906 {
900 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); 907 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
901 RefPtr<Document> protectDocument(m_document); 908 RefPtr<Document> protectDocument(m_document);
902 909
903 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { 910 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
904 HashMap<CachedResource*, CachedResourceInitiatorInfo>::iterator initiato rIt = m_initiatorMap.find(resource); 911 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour ce);
905 if (initiatorIt != m_initiatorMap.end()) { 912 if (it != m_resourceTimingInfoMap.end()) {
906 ASSERT(document()); 913 ASSERT(document());
907 Document* initiatorDocument = document(); 914 Document* initiatorDocument = document();
908 if (resource->type() == CachedResource::MainResource) 915 if (resource->type() == CachedResource::MainResource)
909 initiatorDocument = document()->parentDocument(); 916 initiatorDocument = document()->parentDocument();
910 ASSERT(initiatorDocument); 917 ASSERT(initiatorDocument);
911 const CachedResourceInitiatorInfo& info = initiatorIt->value; 918 RefPtr<ResourceTimingInfo> info = it->value;
912 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); 919 info->setInitialRequest(resource->resourceRequest());
913 m_initiatorMap.remove(initiatorIt); 920 info->setFinalResponse(resource->response());
921 info->setLoadFinishTime(resource->loadFinishTime());
922 initiatorDocument->domWindow()->performance()->addResourceTiming(*in fo, initiatorDocument);
923 m_resourceTimingInfoMap.remove(it);
914 } 924 }
915 } 925 }
916 926
917 if (frame()) 927 if (frame())
918 frame()->loader()->loadDone(); 928 frame()->loader()->loadDone();
919 performPostLoadActions(); 929 performPostLoadActions();
920 930
921 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 931 if (!m_garbageCollectDocumentResourcesTimer.isActive())
922 m_garbageCollectDocumentResourcesTimer.startOneShot(0); 932 m_garbageCollectDocumentResourcesTimer.startOneShot(0);
923 } 933 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1252 }
1243 #endif 1253 #endif
1244 1254
1245 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) 1255 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( )
1246 { 1256 {
1247 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy, UseDefaul tOriginRestrictionsForType, DocumentContext)); 1257 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy, UseDefaul tOriginRestrictionsForType, DocumentContext));
1248 return options; 1258 return options;
1249 } 1259 }
1250 1260
1251 } 1261 }
OLDNEW
« no previous file with comments | « Source/core/loader/cache/CachedResourceLoader.h ('k') | Source/core/page/Performance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698