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

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

Issue 2825893003: Remove ResourceFetcher::DeadResourceStatsRecorder (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
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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 if (resource->IsLinkPreload() && !params.IsLinkPreload()) 615 if (resource->IsLinkPreload() && !params.IsLinkPreload())
616 resource->SetLinkPreload(false); 616 resource->SetLinkPreload(false);
617 break; 617 break;
618 } 618 }
619 if (!resource) 619 if (!resource)
620 return nullptr; 620 return nullptr;
621 621
622 // TODO(yoav): turn to a DCHECK. See https://crbug.com/690632 622 // TODO(yoav): turn to a DCHECK. See https://crbug.com/690632
623 CHECK_EQ(resource->GetType(), factory.GetType()); 623 CHECK_EQ(resource->GetType(), factory.GetType());
624 624
625 if (!resource->IsAlive())
626 dead_stats_recorder_.Update(policy);
627
628 if (policy != kUse) 625 if (policy != kUse)
629 resource->SetIdentifier(identifier); 626 resource->SetIdentifier(identifier);
630 627
631 // TODO(yoav): It is not clear why preloads are exempt from this check. Can we 628 // TODO(yoav): It is not clear why preloads are exempt from this check. Can we
632 // remove the exemption? 629 // remove the exemption?
633 if (!params.IsSpeculativePreload() || policy != kUse) { 630 if (!params.IsSpeculativePreload() || policy != kUse) {
634 // When issuing another request for a resource that is already in-flight 631 // When issuing another request for a resource that is already in-flight
635 // make sure to not demote the priority of the in-flight request. If the new 632 // make sure to not demote the priority of the in-flight request. If the new
636 // request isn't at the same priority as the in-flight request, only allow 633 // request isn't at the same priority as the in-flight request, only allow
637 // promotions. This can happen when a visible image's priority is increased 634 // promotions. This can happen when a visible image's priority is increased
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 ResourceRequest resource_request(url); 1526 ResourceRequest resource_request(url);
1530 resource_request.SetRequestContext(request_context); 1527 resource_request.SetRequestContext(request_context);
1531 FetchParameters params(resource_request, initiator_name, resource->Options()); 1528 FetchParameters params(resource_request, initiator_name, resource->Options());
1532 Context().CanRequest(resource->GetType(), resource->LastResourceRequest(), 1529 Context().CanRequest(resource->GetType(), resource->LastResourceRequest(),
1533 resource->LastResourceRequest().Url(), params.Options(), 1530 resource->LastResourceRequest().Url(), params.Options(),
1534 SecurityViolationReportingPolicy::kReport, 1531 SecurityViolationReportingPolicy::kReport,
1535 params.GetOriginRestriction()); 1532 params.GetOriginRestriction());
1536 RequestLoadStarted(resource->Identifier(), resource, params, kUse); 1533 RequestLoadStarted(resource->Identifier(), resource, params, kUse);
1537 } 1534 }
1538 1535
1539 ResourceFetcher::DeadResourceStatsRecorder::DeadResourceStatsRecorder()
1540 : use_count_(0), revalidate_count_(0), load_count_(0) {}
1541
1542 ResourceFetcher::DeadResourceStatsRecorder::~DeadResourceStatsRecorder() {
1543 DEFINE_THREAD_SAFE_STATIC_LOCAL(
1544 CustomCountHistogram, hit_count_histogram,
1545 new CustomCountHistogram("WebCore.ResourceFetcher.HitCount", 0, 1000,
1546 50));
1547 hit_count_histogram.Count(use_count_);
1548 DEFINE_THREAD_SAFE_STATIC_LOCAL(
1549 CustomCountHistogram, revalidate_count_histogram,
1550 new CustomCountHistogram("WebCore.ResourceFetcher.RevalidateCount", 0,
1551 1000, 50));
1552 revalidate_count_histogram.Count(revalidate_count_);
1553 DEFINE_THREAD_SAFE_STATIC_LOCAL(
1554 CustomCountHistogram, load_count_histogram,
1555 new CustomCountHistogram("WebCore.ResourceFetcher.LoadCount", 0, 1000,
1556 50));
1557 load_count_histogram.Count(load_count_);
1558 }
1559
1560 void ResourceFetcher::DeadResourceStatsRecorder::Update(
1561 RevalidationPolicy policy) {
1562 switch (policy) {
1563 case kReload:
1564 case kLoad:
1565 ++load_count_;
1566 return;
1567 case kRevalidate:
1568 ++revalidate_count_;
1569 return;
1570 case kUse:
1571 ++use_count_;
1572 return;
1573 }
1574 }
1575
1576 DEFINE_TRACE(ResourceFetcher) { 1536 DEFINE_TRACE(ResourceFetcher) {
1577 visitor->Trace(context_); 1537 visitor->Trace(context_);
1578 visitor->Trace(archive_); 1538 visitor->Trace(archive_);
1579 visitor->Trace(loaders_); 1539 visitor->Trace(loaders_);
1580 visitor->Trace(non_blocking_loaders_); 1540 visitor->Trace(non_blocking_loaders_);
1581 visitor->Trace(document_resources_); 1541 visitor->Trace(document_resources_);
1582 visitor->Trace(preloads_); 1542 visitor->Trace(preloads_);
1583 visitor->Trace(resource_timing_info_map_); 1543 visitor->Trace(resource_timing_info_map_);
1584 } 1544 }
1585 1545
1586 } // namespace blink 1546 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698