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

Unified Diff: components/subresource_filter/core/common/indexed_ruleset.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/indexed_ruleset.cc
diff --git a/components/subresource_filter/core/common/indexed_ruleset.cc b/components/subresource_filter/core/common/indexed_ruleset.cc
index edbbee88c9d1283af1ac0e1bf198c0d279d39ebc..5f991dc80ea8aa3f72ab6a99586e6564faa1f057 100644
--- a/components/subresource_filter/core/common/indexed_ruleset.cc
+++ b/components/subresource_filter/core/common/indexed_ruleset.cc
@@ -1,3 +1,4 @@
+
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -61,10 +62,17 @@ bool IndexedRulesetMatcher::Verify(const uint8_t* buffer, size_t size) {
}
IndexedRulesetMatcher::IndexedRulesetMatcher(const uint8_t* buffer, size_t size)
+ : IndexedRulesetMatcher(buffer, size, nullptr) {}
+
+IndexedRulesetMatcher::IndexedRulesetMatcher(
+ const uint8_t* buffer,
+ size_t size,
+ std::unique_ptr<RuleRecorder> recorder)
: root_(flat::GetIndexedRuleset(buffer)),
blacklist_(root_->blacklist_index()),
whitelist_(root_->whitelist_index()),
- deactivation_(root_->deactivation_index()) {}
+ deactivation_(root_->deactivation_index()),
+ recorder_(std::move(recorder)) {}
bool IndexedRulesetMatcher::ShouldDisableFilteringForDocument(
const GURL& document_url,
@@ -74,7 +82,7 @@ bool IndexedRulesetMatcher::ShouldDisableFilteringForDocument(
document_url, parent_document_origin, proto::ELEMENT_TYPE_UNSPECIFIED,
activation_type,
FirstPartyOrigin::IsThirdParty(document_url, parent_document_origin),
- false);
+ false, nullptr);
}
bool IndexedRulesetMatcher::ShouldDisallowResourceLoad(
@@ -85,10 +93,12 @@ bool IndexedRulesetMatcher::ShouldDisallowResourceLoad(
const bool is_third_party = first_party.IsThirdParty(url);
return !!blacklist_.FindMatch(url, first_party.origin(), element_type,
proto::ACTIVATION_TYPE_UNSPECIFIED,
- is_third_party, disable_generic_rules) &&
+ is_third_party, disable_generic_rules,
+ recorder_.get()) &&
!whitelist_.FindMatch(url, first_party.origin(), element_type,
proto::ACTIVATION_TYPE_UNSPECIFIED,
- is_third_party, disable_generic_rules);
+ is_third_party, disable_generic_rules,
+ recorder_.get());
}
} // namespace subresource_filter

Powered by Google App Engine
This is Rietveld 408576698