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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "DocumentLoader.h" | 43 #include "DocumentLoader.h" |
44 #include "Frame.h" | 44 #include "Frame.h" |
45 #include "FrameLoader.h" | 45 #include "FrameLoader.h" |
46 #include "FrameLoaderClient.h" | 46 #include "FrameLoaderClient.h" |
47 #include "HTMLElement.h" | 47 #include "HTMLElement.h" |
48 #include "HTMLFrameOwnerElement.h" | 48 #include "HTMLFrameOwnerElement.h" |
49 #include "Logging.h" | 49 #include "Logging.h" |
50 #include "MemoryCache.h" | 50 #include "MemoryCache.h" |
51 #include "Performance.h" | 51 #include "Performance.h" |
52 #include "PingLoader.h" | 52 #include "PingLoader.h" |
53 #include "ResourceTimingInfo.h" | |
53 #include "SecurityOrigin.h" | 54 #include "SecurityOrigin.h" |
54 #include "Settings.h" | 55 #include "Settings.h" |
55 #include <wtf/MemoryInstrumentationHashMap.h> | 56 #include <wtf/MemoryInstrumentationHashMap.h> |
56 #include <wtf/MemoryInstrumentationHashSet.h> | 57 #include <wtf/MemoryInstrumentationHashSet.h> |
57 #include <wtf/MemoryInstrumentationListHashSet.h> | 58 #include <wtf/MemoryInstrumentationListHashSet.h> |
58 #include <wtf/UnusedParam.h> | 59 #include <wtf/UnusedParam.h> |
59 #include <wtf/text/CString.h> | 60 #include <wtf/text/CString.h> |
60 #include <wtf/text/WTFString.h> | 61 #include <wtf/text/WTFString.h> |
61 | 62 |
62 #include "CachedTextTrack.h" | 63 #include "CachedTextTrack.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 | 479 |
479 if (!memoryCache()->add(resource.get())) | 480 if (!memoryCache()->add(resource.get())) |
480 resource->setOwningCachedResourceLoader(this); | 481 resource->setOwningCachedResourceLoader(this); |
481 storeResourceTimingInitiatorInformation(resource, request); | 482 storeResourceTimingInitiatorInformation(resource, request); |
482 return resource; | 483 return resource; |
483 } | 484 } |
484 | 485 |
485 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) | 486 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) |
486 { | 487 { |
487 if (resource->type() == CachedResource::MainResource) { | 488 if (resource->type() == CachedResource::MainResource) { |
488 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. | 489 // <iframe>s should report the initial navigation requested by the paren t document, but not subsequent navigations. |
Pan
2013/04/23 15:27:38
I don't quite understand here, and seems it affect
Pan
2013/04/25 12:40:51
The problem is m_documentLoader->frameLoader()->st
| |
489 if (frame()->ownerElement() && m_documentLoader->frameLoader()->stateMac hine()->committingFirstRealLoad()) { | 490 if (frame()->ownerElement() && m_documentLoader->frameLoader()->stateMac hine()->committingFirstRealLoad()) { |
490 InitiatorInfo info = { frame()->ownerElement()->localName(), monoton icallyIncreasingTime() }; | 491 ResourceTimingInfo info(frame()->ownerElement()->localName(), monoto nicallyIncreasingTime()); |
491 m_initiatorMap.add(resource.get(), info); | 492 m_resourceTimingInfoMap.add(resource.get(), info); |
492 } | 493 } |
493 } else { | 494 } else { |
494 InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingT ime() }; | 495 ResourceTimingInfo info(request.initiatorName(), monotonicallyIncreasing Time()); |
495 m_initiatorMap.add(resource.get(), info); | 496 m_resourceTimingInfoMap.add(resource.get(), info); |
496 } | 497 } |
497 } | 498 } |
498 | 499 |
499 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st | 500 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con st |
500 { | 501 { |
501 if (!existingResource) | 502 if (!existingResource) |
502 return Load; | 503 return Load; |
503 | 504 |
504 // We already have a preload going for this URL. | 505 // We already have a preload going for this URL. |
505 if (forPreload && existingResource->isPreloaded()) | 506 if (forPreload && existingResource->isPreloaded()) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
667 void CachedResourceLoader::removeCachedResource(CachedResource* resource) const | 668 void CachedResourceLoader::removeCachedResource(CachedResource* resource) const |
668 { | 669 { |
669 #ifndef NDEBUG | 670 #ifndef NDEBUG |
670 DocumentResourceMap::iterator it = m_documentResources.find(resource->url()) ; | 671 DocumentResourceMap::iterator it = m_documentResources.find(resource->url()) ; |
671 if (it != m_documentResources.end()) | 672 if (it != m_documentResources.end()) |
672 ASSERT(it->value.get() == resource); | 673 ASSERT(it->value.get() == resource); |
673 #endif | 674 #endif |
674 m_documentResources.remove(resource->url()); | 675 m_documentResources.remove(resource->url()); |
675 } | 676 } |
676 | 677 |
678 void CachedResourceLoader::redirectReceived(CachedResource* resource, const Reso urceResponse& redirectResponse) | |
679 { | |
680 HashMap<CachedResource*, ResourceTimingInfo>::iterator infoIter = m_resource TimingInfoMap.find(resource); | |
681 if (infoIter != m_resourceTimingInfoMap.end()) | |
682 infoIter->value.addRedirect(redirectResponse); | |
683 } | |
684 | |
677 void CachedResourceLoader::loadDone(CachedResource* resource) | 685 void CachedResourceLoader::loadDone(CachedResource* resource) |
678 { | 686 { |
679 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); | 687 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); |
680 RefPtr<Document> protectDocument(m_document); | 688 RefPtr<Document> protectDocument(m_document); |
681 | 689 |
682 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { | 690 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred( ) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) { |
683 HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initia torMap.find(resource); | 691 HashMap<CachedResource*, ResourceTimingInfo>::iterator infoIt = m_resour ceTimingInfoMap.find(resource); |
684 if (initiatorIt != m_initiatorMap.end()) { | 692 if (infoIt != m_resourceTimingInfoMap.end()) { |
685 ASSERT(document()); | 693 ASSERT(document()); |
686 Document* initiatorDocument = document(); | 694 Document* initiatorDocument = document(); |
687 if (resource->type() == CachedResource::MainResource) | 695 if (resource->type() == CachedResource::MainResource) |
688 initiatorDocument = document()->parentDocument(); | 696 initiatorDocument = document()->parentDocument(); |
689 ASSERT(initiatorDocument); | 697 ASSERT(initiatorDocument); |
690 const InitiatorInfo& info = initiatorIt->value; | 698 ResourceTimingInfo& info = infoIt->value; |
691 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in fo.startTime, resource->loadFinishTime()); | 699 info.setInitialRequest(resource->resourceRequest()); |
692 m_initiatorMap.remove(initiatorIt); | 700 info.setFinalResponse(resource->response()); |
701 info.setLoadFinishTime(resource->loadFinishTime()); | |
702 initiatorDocument->domWindow()->performance()->addResourceTiming(inf o, initiatorDocument); | |
703 m_resourceTimingInfoMap.remove(infoIt); | |
693 } | 704 } |
694 } | 705 } |
695 | 706 |
696 if (frame()) | 707 if (frame()) |
697 frame()->loader()->loadDone(); | 708 frame()->loader()->loadDone(); |
698 performPostLoadActions(); | 709 performPostLoadActions(); |
699 | 710 |
700 if (!m_garbageCollectDocumentResourcesTimer.isActive()) | 711 if (!m_garbageCollectDocumentResourcesTimer.isActive()) |
701 m_garbageCollectDocumentResourcesTimer.startOneShot(0); | 712 m_garbageCollectDocumentResourcesTimer.startOneShot(0); |
702 } | 713 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 926 void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
916 { | 927 { |
917 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); | 928 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); |
918 info.addMember(m_documentResources, "documentResources"); | 929 info.addMember(m_documentResources, "documentResources"); |
919 info.addMember(m_document, "document"); | 930 info.addMember(m_document, "document"); |
920 info.addMember(m_documentLoader, "documentLoader"); | 931 info.addMember(m_documentLoader, "documentLoader"); |
921 info.addMember(m_validatedURLs, "validatedURLs"); | 932 info.addMember(m_validatedURLs, "validatedURLs"); |
922 info.addMember(m_preloads, "preloads"); | 933 info.addMember(m_preloads, "preloads"); |
923 info.addMember(m_pendingPreloads, "pendingPreloads"); | 934 info.addMember(m_pendingPreloads, "pendingPreloads"); |
924 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); | 935 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume ntResourcesTimer"); |
925 // FIXME: m_initiatorMap has pointers to already deleted CachedResources | 936 // FIXME: m_resourceTimingInfoMap has pointers to already deleted CachedReso urces |
926 info.ignoreMember(m_initiatorMap); | 937 info.ignoreMember(m_resourceTimingInfoMap); |
927 } | 938 } |
928 | 939 |
929 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) | 940 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) |
930 { | 941 { |
931 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, AskClientForCrossOriginCredentials, DoSecurityCheck); | 942 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, AskClientForCrossOriginCredentials, DoSecurityCheck); |
932 return options; | 943 return options; |
933 } | 944 } |
934 | 945 |
935 } | 946 } |
OLD | NEW |