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

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

Issue 13912021: [Resource Timing] Expose redirect timing information (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaseline Created 7 years, 6 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "core/loader/cache/CachedScript.h" 51 #include "core/loader/cache/CachedScript.h"
52 #include "core/loader/cache/CachedShader.h" 52 #include "core/loader/cache/CachedShader.h"
53 #include "core/loader/cache/CachedTextTrack.h" 53 #include "core/loader/cache/CachedTextTrack.h"
54 #include "core/loader/cache/CachedXSLStyleSheet.h" 54 #include "core/loader/cache/CachedXSLStyleSheet.h"
55 #include "core/loader/cache/MemoryCache.h" 55 #include "core/loader/cache/MemoryCache.h"
56 #include "core/page/Console.h" 56 #include "core/page/Console.h"
57 #include "core/page/ContentSecurityPolicy.h" 57 #include "core/page/ContentSecurityPolicy.h"
58 #include "core/page/DOMWindow.h" 58 #include "core/page/DOMWindow.h"
59 #include "core/page/Frame.h" 59 #include "core/page/Frame.h"
60 #include "core/page/Performance.h" 60 #include "core/page/Performance.h"
61 #include "core/page/ResourceTimingInfo.h"
61 #include "core/page/Settings.h" 62 #include "core/page/Settings.h"
62 #include "core/platform/Logging.h" 63 #include "core/platform/Logging.h"
63 #include "public/platform/Platform.h" 64 #include "public/platform/Platform.h"
64 #include "public/platform/WebURL.h" 65 #include "public/platform/WebURL.h"
65 #include "weborigin/SecurityOrigin.h" 66 #include "weborigin/SecurityOrigin.h"
66 #include "weborigin/SecurityPolicy.h" 67 #include "weborigin/SecurityPolicy.h"
67 68
68 #define PRELOAD_DEBUG 0 69 #define PRELOAD_DEBUG 0
69 70
70 namespace WebCore { 71 namespace WebCore {
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 addAdditionalRequestHeaders(request.mutableResourceRequest(), type); 669 addAdditionalRequestHeaders(request.mutableResourceRequest(), type);
669 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset); 670 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset);
670 671
671 memoryCache()->add(resource.get()); 672 memoryCache()->add(resource.get());
672 storeResourceTimingInitiatorInformation(resource, request); 673 storeResourceTimingInitiatorInformation(resource, request);
673 return resource; 674 return resource;
674 } 675 }
675 676
676 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) 677 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request)
677 { 678 {
678 CachedResourceInitiatorInfo info = request.options().initiatorInfo; 679 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.options ().initiatorInfo.name, monotonicallyIncreasingTime());
679 info.startTime = monotonicallyIncreasingTime();
680 680
681 if (resource->type() == CachedResource::MainResource) { 681 if (resource->type() == CachedResource::MainResource) {
682 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. 682 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations.
683 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) { 683 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) {
684 info.name = frame()->ownerElement()->localName(); 684 info->setInitiatorType(frame()->ownerElement()->localName());
685 m_initiatorMap.add(resource.get(), info); 685 m_resourceTimingInfoMap.add(resource.get(), info);
686 frame()->ownerElement()->didLoadNonEmptyDocument(); 686 frame()->ownerElement()->didLoadNonEmptyDocument();
687 } 687 }
688 } else { 688 } else {
689 m_initiatorMap.add(resource.get(), info); 689 m_resourceTimingInfoMap.add(resource.get(), info);
690 } 690 }
691 } 691 }
692 692
693 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st 693 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st
694 { 694 {
695 if (!existingResource) 695 if (!existingResource)
696 return Load; 696 return Load;
697 697
698 // We already have a preload going for this URL. 698 // We already have a preload going for this URL.
699 if (forPreload && existingResource->isPreloaded()) 699 if (forPreload && existingResource->isPreloaded())
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 return CachePolicyVerify; 851 return CachePolicyVerify;
852 852
853 if (type != CachedResource::MainResource) 853 if (type != CachedResource::MainResource)
854 return frame()->loader()->subresourceCachePolicy(); 854 return frame()->loader()->subresourceCachePolicy();
855 855
856 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload) 856 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload)
857 return CachePolicyReload; 857 return CachePolicyReload;
858 return CachePolicyVerify; 858 return CachePolicyVerify;
859 } 859 }
860 860
861 void CachedResourceLoader::redirectReceived(CachedResource* resource, const Reso urceResponse& redirectResponse)
862 {
863 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
864 if (it != m_resourceTimingInfoMap.end())
865 it->value->addRedirect(redirectResponse);
866 }
867
861 void CachedResourceLoader::loadDone(CachedResource* resource) 868 void CachedResourceLoader::loadDone(CachedResource* resource)
862 { 869 {
863 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); 870 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
864 RefPtr<Document> protectDocument(m_document); 871 RefPtr<Document> protectDocument(m_document);
865 872
866 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { 873 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
867 HashMap<CachedResource*, CachedResourceInitiatorInfo>::iterator initiato rIt = m_initiatorMap.find(resource); 874 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour ce);
868 if (initiatorIt != m_initiatorMap.end()) { 875 if (it != m_resourceTimingInfoMap.end()) {
869 ASSERT(document()); 876 ASSERT(document());
870 Document* initiatorDocument = document(); 877 Document* initiatorDocument = document();
871 if (resource->type() == CachedResource::MainResource) 878 if (resource->type() == CachedResource::MainResource)
872 initiatorDocument = document()->parentDocument(); 879 initiatorDocument = document()->parentDocument();
873 ASSERT(initiatorDocument); 880 ASSERT(initiatorDocument);
874 const CachedResourceInitiatorInfo& info = initiatorIt->value; 881 RefPtr<ResourceTimingInfo> info = it->value;
875 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); 882 info->setInitialRequest(resource->resourceRequest());
876 m_initiatorMap.remove(initiatorIt); 883 info->setFinalResponse(resource->response());
884 info->setLoadFinishTime(resource->loadFinishTime());
885 initiatorDocument->domWindow()->performance()->addResourceTiming(*in fo, initiatorDocument);
886 m_resourceTimingInfoMap.remove(it);
877 } 887 }
878 } 888 }
879 889
880 if (frame()) 890 if (frame())
881 frame()->loader()->loadDone(); 891 frame()->loader()->loadDone();
882 performPostLoadActions(); 892 performPostLoadActions();
883 893
884 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 894 if (!m_garbageCollectDocumentResourcesTimer.isActive())
885 m_garbageCollectDocumentResourcesTimer.startOneShot(0); 895 m_garbageCollectDocumentResourcesTimer.startOneShot(0);
886 } 896 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); 1113 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer");
1104 } 1114 }
1105 1115
1106 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) 1116 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( )
1107 { 1117 {
1108 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy)); 1118 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy));
1109 return options; 1119 return options;
1110 } 1120 }
1111 1121
1112 } 1122 }
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