| 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 CachedResourceInitiatorInfo info = request.initiatorInfo(); |
| 573 info.startTime = monotonicallyIncreasingTime(); |
| 572 if (resource->type() == CachedResource::MainResource) { | 574 if (resource->type() == CachedResource::MainResource) { |
| 573 // <iframe>s should report the initial navigation requested by the paren
t document, but not subsequent navigations. | 575 // <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()) { | 576 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD
ocument()) { |
| 575 InitiatorInfo info = { frame()->ownerElement()->localName(), monoton
icallyIncreasingTime() }; | 577 info.name = frame()->ownerElement()->localName(); |
| 576 m_initiatorMap.add(resource.get(), info); | 578 resource->setInitiatorInfo(info); |
| 577 frame()->ownerElement()->didLoadNonEmptyDocument(); | 579 frame()->ownerElement()->didLoadNonEmptyDocument(); |
| 578 } | 580 } |
| 579 } else { | 581 } else |
| 580 InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingT
ime() }; | 582 resource->setInitiatorInfo(info); |
| 581 m_initiatorMap.add(resource.get(), info); | |
| 582 } | |
| 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 ASSERT(document()); |
| 770 if (initiatorIt != m_initiatorMap.end()) { | 770 Document* initiatorDocument = document(); |
| 771 ASSERT(document()); | 771 if (resource->type() == CachedResource::MainResource) |
| 772 Document* initiatorDocument = document(); | 772 initiatorDocument = document()->parentDocument(); |
| 773 if (resource->type() == CachedResource::MainResource) | 773 ASSERT(initiatorDocument); |
| 774 initiatorDocument = document()->parentDocument(); | 774 const CachedResourceInitiatorInfo& info = resource->initiatorInfo(); |
| 775 ASSERT(initiatorDocument); | 775 initiatorDocument->domWindow()->performance()->addResourceTiming(info.na
me, initiatorDocument, resource->resourceRequest(), resource->response(), info.s
tartTime, resource->loadFinishTime()); |
| 776 const InitiatorInfo& info = initiatorIt->value; | |
| 777 initiatorDocument->domWindow()->performance()->addResourceTiming(inf
o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in
fo.startTime, resource->loadFinishTime()); | |
| 778 m_initiatorMap.remove(initiatorIt); | |
| 779 } | |
| 780 } | 776 } |
| 781 | 777 |
| 782 if (frame()) | 778 if (frame()) |
| 783 frame()->loader()->loadDone(); | 779 frame()->loader()->loadDone(); |
| 784 performPostLoadActions(); | 780 performPostLoadActions(); |
| 785 | 781 |
| 786 if (!m_garbageCollectDocumentResourcesTimer.isActive()) | 782 if (!m_garbageCollectDocumentResourcesTimer.isActive()) |
| 787 m_garbageCollectDocumentResourcesTimer.startOneShot(0); | 783 m_garbageCollectDocumentResourcesTimer.startOneShot(0); |
| 788 } | 784 } |
| 789 | 785 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
const | 997 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
const |
| 1002 { | 998 { |
| 1003 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); | 999 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); |
| 1004 info.addMember(m_documentResources, "documentResources"); | 1000 info.addMember(m_documentResources, "documentResources"); |
| 1005 info.addMember(m_document, "document"); | 1001 info.addMember(m_document, "document"); |
| 1006 info.addMember(m_documentLoader, "documentLoader"); | 1002 info.addMember(m_documentLoader, "documentLoader"); |
| 1007 info.addMember(m_validatedURLs, "validatedURLs"); | 1003 info.addMember(m_validatedURLs, "validatedURLs"); |
| 1008 info.addMember(m_preloads, "preloads"); | 1004 info.addMember(m_preloads, "preloads"); |
| 1009 info.addMember(m_pendingPreloads, "pendingPreloads"); | 1005 info.addMember(m_pendingPreloads, "pendingPreloads"); |
| 1010 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume
ntResourcesTimer"); | 1006 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume
ntResourcesTimer"); |
| 1011 // FIXME: m_initiatorMap has pointers to already deleted CachedResources | |
| 1012 info.ignoreMember(m_initiatorMap); | |
| 1013 } | 1007 } |
| 1014 | 1008 |
| 1015 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions(
) | 1009 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions(
) |
| 1016 { | 1010 { |
| 1017 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData
, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre
dentials, DoSecurityCheck); | 1011 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData
, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCre
dentials, DoSecurityCheck); |
| 1018 return options; | 1012 return options; |
| 1019 } | 1013 } |
| 1020 | 1014 |
| 1021 } | 1015 } |
| OLD | NEW |