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

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: 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
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/loader/cache/CachedResourceRequest.h" 49 #include "core/loader/cache/CachedResourceRequest.h"
50 #include "core/loader/cache/CachedScript.h" 50 #include "core/loader/cache/CachedScript.h"
51 #include "core/loader/cache/CachedShader.h" 51 #include "core/loader/cache/CachedShader.h"
52 #include "core/loader/cache/CachedXSLStyleSheet.h" 52 #include "core/loader/cache/CachedXSLStyleSheet.h"
53 #include "core/loader/cache/MemoryCache.h" 53 #include "core/loader/cache/MemoryCache.h"
54 #include "core/page/Console.h" 54 #include "core/page/Console.h"
55 #include "core/page/ContentSecurityPolicy.h" 55 #include "core/page/ContentSecurityPolicy.h"
56 #include "core/page/DOMWindow.h" 56 #include "core/page/DOMWindow.h"
57 #include "core/page/Frame.h" 57 #include "core/page/Frame.h"
58 #include "core/page/Performance.h" 58 #include "core/page/Performance.h"
59 #include "core/page/ResourceTimingInfo.h"
59 #include "core/page/Settings.h" 60 #include "core/page/Settings.h"
60 #include "core/platform/Logging.h" 61 #include "core/platform/Logging.h"
61 #include "weborigin/SecurityOrigin.h" 62 #include "weborigin/SecurityOrigin.h"
62 #include "weborigin/SecurityPolicy.h" 63 #include "weborigin/SecurityPolicy.h"
63 64
64 #include "core/loader/cache/CachedTextTrack.h" 65 #include "core/loader/cache/CachedTextTrack.h"
65 66
66 #define PRELOAD_DEBUG 0 67 #define PRELOAD_DEBUG 0
67 68
68 namespace WebCore { 69 namespace WebCore {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 addAdditionalRequestHeaders(request.mutableResourceRequest(), type); 569 addAdditionalRequestHeaders(request.mutableResourceRequest(), type);
569 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset); 570 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset);
570 571
571 memoryCache()->add(resource.get()); 572 memoryCache()->add(resource.get());
572 storeResourceTimingInitiatorInformation(resource, request); 573 storeResourceTimingInitiatorInformation(resource, request);
573 return resource; 574 return resource;
574 } 575 }
575 576
576 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) 577 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request)
577 { 578 {
578 CachedResourceInitiatorInfo info = request.initiatorInfo(); 579 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.initiat orInfo().name, monotonicallyIncreasingTime());
579 info.startTime = monotonicallyIncreasingTime();
580 580
581 if (resource->type() == CachedResource::MainResource) { 581 if (resource->type() == CachedResource::MainResource) {
582 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. 582 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations.
583 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) { 583 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) {
584 info.name = frame()->ownerElement()->localName(); 584 info->setInitiatorType(frame()->ownerElement()->localName());
585 m_initiatorMap.add(resource.get(), info); 585 m_resourceTimingInfoMap.add(resource.get(), info);
586 frame()->ownerElement()->didLoadNonEmptyDocument(); 586 frame()->ownerElement()->didLoadNonEmptyDocument();
587 } 587 }
588 } else { 588 } else {
589 m_initiatorMap.add(resource.get(), info); 589 m_resourceTimingInfoMap.add(resource.get(), info);
590 } 590 }
591 } 591 }
592 592
593 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st 593 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st
594 { 594 {
595 if (!existingResource) 595 if (!existingResource)
596 return Load; 596 return Load;
597 597
598 // We already have a preload going for this URL. 598 // We already have a preload going for this URL.
599 if (forPreload && existingResource->isPreloaded()) 599 if (forPreload && existingResource->isPreloaded())
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 return CachePolicyVerify; 751 return CachePolicyVerify;
752 752
753 if (type != CachedResource::MainResource) 753 if (type != CachedResource::MainResource)
754 return frame()->loader()->subresourceCachePolicy(); 754 return frame()->loader()->subresourceCachePolicy();
755 755
756 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload) 756 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame( )->loader()->loadType() == FrameLoadTypeReload)
757 return CachePolicyReload; 757 return CachePolicyReload;
758 return CachePolicyVerify; 758 return CachePolicyVerify;
759 } 759 }
760 760
761 void CachedResourceLoader::redirectReceived(CachedResource* resource, const Reso urceResponse& redirectResponse)
762 {
763 HashMap<CachedResource*, RefPtr<ResourceTimingInfo> >::iterator infoIter = m _resourceTimingInfoMap.find(resource);
James Simonsen 2013/06/04 01:13:04 Can you make this a typedef in the .h file? I shou
Pan 2013/06/04 02:48:34 yep, done.
764 if (infoIter != m_resourceTimingInfoMap.end())
765 infoIter->value->addRedirect(redirectResponse);
766 }
767
761 void CachedResourceLoader::loadDone(CachedResource* resource) 768 void CachedResourceLoader::loadDone(CachedResource* resource)
762 { 769 {
763 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); 770 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
764 RefPtr<Document> protectDocument(m_document); 771 RefPtr<Document> protectDocument(m_document);
765 772
766 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { 773 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
767 HashMap<CachedResource*, CachedResourceInitiatorInfo>::iterator initiato rIt = m_initiatorMap.find(resource); 774 HashMap<CachedResource*, RefPtr<ResourceTimingInfo> >::iterator infoIt = m_resourceTimingInfoMap.find(resource);
768 if (initiatorIt != m_initiatorMap.end()) { 775 if (infoIt != m_resourceTimingInfoMap.end()) {
769 ASSERT(document()); 776 ASSERT(document());
770 Document* initiatorDocument = document(); 777 Document* initiatorDocument = document();
771 if (resource->type() == CachedResource::MainResource) 778 if (resource->type() == CachedResource::MainResource)
772 initiatorDocument = document()->parentDocument(); 779 initiatorDocument = document()->parentDocument();
773 ASSERT(initiatorDocument); 780 ASSERT(initiatorDocument);
774 const CachedResourceInitiatorInfo& info = initiatorIt->value; 781 RefPtr<ResourceTimingInfo> info = infoIt->value;
775 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); 782 info->setInitialRequest(resource->resourceRequest());
776 m_initiatorMap.remove(initiatorIt); 783 info->setFinalResponse(resource->response());
784 info->setLoadFinishTime(resource->loadFinishTime());
785 initiatorDocument->domWindow()->performance()->addResourceTiming(*in fo, initiatorDocument);
786 m_resourceTimingInfoMap.remove(infoIt);
777 } 787 }
778 } 788 }
779 789
780 if (frame()) 790 if (frame())
781 frame()->loader()->loadDone(); 791 frame()->loader()->loadDone();
782 performPostLoadActions(); 792 performPostLoadActions();
783 793
784 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 794 if (!m_garbageCollectDocumentResourcesTimer.isActive())
785 m_garbageCollectDocumentResourcesTimer.startOneShot(0); 795 m_garbageCollectDocumentResourcesTimer.startOneShot(0);
786 } 796 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); 1016 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer");
1007 } 1017 }
1008 1018
1009 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) 1019 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( )
1010 { 1020 {
1011 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre dentials, DoSecurityCheck, CheckContentSecurityPolicy); 1021 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre dentials, DoSecurityCheck, CheckContentSecurityPolicy);
1012 return options; 1022 return options;
1013 } 1023 }
1014 1024
1015 } 1025 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698