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

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

Issue 14672042: Prepare to add more initiator info to CachedResource(Request) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset); 550 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset);
551 551
552 if (!memoryCache()->add(resource.get())) 552 if (!memoryCache()->add(resource.get()))
553 resource->setOwningCachedResourceLoader(this); 553 resource->setOwningCachedResourceLoader(this);
554 storeResourceTimingInitiatorInformation(resource, request); 554 storeResourceTimingInitiatorInformation(resource, request);
555 return resource; 555 return resource;
556 } 556 }
557 557
558 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) 558 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request)
559 { 559 {
560 CachedResourceInitiatorInfo info = request.initiatorInfo();
561 info.startTime = monotonicallyIncreasingTime();
562
560 if (resource->type() == CachedResource::MainResource) { 563 if (resource->type() == CachedResource::MainResource) {
561 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. 564 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations.
562 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) { 565 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) {
563 InitiatorInfo info = { frame()->ownerElement()->localName(), monoton icallyIncreasingTime() }; 566 info.name = frame()->ownerElement()->localName();
564 m_initiatorMap.add(resource.get(), info); 567 m_initiatorMap.add(resource.get(), info);
565 frame()->ownerElement()->didLoadNonEmptyDocument(); 568 frame()->ownerElement()->didLoadNonEmptyDocument();
566 } 569 }
567 } else { 570 } else {
568 InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingT ime() };
569 m_initiatorMap.add(resource.get(), info); 571 m_initiatorMap.add(resource.get(), info);
570 } 572 }
571 } 573 }
572 574
573 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st 575 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st
574 { 576 {
575 if (!existingResource) 577 if (!existingResource)
576 return Load; 578 return Load;
577 579
578 // We already have a preload going for this URL. 580 // We already have a preload going for this URL.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 #endif 749 #endif
748 m_documentResources.remove(resource->url()); 750 m_documentResources.remove(resource->url());
749 } 751 }
750 752
751 void CachedResourceLoader::loadDone(CachedResource* resource) 753 void CachedResourceLoader::loadDone(CachedResource* resource)
752 { 754 {
753 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); 755 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
754 RefPtr<Document> protectDocument(m_document); 756 RefPtr<Document> protectDocument(m_document);
755 757
756 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { 758 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
757 HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initia torMap.find(resource); 759 HashMap<CachedResource*, CachedResourceInitiatorInfo>::iterator initiato rIt = m_initiatorMap.find(resource);
758 if (initiatorIt != m_initiatorMap.end()) { 760 if (initiatorIt != m_initiatorMap.end()) {
759 ASSERT(document()); 761 ASSERT(document());
760 Document* initiatorDocument = document(); 762 Document* initiatorDocument = document();
761 if (resource->type() == CachedResource::MainResource) 763 if (resource->type() == CachedResource::MainResource)
762 initiatorDocument = document()->parentDocument(); 764 initiatorDocument = document()->parentDocument();
763 ASSERT(initiatorDocument); 765 ASSERT(initiatorDocument);
764 const InitiatorInfo& info = initiatorIt->value; 766 const CachedResourceInitiatorInfo& info = initiatorIt->value;
765 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); 767 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime());
766 m_initiatorMap.remove(initiatorIt); 768 m_initiatorMap.remove(initiatorIt);
767 } 769 }
768 } 770 }
769 771
770 if (frame()) 772 if (frame())
771 frame()->loader()->loadDone(); 773 frame()->loader()->loadDone();
772 performPostLoadActions(); 774 performPostLoadActions();
773 775
774 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 776 if (!m_garbageCollectDocumentResourcesTimer.isActive())
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 991 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
990 { 992 {
991 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); 993 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader);
992 info.addMember(m_documentResources, "documentResources"); 994 info.addMember(m_documentResources, "documentResources");
993 info.addMember(m_document, "document"); 995 info.addMember(m_document, "document");
994 info.addMember(m_documentLoader, "documentLoader"); 996 info.addMember(m_documentLoader, "documentLoader");
995 info.addMember(m_validatedURLs, "validatedURLs"); 997 info.addMember(m_validatedURLs, "validatedURLs");
996 info.addMember(m_preloads, "preloads"); 998 info.addMember(m_preloads, "preloads");
997 info.addMember(m_pendingPreloads, "pendingPreloads"); 999 info.addMember(m_pendingPreloads, "pendingPreloads");
998 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); 1000 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer");
999 // FIXME: m_initiatorMap has pointers to already deleted CachedResources
1000 info.ignoreMember(m_initiatorMap);
1001 } 1001 }
1002 1002
1003 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) 1003 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( )
1004 { 1004 {
1005 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre dentials, DoSecurityCheck, CheckContentSecurityPolicy); 1005 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre dentials, DoSecurityCheck, CheckContentSecurityPolicy);
1006 return options; 1006 return options;
1007 } 1007 }
1008 1008
1009 } 1009 }
OLDNEW
« no previous file with comments | « Source/core/loader/cache/CachedResourceLoader.h ('k') | Source/core/loader/cache/CachedResourceRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698