| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "core/loader/cache/CachedScript.h" | 51 #include "core/loader/cache/CachedScript.h" |
| 52 #include "core/loader/cache/CachedShader.h" | 52 #include "core/loader/cache/CachedShader.h" |
| 53 #include "core/loader/cache/CachedTextTrack.h" | 53 #include "core/loader/cache/CachedTextTrack.h" |
| 54 #include "core/loader/cache/CachedXSLStyleSheet.h" | 54 #include "core/loader/cache/CachedXSLStyleSheet.h" |
| 55 #include "core/loader/cache/MemoryCache.h" | 55 #include "core/loader/cache/MemoryCache.h" |
| 56 #include "core/page/Console.h" | 56 #include "core/page/Console.h" |
| 57 #include "core/page/ContentSecurityPolicy.h" | 57 #include "core/page/ContentSecurityPolicy.h" |
| 58 #include "core/page/DOMWindow.h" | 58 #include "core/page/DOMWindow.h" |
| 59 #include "core/page/Frame.h" | 59 #include "core/page/Frame.h" |
| 60 #include "core/page/Performance.h" | 60 #include "core/page/Performance.h" |
| 61 #include "core/page/ResourceTimingInfo.h" |
| 61 #include "core/page/Settings.h" | 62 #include "core/page/Settings.h" |
| 62 #include "core/platform/Logging.h" | 63 #include "core/platform/Logging.h" |
| 63 #include "public/platform/Platform.h" | 64 #include "public/platform/Platform.h" |
| 64 #include "public/platform/WebURL.h" | 65 #include "public/platform/WebURL.h" |
| 65 #include "weborigin/SecurityOrigin.h" | 66 #include "weborigin/SecurityOrigin.h" |
| 66 #include "weborigin/SecurityPolicy.h" | 67 #include "weborigin/SecurityPolicy.h" |
| 67 | 68 |
| 68 #define PRELOAD_DEBUG 0 | 69 #define PRELOAD_DEBUG 0 |
| 69 | 70 |
| 70 namespace WebCore { | 71 namespace WebCore { |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 addAdditionalRequestHeaders(request.mutableResourceRequest(), type); | 671 addAdditionalRequestHeaders(request.mutableResourceRequest(), type); |
| 671 CachedResourceHandle<CachedResource> resource = createResource(type, request
.mutableResourceRequest(), charset); | 672 CachedResourceHandle<CachedResource> resource = createResource(type, request
.mutableResourceRequest(), charset); |
| 672 | 673 |
| 673 memoryCache()->add(resource.get()); | 674 memoryCache()->add(resource.get()); |
| 674 storeResourceTimingInitiatorInformation(resource, request); | 675 storeResourceTimingInitiatorInformation(resource, request); |
| 675 return resource; | 676 return resource; |
| 676 } | 677 } |
| 677 | 678 |
| 678 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR
esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) | 679 void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedR
esourceHandle<CachedResource>& resource, const CachedResourceRequest& request) |
| 679 { | 680 { |
| 680 CachedResourceInitiatorInfo info = request.options().initiatorInfo; | 681 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.options
().initiatorInfo.name, monotonicallyIncreasingTime()); |
| 681 info.startTime = monotonicallyIncreasingTime(); | |
| 682 | 682 |
| 683 if (resource->type() == CachedResource::MainResource) { | 683 if (resource->type() == CachedResource::MainResource) { |
| 684 // <iframe>s should report the initial navigation requested by the paren
t document, but not subsequent navigations. | 684 // <iframe>s should report the initial navigation requested by the paren
t document, but not subsequent navigations. |
| 685 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD
ocument()) { | 685 if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyD
ocument()) { |
| 686 info.name = frame()->ownerElement()->localName(); | 686 info->setInitiatorType(frame()->ownerElement()->localName()); |
| 687 m_initiatorMap.add(resource.get(), info); | 687 m_resourceTimingInfoMap.add(resource.get(), info); |
| 688 frame()->ownerElement()->didLoadNonEmptyDocument(); | 688 frame()->ownerElement()->didLoadNonEmptyDocument(); |
| 689 } | 689 } |
| 690 } else { | 690 } else { |
| 691 m_initiatorMap.add(resource.get(), info); | 691 m_resourceTimingInfoMap.add(resource.get(), info); |
| 692 } | 692 } |
| 693 } | 693 } |
| 694 | 694 |
| 695 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida
tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload,
CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con
st | 695 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida
tionPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload,
CachedResource* existingResource, CachedResourceRequest::DeferOption defer) con
st |
| 696 { | 696 { |
| 697 if (!existingResource) | 697 if (!existingResource) |
| 698 return Load; | 698 return Load; |
| 699 | 699 |
| 700 // We already have a preload going for this URL. | 700 // We already have a preload going for this URL. |
| 701 if (forPreload && existingResource->isPreloaded()) | 701 if (forPreload && existingResource->isPreloaded()) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 return CachePolicyVerify; | 858 return CachePolicyVerify; |
| 859 | 859 |
| 860 if (type != CachedResource::MainResource) | 860 if (type != CachedResource::MainResource) |
| 861 return frame()->loader()->subresourceCachePolicy(); | 861 return frame()->loader()->subresourceCachePolicy(); |
| 862 | 862 |
| 863 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame(
)->loader()->loadType() == FrameLoadTypeReload) | 863 if (frame()->loader()->loadType() == FrameLoadTypeReloadFromOrigin || frame(
)->loader()->loadType() == FrameLoadTypeReload) |
| 864 return CachePolicyReload; | 864 return CachePolicyReload; |
| 865 return CachePolicyVerify; | 865 return CachePolicyVerify; |
| 866 } | 866 } |
| 867 | 867 |
| 868 void CachedResourceLoader::redirectReceived(CachedResource* resource, const Reso
urceResponse& redirectResponse) |
| 869 { |
| 870 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); |
| 871 if (it != m_resourceTimingInfoMap.end()) |
| 872 it->value->addRedirect(redirectResponse); |
| 873 } |
| 874 |
| 868 void CachedResourceLoader::loadDone(CachedResource* resource) | 875 void CachedResourceLoader::loadDone(CachedResource* resource) |
| 869 { | 876 { |
| 870 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); | 877 RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader); |
| 871 RefPtr<Document> protectDocument(m_document); | 878 RefPtr<Document> protectDocument(m_document); |
| 872 | 879 |
| 873 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred(
) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304))
{ | 880 if (resource && resource->response().isHTTP() && ((!resource->errorOccurred(
) && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304))
{ |
| 874 HashMap<CachedResource*, CachedResourceInitiatorInfo>::iterator initiato
rIt = m_initiatorMap.find(resource); | 881 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); |
| 875 if (initiatorIt != m_initiatorMap.end()) { | 882 if (it != m_resourceTimingInfoMap.end()) { |
| 876 ASSERT(document()); | 883 ASSERT(document()); |
| 877 Document* initiatorDocument = document(); | 884 Document* initiatorDocument = document(); |
| 878 if (resource->type() == CachedResource::MainResource) | 885 if (resource->type() == CachedResource::MainResource) |
| 879 initiatorDocument = document()->parentDocument(); | 886 initiatorDocument = document()->parentDocument(); |
| 880 ASSERT(initiatorDocument); | 887 ASSERT(initiatorDocument); |
| 881 const CachedResourceInitiatorInfo& info = initiatorIt->value; | 888 RefPtr<ResourceTimingInfo> info = it->value; |
| 882 initiatorDocument->domWindow()->performance()->addResourceTiming(inf
o.name, initiatorDocument, resource->resourceRequest(), resource->response(), in
fo.startTime, resource->loadFinishTime()); | 889 info->setInitialRequest(resource->resourceRequest()); |
| 883 m_initiatorMap.remove(initiatorIt); | 890 info->setFinalResponse(resource->response()); |
| 891 info->setLoadFinishTime(resource->loadFinishTime()); |
| 892 initiatorDocument->domWindow()->performance()->addResourceTiming(*in
fo, initiatorDocument); |
| 893 m_resourceTimingInfoMap.remove(it); |
| 884 } | 894 } |
| 885 } | 895 } |
| 886 | 896 |
| 887 if (frame()) | 897 if (frame()) |
| 888 frame()->loader()->loadDone(); | 898 frame()->loader()->loadDone(); |
| 889 performPostLoadActions(); | 899 performPostLoadActions(); |
| 890 | 900 |
| 891 if (!m_garbageCollectDocumentResourcesTimer.isActive()) | 901 if (!m_garbageCollectDocumentResourcesTimer.isActive()) |
| 892 m_garbageCollectDocumentResourcesTimer.startOneShot(0); | 902 m_garbageCollectDocumentResourcesTimer.startOneShot(0); |
| 893 } | 903 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume
ntResourcesTimer"); | 1120 info.addMember(m_garbageCollectDocumentResourcesTimer, "garbageCollectDocume
ntResourcesTimer"); |
| 1111 } | 1121 } |
| 1112 | 1122 |
| 1113 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions(
) | 1123 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions(
) |
| 1114 { | 1124 { |
| 1115 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon
tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF
orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy)); | 1125 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon
tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF
orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy)); |
| 1116 return options; | 1126 return options; |
| 1117 } | 1127 } |
| 1118 | 1128 |
| 1119 } | 1129 } |
| OLD | NEW |