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

Unified Diff: components/subresource_filter/content/renderer/document_subresource_filter.cc

Issue 2556433003: Support optional performance measuring in SubresourceFilter. (Closed)
Patch Set: Link TODO to a bug. Created 4 years 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
Index: components/subresource_filter/content/renderer/document_subresource_filter.cc
diff --git a/components/subresource_filter/content/renderer/document_subresource_filter.cc b/components/subresource_filter/content/renderer/document_subresource_filter.cc
index dadb24c3eb063e95ca597d46d32036f4f6b9c70b..12afb7daf2acfa896b5607425d342dc28440250d 100644
--- a/components/subresource_filter/content/renderer/document_subresource_filter.cc
+++ b/components/subresource_filter/content/renderer/document_subresource_filter.cc
@@ -77,10 +77,12 @@ proto::ElementType ToElementType(
DocumentSubresourceFilter::DocumentSubresourceFilter(
ActivationState activation_state,
+ bool measure_performance,
const scoped_refptr<const MemoryMappedRuleset>& ruleset,
const std::vector<GURL>& ancestor_document_urls,
const base::Closure& first_disallowed_load_callback)
: activation_state_(activation_state),
+ measure_performance_(measure_performance),
ruleset_(ruleset),
ruleset_matcher_(ruleset_->data(), ruleset_->length()),
first_disallowed_load_callback_(first_disallowed_load_callback) {
@@ -132,13 +134,14 @@ bool DocumentSubresourceFilter::allowLoad(
resourceUrl.string().utf8());
auto wall_duration_timer = ScopedTimers::StartIf(
- ScopedThreadTimers::IsSupported(), [this](base::TimeDelta delta) {
+ measure_performance_ && ScopedThreadTimers::IsSupported(),
+ [this](base::TimeDelta delta) {
statistics_.evaluation_total_wall_duration += delta;
UMA_HISTOGRAM_MICRO_TIMES(
"SubresourceFilter.SubresourceLoad.Evaluation.WallDuration", delta);
});
- auto cpu_duration_timer =
- ScopedThreadTimers::Start([this](base::TimeDelta delta) {
+ auto cpu_duration_timer = ScopedThreadTimers::StartIf(
+ measure_performance_, [this](base::TimeDelta delta) {
statistics_.evaluation_total_cpu_duration += delta;
UMA_HISTOGRAM_MICRO_TIMES(
"SubresourceFilter.SubresourceLoad.Evaluation.CPUDuration", delta);

Powered by Google App Engine
This is Rietveld 408576698