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

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

Issue 2823843008: Remove unnecessary indirection of ResourceFetcher::preloads_ (Closed)
Patch Set: fix 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
index 1816f8d687c68baf6db35b3566b50c292c224325..a41f49cd29131bfb25ef0f267f1de2173b16e223 100644
--- a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
@@ -482,8 +482,7 @@ void ResourceFetcher::UpdateMemoryCacheStats(Resource* resource,
// dead if MemoryCache holds weak references to Resource). Currently we check
// references to Resource from ResourceClient and |m_preloads| only, because
// they are major sources of references.
- if (resource && !resource->IsAlive() &&
- (!preloads_ || !preloads_->Contains(resource))) {
+ if (resource && !resource->IsAlive() && !preloads_.Contains(resource)) {
DEFINE_RESOURCE_HISTOGRAM("Dead.");
}
}
@@ -1088,13 +1087,11 @@ int ResourceFetcher::NonblockingRequestCount() const {
}
void ResourceFetcher::PreloadStarted(Resource* resource) {
- if (preloads_ && preloads_->Contains(resource))
+ if (preloads_.Contains(resource))
return;
resource->IncreasePreloadCount();
- if (!preloads_)
- preloads_ = new HeapListHashSet<Member<Resource>>;
- preloads_->insert(resource);
+ preloads_.insert(resource);
if (preloaded_urls_for_test_)
preloaded_urls_for_test_->insert(resource->Url().GetString());
@@ -1105,10 +1102,8 @@ void ResourceFetcher::EnableIsPreloadedForTest() {
return;
preloaded_urls_for_test_ = WTF::WrapUnique(new HashSet<String>);
- if (preloads_) {
- for (const auto& resource : *preloads_)
- preloaded_urls_for_test_->insert(resource->Url().GetString());
- }
+ for (const auto& resource : preloads_)
+ preloaded_urls_for_test_->insert(resource->Url().GetString());
}
bool ResourceFetcher::IsPreloadedForTest(const KURL& url) const {
@@ -1117,27 +1112,20 @@ bool ResourceFetcher::IsPreloadedForTest(const KURL& url) const {
}
void ResourceFetcher::ClearPreloads(ClearPreloadsPolicy policy) {
- if (!preloads_)
- return;
-
LogPreloadStats(policy);
- for (const auto& resource : *preloads_) {
+ for (const auto& resource : preloads_) {
if (policy == kClearAllPreloads || !resource->IsLinkPreload()) {
resource->DecreasePreloadCount();
if (resource->GetPreloadResult() == Resource::kPreloadNotReferenced)
GetMemoryCache()->Remove(resource.Get());
- preloads_->erase(resource);
+ preloads_.erase(resource);
}
}
- if (!preloads_->size())
- preloads_.Clear();
}
void ResourceFetcher::WarnUnusedPreloads() {
- if (!preloads_)
- return;
- for (const auto& resource : *preloads_) {
+ for (const auto& resource : preloads_) {
if (resource && resource->IsLinkPreload() &&
resource->GetPreloadResult() == Resource::kPreloadNotReferenced) {
Context().AddConsoleMessage(
@@ -1371,8 +1359,6 @@ void ResourceFetcher::ReloadLoFiImages() {
}
void ResourceFetcher::LogPreloadStats(ClearPreloadsPolicy policy) {
- if (!preloads_)
- return;
unsigned scripts = 0;
unsigned script_misses = 0;
unsigned stylesheets = 0;
@@ -1389,7 +1375,7 @@ void ResourceFetcher::LogPreloadStats(ClearPreloadsPolicy policy) {
unsigned import_misses = 0;
unsigned raws = 0;
unsigned raw_misses = 0;
- for (const auto& resource : *preloads_) {
+ for (const auto& resource : preloads_) {
// Do not double count link rel preloads. These do not get cleared if the
// ClearPreloadsPolicy is only clearing speculative markup preloads.
if (resource->IsLinkPreload() &&
« 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