| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 if (!resource) | 456 if (!resource) |
| 457 resource = memoryCache()->resourceForURL(request.url(), getCacheIdentifi
er()); | 457 resource = memoryCache()->resourceForURL(request.url(), getCacheIdentifi
er()); |
| 458 | 458 |
| 459 // See if we can use an existing resource from the cache. If so, we need to
move it to be load blocking. | 459 // See if we can use an existing resource from the cache. If so, we need to
move it to be load blocking. |
| 460 moveCachedNonBlockingResourceToBlocking(resource, request); | 460 moveCachedNonBlockingResourceToBlocking(resource, request); |
| 461 | 461 |
| 462 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type()
, request, resource, isStaticData); | 462 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type()
, request, resource, isStaticData); |
| 463 | 463 |
| 464 updateMemoryCacheStats(resource, policy, request, factory, isStaticData); | 464 updateMemoryCacheStats(resource, policy, request, factory, isStaticData); |
| 465 | 465 |
| 466 if (policy != Use) | 466 request.mutableResourceRequest().setAllowStoredCredentials(request.options()
.allowCredentials == AllowStoredCredentials); |
| 467 willSendRequest(identifier, request.mutableResourceRequest(), ResourceRe
sponse(), request.options()); | |
| 468 | 467 |
| 469 switch (policy) { | 468 switch (policy) { |
| 470 case Reload: | 469 case Reload: |
| 471 memoryCache()->remove(resource); | 470 memoryCache()->remove(resource); |
| 472 // Fall through | 471 // Fall through |
| 473 case Load: | 472 case Load: |
| 474 resource = createResourceForLoading(request, request.charset(), factory)
; | 473 resource = createResourceForLoading(request, request.charset(), factory)
; |
| 475 break; | 474 break; |
| 476 case Revalidate: | 475 case Revalidate: |
| 477 initializeRevalidation(request.mutableResourceRequest(), resource); | 476 initializeRevalidation(request.mutableResourceRequest(), resource); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 } | 976 } |
| 978 | 977 |
| 979 bool ResourceFetcher::startLoad(Resource* resource) | 978 bool ResourceFetcher::startLoad(Resource* resource) |
| 980 { | 979 { |
| 981 DCHECK(resource && resource->stillNeedsLoad()); | 980 DCHECK(resource && resource->stillNeedsLoad()); |
| 982 if (!context().shouldLoadNewResource(resource->getType())) { | 981 if (!context().shouldLoadNewResource(resource->getType())) { |
| 983 memoryCache()->remove(resource); | 982 memoryCache()->remove(resource); |
| 984 return false; | 983 return false; |
| 985 } | 984 } |
| 986 | 985 |
| 986 ResourceRequest request(resource->resourceRequest()); |
| 987 willSendRequest(resource->identifier(), request, ResourceResponse(), resourc
e->options()); |
| 988 |
| 987 ResourceLoader* loader = ResourceLoader::create(this, resource); | 989 ResourceLoader* loader = ResourceLoader::create(this, resource); |
| 988 if (resource->shouldBlockLoadEvent()) | 990 if (resource->shouldBlockLoadEvent()) |
| 989 m_loaders.add(loader); | 991 m_loaders.add(loader); |
| 990 else | 992 else |
| 991 m_nonBlockingLoaders.add(loader); | 993 m_nonBlockingLoaders.add(loader); |
| 992 | 994 |
| 993 storeResourceTimingInitiatorInformation(resource); | 995 storeResourceTimingInitiatorInformation(resource); |
| 994 resource->setFetcherSecurityOrigin(context().getSecurityOrigin()); | 996 resource->setFetcherSecurityOrigin(context().getSecurityOrigin()); |
| 995 loader->start(resource->resourceRequest(), context().loadingTaskRunner(), co
ntext().defersLoading()); | 997 loader->start(request, context().loadingTaskRunner(), context().defersLoadin
g()); |
| 996 return true; | 998 return true; |
| 997 } | 999 } |
| 998 | 1000 |
| 999 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) | 1001 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) |
| 1000 { | 1002 { |
| 1001 if (m_loaders.contains(loader)) | 1003 if (m_loaders.contains(loader)) |
| 1002 m_loaders.remove(loader); | 1004 m_loaders.remove(loader); |
| 1003 else if (m_nonBlockingLoaders.contains(loader)) | 1005 else if (m_nonBlockingLoaders.contains(loader)) |
| 1004 m_nonBlockingLoaders.remove(loader); | 1006 m_nonBlockingLoaders.remove(loader); |
| 1005 else | 1007 else |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 return false; | 1053 return false; |
| 1052 } | 1054 } |
| 1053 } | 1055 } |
| 1054 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newRe
quest.url())) | 1056 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newRe
quest.url())) |
| 1055 return false; | 1057 return false; |
| 1056 } | 1058 } |
| 1057 | 1059 |
| 1058 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); | 1060 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); |
| 1059 if (it != m_resourceTimingInfoMap.end()) | 1061 if (it != m_resourceTimingInfoMap.end()) |
| 1060 it->value->addRedirect(redirectResponse); | 1062 it->value->addRedirect(redirectResponse); |
| 1063 newRequest.setAllowStoredCredentials(resource->options().allowCredentials ==
AllowStoredCredentials); |
| 1061 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour
ce->options()); | 1064 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour
ce->options()); |
| 1062 return true; | 1065 return true; |
| 1063 } | 1066 } |
| 1064 | 1067 |
| 1065 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest&
newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio
ns& options) | 1068 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest&
newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio
ns& options) |
| 1066 { | 1069 { |
| 1067 newRequest.setAllowStoredCredentials(options.allowCredentials == AllowStored
Credentials); | |
| 1068 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse,
options.initiatorInfo); | 1070 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse,
options.initiatorInfo); |
| 1069 } | 1071 } |
| 1070 | 1072 |
| 1071 void ResourceFetcher::updateAllImageResourcePriorities() | 1073 void ResourceFetcher::updateAllImageResourcePriorities() |
| 1072 { | 1074 { |
| 1073 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource
Priorities"); | 1075 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource
Priorities"); |
| 1074 for (const auto& documentResource : m_documentResources) { | 1076 for (const auto& documentResource : m_documentResources) { |
| 1075 Resource* resource = documentResource.value.get(); | 1077 Resource* resource = documentResource.value.get(); |
| 1076 if (!resource || !resource->isImage() || !resource->isLoading()) | 1078 if (!resource || !resource->isImage() || !resource->isLoading()) |
| 1077 continue; | 1079 continue; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 visitor->trace(m_context); | 1263 visitor->trace(m_context); |
| 1262 visitor->trace(m_archive); | 1264 visitor->trace(m_archive); |
| 1263 visitor->trace(m_loaders); | 1265 visitor->trace(m_loaders); |
| 1264 visitor->trace(m_nonBlockingLoaders); | 1266 visitor->trace(m_nonBlockingLoaders); |
| 1265 visitor->trace(m_documentResources); | 1267 visitor->trace(m_documentResources); |
| 1266 visitor->trace(m_preloads); | 1268 visitor->trace(m_preloads); |
| 1267 visitor->trace(m_resourceTimingInfoMap); | 1269 visitor->trace(m_resourceTimingInfoMap); |
| 1268 } | 1270 } |
| 1269 | 1271 |
| 1270 } // namespace blink | 1272 } // namespace blink |
| OLD | NEW |