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

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

Issue 2484823002: Stop double counting link rel preload preloads for metrics tracking (Closed)
Patch Set: Created 4 years, 1 month 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/core/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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 1066
1067 bool ResourceFetcher::isPreloadedForTest(const KURL& url) const { 1067 bool ResourceFetcher::isPreloadedForTest(const KURL& url) const {
1068 DCHECK(m_preloadedURLsForTest); 1068 DCHECK(m_preloadedURLsForTest);
1069 return m_preloadedURLsForTest->contains(url.getString()); 1069 return m_preloadedURLsForTest->contains(url.getString());
1070 } 1070 }
1071 1071
1072 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) { 1072 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) {
1073 if (!m_preloads) 1073 if (!m_preloads)
1074 return; 1074 return;
1075 1075
1076 logPreloadStats(); 1076 logPreloadStats(policy);
1077 1077
1078 for (const auto& resource : *m_preloads) { 1078 for (const auto& resource : *m_preloads) {
1079 if (policy == ClearAllPreloads || !resource->isLinkPreload()) { 1079 if (policy == ClearAllPreloads || !resource->isLinkPreload()) {
1080 resource->decreasePreloadCount(); 1080 resource->decreasePreloadCount();
1081 if (resource->getPreloadResult() == Resource::PreloadNotReferenced) 1081 if (resource->getPreloadResult() == Resource::PreloadNotReferenced)
1082 memoryCache()->remove(resource.get()); 1082 memoryCache()->remove(resource.get());
1083 m_preloads->remove(resource); 1083 m_preloads->remove(resource);
1084 } 1084 }
1085 } 1085 }
1086 if (!m_preloads->size()) 1086 if (!m_preloads->size())
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 void ResourceFetcher::reloadLoFiImages() { 1428 void ResourceFetcher::reloadLoFiImages() {
1429 for (const auto& documentResource : m_documentResources) { 1429 for (const auto& documentResource : m_documentResources) {
1430 Resource* resource = documentResource.value.get(); 1430 Resource* resource = documentResource.value.get();
1431 if (resource && resource->isImage()) { 1431 if (resource && resource->isImage()) {
1432 ImageResource* imageResource = toImageResource(resource); 1432 ImageResource* imageResource = toImageResource(resource);
1433 imageResource->reloadIfLoFiOrPlaceholder(this); 1433 imageResource->reloadIfLoFiOrPlaceholder(this);
1434 } 1434 }
1435 } 1435 }
1436 } 1436 }
1437 1437
1438 void ResourceFetcher::logPreloadStats() { 1438 void ResourceFetcher::logPreloadStats(ClearPreloadsPolicy policy) {
1439 if (!m_preloads) 1439 if (!m_preloads)
1440 return; 1440 return;
1441 unsigned scripts = 0; 1441 unsigned scripts = 0;
1442 unsigned scriptMisses = 0; 1442 unsigned scriptMisses = 0;
1443 unsigned stylesheets = 0; 1443 unsigned stylesheets = 0;
1444 unsigned stylesheetMisses = 0; 1444 unsigned stylesheetMisses = 0;
1445 unsigned images = 0; 1445 unsigned images = 0;
1446 unsigned imageMisses = 0; 1446 unsigned imageMisses = 0;
1447 unsigned fonts = 0; 1447 unsigned fonts = 0;
1448 unsigned fontMisses = 0; 1448 unsigned fontMisses = 0;
1449 unsigned medias = 0; 1449 unsigned medias = 0;
1450 unsigned mediaMisses = 0; 1450 unsigned mediaMisses = 0;
1451 unsigned textTracks = 0; 1451 unsigned textTracks = 0;
1452 unsigned textTrackMisses = 0; 1452 unsigned textTrackMisses = 0;
1453 unsigned imports = 0; 1453 unsigned imports = 0;
1454 unsigned importMisses = 0; 1454 unsigned importMisses = 0;
1455 unsigned raws = 0; 1455 unsigned raws = 0;
1456 unsigned rawMisses = 0; 1456 unsigned rawMisses = 0;
1457 for (const auto& resource : *m_preloads) { 1457 for (const auto& resource : *m_preloads) {
1458 // Do not double count link rel preloads. These do not get cleared if the
1459 // ClearPreloadsPolicy is only clearing speculative markup preloads.
1460 if (resource->isLinkPreload() && policy == ClearSpeculativeMarkupPreloads) {
1461 continue;
1462 }
1458 int missCount = 1463 int missCount =
1459 resource->getPreloadResult() == Resource::PreloadNotReferenced ? 1 : 0; 1464 resource->getPreloadResult() == Resource::PreloadNotReferenced ? 1 : 0;
1460 switch (resource->getType()) { 1465 switch (resource->getType()) {
1461 case Resource::Image: 1466 case Resource::Image:
1462 images++; 1467 images++;
1463 imageMisses += missCount; 1468 imageMisses += missCount;
1464 break; 1469 break;
1465 case Resource::Script: 1470 case Resource::Script:
1466 scripts++; 1471 scripts++;
1467 scriptMisses += missCount; 1472 scriptMisses += missCount;
(...skipping 19 matching lines...) Expand all
1487 importMisses += missCount; 1492 importMisses += missCount;
1488 break; 1493 break;
1489 case Resource::Raw: 1494 case Resource::Raw:
1490 raws++; 1495 raws++;
1491 rawMisses += missCount; 1496 rawMisses += missCount;
1492 break; 1497 break;
1493 default: 1498 default:
1494 NOTREACHED(); 1499 NOTREACHED();
1495 } 1500 }
1496 } 1501 }
1497 // TODO(csharrison): These can falsely attribute link rel="preload" requests
1498 // as misses if they are referenced after parsing completes. Migrate this
1499 // logic to the memory cache / individual resources to prevent this.
1500 DEFINE_STATIC_LOCAL(CustomCountHistogram, imagePreloads, 1502 DEFINE_STATIC_LOCAL(CustomCountHistogram, imagePreloads,
1501 ("PreloadScanner.Counts2.Image", 0, 100, 25)); 1503 ("PreloadScanner.Counts2.Image", 0, 100, 25));
1502 DEFINE_STATIC_LOCAL(CustomCountHistogram, imagePreloadMisses, 1504 DEFINE_STATIC_LOCAL(CustomCountHistogram, imagePreloadMisses,
1503 ("PreloadScanner.Counts2.Miss.Image", 0, 100, 25)); 1505 ("PreloadScanner.Counts2.Miss.Image", 0, 100, 25));
1504 DEFINE_STATIC_LOCAL(CustomCountHistogram, scriptPreloads, 1506 DEFINE_STATIC_LOCAL(CustomCountHistogram, scriptPreloads,
1505 ("PreloadScanner.Counts2.Script", 0, 100, 25)); 1507 ("PreloadScanner.Counts2.Script", 0, 100, 25));
1506 DEFINE_STATIC_LOCAL(CustomCountHistogram, scriptPreloadMisses, 1508 DEFINE_STATIC_LOCAL(CustomCountHistogram, scriptPreloadMisses,
1507 ("PreloadScanner.Counts2.Miss.Script", 0, 100, 25)); 1509 ("PreloadScanner.Counts2.Miss.Script", 0, 100, 25));
1508 DEFINE_STATIC_LOCAL(CustomCountHistogram, stylesheetPreloads, 1510 DEFINE_STATIC_LOCAL(CustomCountHistogram, stylesheetPreloads,
1509 ("PreloadScanner.Counts2.CSSStyleSheet", 0, 100, 25)); 1511 ("PreloadScanner.Counts2.CSSStyleSheet", 0, 100, 25));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 visitor->trace(m_context); 1621 visitor->trace(m_context);
1620 visitor->trace(m_archive); 1622 visitor->trace(m_archive);
1621 visitor->trace(m_loaders); 1623 visitor->trace(m_loaders);
1622 visitor->trace(m_nonBlockingLoaders); 1624 visitor->trace(m_nonBlockingLoaders);
1623 visitor->trace(m_documentResources); 1625 visitor->trace(m_documentResources);
1624 visitor->trace(m_preloads); 1626 visitor->trace(m_preloads);
1625 visitor->trace(m_resourceTimingInfoMap); 1627 visitor->trace(m_resourceTimingInfoMap);
1626 } 1628 }
1627 1629
1628 } // namespace blink 1630 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698