Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset); | 562 CachedResourceHandle<CachedResource> resource = createResource(type, request .mutableResourceRequest(), charset); |
| 563 | 563 |
| 564 if (!memoryCache()->add(resource.get())) | 564 if (!memoryCache()->add(resource.get())) |
| 565 resource->setOwningCachedResourceLoader(this); | 565 resource->setOwningCachedResourceLoader(this); |
| 566 storeResourceTimingInitiatorInformation(resource, request); | 566 storeResourceTimingInitiatorInformation(resource, request); |
| 567 return resource; | 567 return resource; |
| 568 } | 568 } |
| 569 | 569 |
| 570 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) | 570 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) |
| 571 { | 571 { |
| 572 if (resource->type() == CachedResource::MainResource) { | 572 CachedResourceInitiatorInfo info = request.initiatorInfo(); |
| 573 info.startTime = monotonicallyIncreasingTime(); | |
| 574 if ((resource->type() == CachedResource::MainResource) && frame()->ownerElem ent()) { | |
| 575 info.name = frame()->ownerElement()->localName(); | |
| 573 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. | 576 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. |
| 574 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD ocument()) { | 577 if (!frame()->ownerElement()->loadedNonEmptyDocument()) { |
| 575 InitiatorInfo info = { frame()->ownerElement()->localName(), monoton icallyIncreasingTime() }; | 578 info.isInitialFrameLoad = true; |
| 576 m_initiatorMap.add(resource.get(), info); | |
| 577 frame()->ownerElement()->didLoadNonEmptyDocument(); | 579 frame()->ownerElement()->didLoadNonEmptyDocument(); |
| 578 } | 580 } |
| 579 } else { | |
| 580 InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingT ime() }; | |
| 581 m_initiatorMap.add(resource.get(), info); | |
| 582 } | 581 } |
| 582 resource->setInitiatorInfo(info); | |
|
James Simonsen
2013/05/16 13:28:54
The initiator info is different depending on which
eustas
2013/05/16 14:26:54
I see that CachedResource initiatorInfo is set onc
| |
| 583 } | 583 } |
| 584 | 584 |
| 585 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st | 585 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st |
| 586 { | 586 { |
| 587 if (!existingResource) | 587 if (!existingResource) |
| 588 return Load; | 588 return Load; |
| 589 | 589 |
| 590 // We already have a preload going for this URL. | 590 // We already have a preload going for this URL. |
| 591 if (forPreload && existingResource->isPreloaded()) | 591 if (forPreload && existingResource->isPreloaded()) |
| 592 return Use; | 592 return Use; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 #endif | 759 #endif |
| 760 m_documentResources.remove(resource->url()); | 760 m_documentResources.remove(resource->url()); |
| 761 } | 761 } |
| 762 | 762 |
| 763 void CachedResourceLoader::loadDone(CachedResource* resource) | 763 void CachedResourceLoader::loadDone(CachedResource* resource) |
| 764 { | 764 { |
| 765 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); | 765 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); |
| 766 RefPtr<Document> protectDocument(m_document); | 766 RefPtr<Document> protectDocument(m_document); |
| 767 | 767 |
| 768 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { | 768 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { |
| 769 HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initia torMap.find(resource); | 769 const CachedResourceInitiatorInfo& info = resource->initiatorInfo(); |
| 770 if (initiatorIt != m_initiatorMap.end()) { | 770 bool isMainResource = resource->type() == CachedResource::MainResource; |
| 771 if ((resource->type() != CachedResource::MainResource) || info.isInitial FrameLoad) { | |
| 771 ASSERT(document()); | 772 ASSERT(document()); |
| 772 Document* initiatorDocument = document(); | 773 Document* initiatorDocument = document(); |
| 773 if (resource->type() == CachedResource::MainResource) | 774 if (info.isInitialFrameLoad) |
| 774 initiatorDocument = document()->parentDocument(); | 775 initiatorDocument = document()->parentDocument(); |
| 775 ASSERT(initiatorDocument); | 776 ASSERT(initiatorDocument); |
| 776 const InitiatorInfo& info = initiatorIt->value; | |
| 777 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); | 777 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); |
| 778 m_initiatorMap.remove(initiatorIt); | |
| 779 } | 778 } |
| 780 } | 779 } |
| 781 | 780 |
| 782 if (frame()) | 781 if (frame()) |
| 783 frame()->loader()->loadDone(); | 782 frame()->loader()->loadDone(); |
| 784 performPostLoadActions(); | 783 performPostLoadActions(); |
| 785 | 784 |
| 786 if (!m_garbageCollectDocumentResourcesTimer.isActive()) | 785 if (!m_garbageCollectDocumentResourcesTimer.isActive()) |
| 787 m_garbageCollectDocumentResourcesTimer.startOneShot(0); | 786 m_garbageCollectDocumentResourcesTimer.startOneShot(0); |
| 788 } | 787 } |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1001 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 1000 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
| 1002 { | 1001 { |
| 1003 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); | 1002 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); |
| 1004 info.addMember(m_documentResources, "documentResources"); | 1003 info.addMember(m_documentResources, "documentResources"); |
| 1005 info.addMember(m_document, "document"); | 1004 info.addMember(m_document, "document"); |
| 1006 info.addMember(m_documentLoader, "documentLoader"); | 1005 info.addMember(m_documentLoader, "documentLoader"); |
| 1007 info.addMember(m_validatedURLs, "validatedURLs"); | 1006 info.addMember(m_validatedURLs, "validatedURLs"); |
| 1008 info.addMember(m_preloads, "preloads"); | 1007 info.addMember(m_preloads, "preloads"); |
| 1009 info.addMember(m_pendingPreloads, "pendingPreloads"); | 1008 info.addMember(m_pendingPreloads, "pendingPreloads"); |
| 1010 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); | 1009 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); |
| 1011 // FIXME: m_initiatorMap has pointers to already deleted CachedResources | |
| 1012 info.ignoreMember(m_initiatorMap); | |
| 1013 } | 1010 } |
| 1014 | 1011 |
| 1015 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) | 1012 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) |
| 1016 { | 1013 { |
| 1017 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre dentials, DoSecurityCheck); | 1014 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre dentials, DoSecurityCheck); |
| 1018 return options; | 1015 return options; |
| 1019 } | 1016 } |
| 1020 | 1017 |
| 1021 } | 1018 } |
| OLD | NEW |