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

Unified Diff: components/subresource_filter/core/common/url_pattern_index.cc

Issue 2894523006: Add instrumentation hooks to mesaure which subresource filter rules are used.
Patch Set: Created 3 years, 7 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
Index: components/subresource_filter/core/common/url_pattern_index.cc
diff --git a/components/subresource_filter/core/common/url_pattern_index.cc b/components/subresource_filter/core/common/url_pattern_index.cc
index 574f577a32533c1d0811f55d579d152c22f0a3d7..fdab2ede938d62f70f9ebf593fbf0f259177bb4e 100644
--- a/components/subresource_filter/core/common/url_pattern_index.cc
+++ b/components/subresource_filter/core/common/url_pattern_index.cc
@@ -551,7 +551,8 @@ const flat::UrlRule* UrlPatternIndexMatcher::FindMatch(
proto::ElementType element_type,
proto::ActivationType activation_type,
bool is_third_party,
- bool disable_generic_rules) const {
+ bool disable_generic_rules,
+ RuleRecorder* recorder) const {
if (!flat_index_ || !url.is_valid())
return nullptr;
if ((element_type == proto::ELEMENT_TYPE_UNSPECIFIED) ==
@@ -559,9 +560,16 @@ const flat::UrlRule* UrlPatternIndexMatcher::FindMatch(
return nullptr;
}
- return FindMatchInFlatUrlPatternIndex(*flat_index_, url, first_party_origin,
- element_type, activation_type,
- is_third_party, disable_generic_rules);
+ const flat::UrlRule* rule = FindMatchInFlatUrlPatternIndex(
+ *flat_index_, url, first_party_origin, element_type, activation_type,
+ is_third_party, disable_generic_rules);
+
+ // Log the rule if used. We don't care about blacklist or whitelist I assume.
+ // Can we just use url_pattern or are there rules with same pattern
+ // but different options.
+ if (recorder && rule)
+ recorder->RecordRuleUsage(rule);
+ return rule;
}
} // namespace subresource_filter

Powered by Google App Engine
This is Rietveld 408576698