Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2809103002: ur_ls -> urls in ResourceFetcher (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Limit the number of URLs in m_validatedURLs to avoid memory bloat. 298 // Limit the number of URLs in m_validatedURLs to avoid memory bloat.
299 // http://crbug.com/52411 299 // http://crbug.com/52411
300 static const int kMaxValidatedURLsSize = 10000; 300 static const int kMaxValidatedURLsSize = 10000;
301 301
302 void ResourceFetcher::RequestLoadStarted(unsigned long identifier, 302 void ResourceFetcher::RequestLoadStarted(unsigned long identifier,
303 Resource* resource, 303 Resource* resource,
304 const FetchRequest& request, 304 const FetchRequest& request,
305 RevalidationPolicy policy, 305 RevalidationPolicy policy,
306 bool is_static_data) { 306 bool is_static_data) {
307 if (policy == kUse && resource->GetStatus() == ResourceStatus::kCached && 307 if (policy == kUse && resource->GetStatus() == ResourceStatus::kCached &&
308 !validated_ur_ls_.Contains(resource->Url())) { 308 !validated_urls_.Contains(resource->Url())) {
309 // Loaded from MemoryCache. 309 // Loaded from MemoryCache.
310 DidLoadResourceFromMemoryCache(identifier, resource, 310 DidLoadResourceFromMemoryCache(identifier, resource,
311 request.GetResourceRequest()); 311 request.GetResourceRequest());
312 } 312 }
313 313
314 if (is_static_data) 314 if (is_static_data)
315 return; 315 return;
316 316
317 if (policy == kUse && !resource->StillNeedsLoad() && 317 if (policy == kUse && !resource->StillNeedsLoad() &&
318 !validated_ur_ls_.Contains(request.GetResourceRequest().Url())) { 318 !validated_urls_.Contains(request.GetResourceRequest().Url())) {
319 // Resources loaded from memory cache should be reported the first time 319 // Resources loaded from memory cache should be reported the first time
320 // they're used. 320 // they're used.
321 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::Create( 321 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::Create(
322 request.Options().initiator_info.name, MonotonicallyIncreasingTime(), 322 request.Options().initiator_info.name, MonotonicallyIncreasingTime(),
323 resource->GetType() == Resource::kMainResource); 323 resource->GetType() == Resource::kMainResource);
324 PopulateTimingInfo(info.Get(), resource); 324 PopulateTimingInfo(info.Get(), resource);
325 info->ClearLoadTimings(); 325 info->ClearLoadTimings();
326 info->SetLoadFinishTime(info->InitialTime()); 326 info->SetLoadFinishTime(info->InitialTime());
327 scheduled_resource_timing_reports_.push_back(info.Release()); 327 scheduled_resource_timing_reports_.push_back(info.Release());
328 if (!resource_timing_report_timer_.IsActive()) 328 if (!resource_timing_report_timer_.IsActive())
329 resource_timing_report_timer_.StartOneShot(0, BLINK_FROM_HERE); 329 resource_timing_report_timer_.StartOneShot(0, BLINK_FROM_HERE);
330 } 330 }
331 331
332 if (validated_ur_ls_.size() >= kMaxValidatedURLsSize) { 332 if (validated_urls_.size() >= kMaxValidatedURLsSize) {
333 validated_ur_ls_.Clear(); 333 validated_urls_.Clear();
334 } 334 }
335 validated_ur_ls_.insert(request.GetResourceRequest().Url()); 335 validated_urls_.insert(request.GetResourceRequest().Url());
336 } 336 }
337 337
338 void ResourceFetcher::DidLoadResourceFromMemoryCache( 338 void ResourceFetcher::DidLoadResourceFromMemoryCache(
339 unsigned long identifier, 339 unsigned long identifier,
340 Resource* resource, 340 Resource* resource,
341 const ResourceRequest& original_resource_request) { 341 const ResourceRequest& original_resource_request) {
342 ResourceRequest resource_request(resource->Url()); 342 ResourceRequest resource_request(resource->Url());
343 resource_request.SetFrameType(original_resource_request.GetFrameType()); 343 resource_request.SetFrameType(original_resource_request.GetFrameType());
344 resource_request.SetRequestContext( 344 resource_request.SetRequestContext(
345 original_resource_request.GetRequestContext()); 345 original_resource_request.GetRequestContext());
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 return kReload; 961 return kReload;
962 } 962 }
963 963
964 // During the initial load, avoid loading the same resource multiple times for 964 // During the initial load, avoid loading the same resource multiple times for
965 // a single document, even if the cache policies would tell us to. We also 965 // a single document, even if the cache policies would tell us to. We also
966 // group loads of the same resource together. Raw resources are exempted, as 966 // group loads of the same resource together. Raw resources are exempted, as
967 // XHRs fall into this category and may have user-set Cache-Control: headers 967 // XHRs fall into this category and may have user-set Cache-Control: headers
968 // or other factors that require separate requests. 968 // or other factors that require separate requests.
969 if (type != Resource::kRaw) { 969 if (type != Resource::kRaw) {
970 if (!Context().IsLoadComplete() && 970 if (!Context().IsLoadComplete() &&
971 validated_ur_ls_.Contains(existing_resource->Url())) 971 validated_urls_.Contains(existing_resource->Url()))
972 return kUse; 972 return kUse;
973 if (existing_resource->IsLoading()) 973 if (existing_resource->IsLoading())
974 return kUse; 974 return kUse;
975 } 975 }
976 976
977 // WebCachePolicy::BypassingCache always reloads 977 // WebCachePolicy::BypassingCache always reloads
978 if (request.GetCachePolicy() == WebCachePolicy::kBypassingCache) { 978 if (request.GetCachePolicy() == WebCachePolicy::kBypassingCache) {
979 RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy " 979 RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy "
980 "reloading due to " 980 "reloading due to "
981 "WebCachePolicy::BypassingCache."; 981 "WebCachePolicy::BypassingCache.";
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1089
1090 void ResourceFetcher::PreloadStarted(Resource* resource) { 1090 void ResourceFetcher::PreloadStarted(Resource* resource) {
1091 if (preloads_ && preloads_->Contains(resource)) 1091 if (preloads_ && preloads_->Contains(resource))
1092 return; 1092 return;
1093 resource->IncreasePreloadCount(); 1093 resource->IncreasePreloadCount();
1094 1094
1095 if (!preloads_) 1095 if (!preloads_)
1096 preloads_ = new HeapListHashSet<Member<Resource>>; 1096 preloads_ = new HeapListHashSet<Member<Resource>>;
1097 preloads_->insert(resource); 1097 preloads_->insert(resource);
1098 1098
1099 if (preloaded_ur_ls_for_test_) 1099 if (preloaded_urls_for_test_)
1100 preloaded_ur_ls_for_test_->insert(resource->Url().GetString()); 1100 preloaded_urls_for_test_->insert(resource->Url().GetString());
1101 } 1101 }
1102 1102
1103 void ResourceFetcher::EnableIsPreloadedForTest() { 1103 void ResourceFetcher::EnableIsPreloadedForTest() {
1104 if (preloaded_ur_ls_for_test_) 1104 if (preloaded_urls_for_test_)
1105 return; 1105 return;
1106 preloaded_ur_ls_for_test_ = WTF::WrapUnique(new HashSet<String>); 1106 preloaded_urls_for_test_ = WTF::WrapUnique(new HashSet<String>);
1107 1107
1108 if (preloads_) { 1108 if (preloads_) {
1109 for (const auto& resource : *preloads_) 1109 for (const auto& resource : *preloads_)
1110 preloaded_ur_ls_for_test_->insert(resource->Url().GetString()); 1110 preloaded_urls_for_test_->insert(resource->Url().GetString());
1111 } 1111 }
1112 } 1112 }
1113 1113
1114 bool ResourceFetcher::IsPreloadedForTest(const KURL& url) const { 1114 bool ResourceFetcher::IsPreloadedForTest(const KURL& url) const {
1115 DCHECK(preloaded_ur_ls_for_test_); 1115 DCHECK(preloaded_urls_for_test_);
1116 return preloaded_ur_ls_for_test_->Contains(url.GetString()); 1116 return preloaded_urls_for_test_->Contains(url.GetString());
1117 } 1117 }
1118 1118
1119 void ResourceFetcher::ClearPreloads(ClearPreloadsPolicy policy) { 1119 void ResourceFetcher::ClearPreloads(ClearPreloadsPolicy policy) {
1120 if (!preloads_) 1120 if (!preloads_)
1121 return; 1121 return;
1122 1122
1123 LogPreloadStats(policy); 1123 LogPreloadStats(policy);
1124 1124
1125 for (const auto& resource : *preloads_) { 1125 for (const auto& resource : *preloads_) {
1126 if (policy == kClearAllPreloads || !resource->IsLinkPreload()) { 1126 if (policy == kClearAllPreloads || !resource->IsLinkPreload()) {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 visitor->Trace(context_); 1577 visitor->Trace(context_);
1578 visitor->Trace(archive_); 1578 visitor->Trace(archive_);
1579 visitor->Trace(loaders_); 1579 visitor->Trace(loaders_);
1580 visitor->Trace(non_blocking_loaders_); 1580 visitor->Trace(non_blocking_loaders_);
1581 visitor->Trace(document_resources_); 1581 visitor->Trace(document_resources_);
1582 visitor->Trace(preloads_); 1582 visitor->Trace(preloads_);
1583 visitor->Trace(resource_timing_info_map_); 1583 visitor->Trace(resource_timing_info_map_);
1584 } 1584 }
1585 1585
1586 } // namespace blink 1586 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698