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

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

Issue 2161963002: Add some initial histograms about subresource filtering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sbsf_dsf
Patch Set: Rebase. Created 4 years, 5 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/content/renderer/subresource_filter_agent.cc
diff --git a/components/subresource_filter/content/renderer/subresource_filter_agent.cc b/components/subresource_filter/content/renderer/subresource_filter_agent.cc
index b7b7ccae80c6b3d2058a53825b16d524d7ab75e5..a7c338db2804f23a6c76e0a32271de5ea0bb1f6d 100644
--- a/components/subresource_filter/content/renderer/subresource_filter_agent.cc
+++ b/components/subresource_filter/content/renderer/subresource_filter_agent.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
+#include "base/metrics/histogram_macros.h"
#include "components/subresource_filter/content/common/subresource_filter_messages.h"
#include "components/subresource_filter/content/renderer/document_subresource_filter.h"
#include "components/subresource_filter/content/renderer/ruleset_dealer.h"
@@ -50,17 +51,44 @@ void SubresourceFilterAgent::ActivateForProvisionalLoad(
activation_state_for_provisional_load_ = activation_state;
}
+void SubresourceFilterAgent::RecordHistogramsOnLoadCommitted() {
+ UMA_HISTOGRAM_ENUMERATION(
+ "SubresourceFilter.DocumentLoad.ActivationState",
+ static_cast<int>(activation_state_for_provisional_load_),
+ static_cast<int>(ActivationState::LAST) + 1);
+
+ if (activation_state_for_provisional_load_ != ActivationState::DISABLED) {
+ UMA_HISTOGRAM_BOOLEAN("SubresourceFilter.DocumentLoad.RulesetIsAvailable",
+ !!ruleset_dealer_->ruleset());
+ }
+}
+
+void SubresourceFilterAgent::RecordHistogramsOnLoadFinished() {
+ DCHECK(filter_for_last_committed_load_);
+ UMA_HISTOGRAM_COUNTS_1000(
+ "SubresourceFilter.DocumentLoad.NumSubresourceLoads.Evaluated",
+ filter_for_last_committed_load_->num_loads_evaluated());
+ UMA_HISTOGRAM_COUNTS_1000(
+ "SubresourceFilter.DocumentLoad.NumSubresourceLoads.MatchedRules",
+ filter_for_last_committed_load_->num_loads_matching_rules());
+ UMA_HISTOGRAM_COUNTS_1000(
+ "SubresourceFilter.DocumentLoad.NumSubresourceLoads.Disallowed",
+ filter_for_last_committed_load_->num_loads_disallowed());
+}
+
void SubresourceFilterAgent::OnDestruct() {
delete this;
}
void SubresourceFilterAgent::DidStartProvisionalLoad() {
activation_state_for_provisional_load_ = ActivationState::DISABLED;
+ filter_for_last_committed_load_.reset();
}
void SubresourceFilterAgent::DidCommitProvisionalLoad(
bool is_new_navigation,
bool is_same_page_navigation) {
+ RecordHistogramsOnLoadCommitted();
if (activation_state_for_provisional_load_ != ActivationState::DISABLED &&
ruleset_dealer_->ruleset()) {
std::vector<GURL> ancestor_document_urls = GetAncestorDocumentURLs();
@@ -68,11 +96,19 @@ void SubresourceFilterAgent::DidCommitProvisionalLoad(
new DocumentSubresourceFilter(activation_state_for_provisional_load_,
ruleset_dealer_->ruleset(),
std::move(ancestor_document_urls)));
+ filter_for_last_committed_load_ = filter->AsWeakPtr();
SetSubresourceFilterForCommittedLoad(std::move(filter));
}
activation_state_for_provisional_load_ = ActivationState::DISABLED;
}
+void SubresourceFilterAgent::DidFinishLoad() {
+ if (!filter_for_last_committed_load_)
+ return;
+
+ RecordHistogramsOnLoadFinished();
+}
+
bool SubresourceFilterAgent::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(SubresourceFilterAgent, message)

Powered by Google App Engine
This is Rietveld 408576698