| 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 | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 6 rights reserved. | 6 rights reserved. |
| 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 info->clearLoadTimings(); | 313 info->clearLoadTimings(); |
| 314 info->setLoadFinishTime(info->initialTime()); | 314 info->setLoadFinishTime(info->initialTime()); |
| 315 m_scheduledResourceTimingReports.push_back(std::move(info)); | 315 m_scheduledResourceTimingReports.push_back(std::move(info)); |
| 316 if (!m_resourceTimingReportTimer.isActive()) | 316 if (!m_resourceTimingReportTimer.isActive()) |
| 317 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); | 317 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 318 } | 318 } |
| 319 | 319 |
| 320 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { | 320 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { |
| 321 m_validatedURLs.clear(); | 321 m_validatedURLs.clear(); |
| 322 } | 322 } |
| 323 m_validatedURLs.add(request.resourceRequest().url()); | 323 m_validatedURLs.insert(request.resourceRequest().url()); |
| 324 } | 324 } |
| 325 | 325 |
| 326 static std::unique_ptr<TracedValue> urlForTraceEvent(const KURL& url) { | 326 static std::unique_ptr<TracedValue> urlForTraceEvent(const KURL& url) { |
| 327 std::unique_ptr<TracedValue> value = TracedValue::create(); | 327 std::unique_ptr<TracedValue> value = TracedValue::create(); |
| 328 value->setString("url", url.getString()); | 328 value->setString("url", url.getString()); |
| 329 return value; | 329 return value; |
| 330 } | 330 } |
| 331 | 331 |
| 332 Resource* ResourceFetcher::resourceForStaticData( | 332 Resource* ResourceFetcher::resourceForStaticData( |
| 333 const FetchRequest& request, | 333 const FetchRequest& request, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 void ResourceFetcher::moveCachedNonBlockingResourceToBlocking( | 416 void ResourceFetcher::moveCachedNonBlockingResourceToBlocking( |
| 417 Resource* resource, | 417 Resource* resource, |
| 418 const FetchRequest& request) { | 418 const FetchRequest& request) { |
| 419 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue | 419 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue |
| 420 // to not-block even after being preloaded and discovered. | 420 // to not-block even after being preloaded and discovered. |
| 421 if (resource && resource->loader() && | 421 if (resource && resource->loader() && |
| 422 resource->isLoadEventBlockingResourceType() && | 422 resource->isLoadEventBlockingResourceType() && |
| 423 m_nonBlockingLoaders.contains(resource->loader()) && | 423 m_nonBlockingLoaders.contains(resource->loader()) && |
| 424 resource->isLinkPreload() && !request.forPreload()) { | 424 resource->isLinkPreload() && !request.forPreload()) { |
| 425 m_nonBlockingLoaders.remove(resource->loader()); | 425 m_nonBlockingLoaders.remove(resource->loader()); |
| 426 m_loaders.add(resource->loader()); | 426 m_loaders.insert(resource->loader()); |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 void ResourceFetcher::updateMemoryCacheStats(Resource* resource, | 430 void ResourceFetcher::updateMemoryCacheStats(Resource* resource, |
| 431 RevalidationPolicy policy, | 431 RevalidationPolicy policy, |
| 432 const FetchRequest& request, | 432 const FetchRequest& request, |
| 433 const ResourceFactory& factory, | 433 const ResourceFactory& factory, |
| 434 bool isStaticData) const { | 434 bool isStaticData) const { |
| 435 if (isStaticData) | 435 if (isStaticData) |
| 436 return; | 436 return; |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 void ResourceFetcher::preloadStarted(Resource* resource) { | 1024 void ResourceFetcher::preloadStarted(Resource* resource) { |
| 1025 if (m_preloads && m_preloads->contains(resource)) | 1025 if (m_preloads && m_preloads->contains(resource)) |
| 1026 return; | 1026 return; |
| 1027 resource->increasePreloadCount(); | 1027 resource->increasePreloadCount(); |
| 1028 | 1028 |
| 1029 if (!m_preloads) | 1029 if (!m_preloads) |
| 1030 m_preloads = new HeapListHashSet<Member<Resource>>; | 1030 m_preloads = new HeapListHashSet<Member<Resource>>; |
| 1031 m_preloads->add(resource); | 1031 m_preloads->add(resource); |
| 1032 | 1032 |
| 1033 if (m_preloadedURLsForTest) | 1033 if (m_preloadedURLsForTest) |
| 1034 m_preloadedURLsForTest->add(resource->url().getString()); | 1034 m_preloadedURLsForTest->insert(resource->url().getString()); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 void ResourceFetcher::enableIsPreloadedForTest() { | 1037 void ResourceFetcher::enableIsPreloadedForTest() { |
| 1038 if (m_preloadedURLsForTest) | 1038 if (m_preloadedURLsForTest) |
| 1039 return; | 1039 return; |
| 1040 m_preloadedURLsForTest = WTF::wrapUnique(new HashSet<String>); | 1040 m_preloadedURLsForTest = WTF::wrapUnique(new HashSet<String>); |
| 1041 | 1041 |
| 1042 if (m_preloads) { | 1042 if (m_preloads) { |
| 1043 for (const auto& resource : *m_preloads) | 1043 for (const auto& resource : *m_preloads) |
| 1044 m_preloadedURLsForTest->add(resource->url().getString()); | 1044 m_preloadedURLsForTest->insert(resource->url().getString()); |
| 1045 } | 1045 } |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 bool ResourceFetcher::isPreloadedForTest(const KURL& url) const { | 1048 bool ResourceFetcher::isPreloadedForTest(const KURL& url) const { |
| 1049 DCHECK(m_preloadedURLsForTest); | 1049 DCHECK(m_preloadedURLsForTest); |
| 1050 return m_preloadedURLsForTest->contains(url.getString()); | 1050 return m_preloadedURLsForTest->contains(url.getString()); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) { | 1053 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) { |
| 1054 if (!m_preloads) | 1054 if (!m_preloads) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 | 1178 |
| 1179 resource->error(error); | 1179 resource->error(error); |
| 1180 | 1180 |
| 1181 handleLoadCompletion(resource); | 1181 handleLoadCompletion(resource); |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 void ResourceFetcher::moveResourceLoaderToNonBlocking(ResourceLoader* loader) { | 1184 void ResourceFetcher::moveResourceLoaderToNonBlocking(ResourceLoader* loader) { |
| 1185 DCHECK(loader); | 1185 DCHECK(loader); |
| 1186 // TODO(yoav): Convert CHECK to DCHECK if no crash reports come in. | 1186 // TODO(yoav): Convert CHECK to DCHECK if no crash reports come in. |
| 1187 CHECK(m_loaders.contains(loader)); | 1187 CHECK(m_loaders.contains(loader)); |
| 1188 m_nonBlockingLoaders.add(loader); | 1188 m_nonBlockingLoaders.insert(loader); |
| 1189 m_loaders.remove(loader); | 1189 m_loaders.remove(loader); |
| 1190 } | 1190 } |
| 1191 | 1191 |
| 1192 bool ResourceFetcher::startLoad(Resource* resource) { | 1192 bool ResourceFetcher::startLoad(Resource* resource) { |
| 1193 DCHECK(resource); | 1193 DCHECK(resource); |
| 1194 DCHECK(resource->stillNeedsLoad()); | 1194 DCHECK(resource->stillNeedsLoad()); |
| 1195 if (!context().shouldLoadNewResource(resource->getType())) { | 1195 if (!context().shouldLoadNewResource(resource->getType())) { |
| 1196 memoryCache()->remove(resource); | 1196 memoryCache()->remove(resource); |
| 1197 return false; | 1197 return false; |
| 1198 } | 1198 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1210 // Resource requests from suborigins should not be intercepted by the service | 1210 // Resource requests from suborigins should not be intercepted by the service |
| 1211 // worker of the physical origin. This has the effect that, for now, | 1211 // worker of the physical origin. This has the effect that, for now, |
| 1212 // suborigins do not work with service workers. See | 1212 // suborigins do not work with service workers. See |
| 1213 // https://w3c.github.io/webappsec-suborigins/. | 1213 // https://w3c.github.io/webappsec-suborigins/. |
| 1214 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); | 1214 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); |
| 1215 if (sourceOrigin && sourceOrigin->hasSuborigin()) | 1215 if (sourceOrigin && sourceOrigin->hasSuborigin()) |
| 1216 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); | 1216 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); |
| 1217 | 1217 |
| 1218 ResourceLoader* loader = ResourceLoader::create(this, resource); | 1218 ResourceLoader* loader = ResourceLoader::create(this, resource); |
| 1219 if (resource->shouldBlockLoadEvent()) | 1219 if (resource->shouldBlockLoadEvent()) |
| 1220 m_loaders.add(loader); | 1220 m_loaders.insert(loader); |
| 1221 else | 1221 else |
| 1222 m_nonBlockingLoaders.add(loader); | 1222 m_nonBlockingLoaders.insert(loader); |
| 1223 | 1223 |
| 1224 storePerformanceTimingInitiatorInformation(resource); | 1224 storePerformanceTimingInitiatorInformation(resource); |
| 1225 resource->setFetcherSecurityOrigin(sourceOrigin); | 1225 resource->setFetcherSecurityOrigin(sourceOrigin); |
| 1226 | 1226 |
| 1227 loader->activateCacheAwareLoadingIfNeeded(request); | 1227 loader->activateCacheAwareLoadingIfNeeded(request); |
| 1228 loader->start(request); | 1228 loader->start(request); |
| 1229 return true; | 1229 return true; |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) { | 1232 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 visitor->trace(m_context); | 1504 visitor->trace(m_context); |
| 1505 visitor->trace(m_archive); | 1505 visitor->trace(m_archive); |
| 1506 visitor->trace(m_loaders); | 1506 visitor->trace(m_loaders); |
| 1507 visitor->trace(m_nonBlockingLoaders); | 1507 visitor->trace(m_nonBlockingLoaders); |
| 1508 visitor->trace(m_documentResources); | 1508 visitor->trace(m_documentResources); |
| 1509 visitor->trace(m_preloads); | 1509 visitor->trace(m_preloads); |
| 1510 visitor->trace(m_resourceTimingInfoMap); | 1510 visitor->trace(m_resourceTimingInfoMap); |
| 1511 } | 1511 } |
| 1512 | 1512 |
| 1513 } // namespace blink | 1513 } // namespace blink |
| OLD | NEW |