diff options
| author | rajendrant <rajendrant@chromium.org> | 2016-01-15 17:09:44 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-01-16 01:10:35 +0000 |
| commit | b582452daa579977cb9200d398d53b4de8cc4ae5 (patch) | |
| tree | 7a166166685b6681fc473b2cef66f60a95d0547e /chrome/browser/android/data_usage/data_use_matcher.cc | |
| parent | 88105b63e6a1f3f9610d7fc21ae1979201d32562 (diff) | |
| download | chromium_src-b582452daa579977cb9200d398d53b4de8cc4ae5.zip chromium_src-b582452daa579977cb9200d398d53b4de8cc4ae5.tar.gz chromium_src-b582452daa579977cb9200d398d53b4de8cc4ae5.tar.bz2 | |
Add histograms for data usage
The following UMA are added:
DataUsage.MatchingRulesCount.Valid
DataUsage.MatchingRulesCount.Invalid
- The number of valid and invalid matching rules fetched.
DataUsage.Perf.URLRegexMatchDuration
- Time taken for a regular expression to process an URL.
DataUsage.Perf.ReportSubmissionDuration
- Time taken for submitting the data use reports.
DataUsage.Perf.MatchingRuleFetchDuration
- Time taken for fetching the matching rules.
BUG=574880
Review URL: https://codereview.chromium.org/1582043002
Cr-Commit-Position: refs/heads/master@{#369900}
Diffstat (limited to 'chrome/browser/android/data_usage/data_use_matcher.cc')
| -rw-r--r-- | chrome/browser/android/data_usage/data_use_matcher.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/chrome/browser/android/data_usage/data_use_matcher.cc b/chrome/browser/android/data_usage/data_use_matcher.cc index 8959c64..21e435c 100644 --- a/chrome/browser/android/data_usage/data_use_matcher.cc +++ b/chrome/browser/android/data_usage/data_use_matcher.cc @@ -10,9 +10,11 @@ #include <utility> #include "base/memory/weak_ptr.h" +#include "base/metrics/histogram_macros.h" #include "base/strings/string_number_conversions.h" #include "base/time/default_tick_clock.h" #include "base/time/tick_clock.h" +#include "base/time/time.h" #include "chrome/browser/android/data_usage/external_data_use_observer.h" #include "third_party/re2/src/re2/re2.h" #include "url/gurl.h" @@ -46,6 +48,7 @@ void DataUseMatcher::RegisterURLRegexes( DCHECK_EQ(app_package_names.size(), labels.size()); base::hash_set<std::string> removed_matching_rule_labels; + uint32_t invalid_rules = 0; for (const auto& matching_rule : matching_rules_) removed_matching_rule_labels.insert(matching_rule->label()); @@ -61,11 +64,15 @@ void DataUseMatcher::RegisterURLRegexes( const base::TimeTicks now_ticks = tick_clock_->NowTicks(); ParsePackageField(app_package_names.at(i), &app_package_name, &expiration); - if (url_regex.empty() && app_package_name.empty()) + if (url_regex.empty() && app_package_name.empty()) { + invalid_rules++; continue; + } scoped_ptr<re2::RE2> pattern(new re2::RE2(url_regex, options)); - if (!pattern->ok()) + if (!pattern->ok()) { + invalid_rules++; continue; + } if (expiration <= now_ticks) continue; // skip expired matching rules. @@ -80,6 +87,11 @@ void DataUseMatcher::RegisterURLRegexes( if (data_use_tab_model_) data_use_tab_model_->OnTrackingLabelRemoved(label); } + UMA_HISTOGRAM_COUNTS_100("DataUsage.MatchingRulesCount.Valid", + matching_rules_.size()); + UMA_HISTOGRAM_COUNTS_100("DataUsage.MatchingRulesCount.Invalid", + invalid_rules); + DCHECK(io_task_runner_); // Notify |external_data_use_observer_| if it should register as a data use @@ -101,7 +113,11 @@ bool DataUseMatcher::MatchesURL(const GURL& url, std::string* label) const { for (const auto& matching_rule : matching_rules_) { if (matching_rule->expiration() <= now_ticks) continue; // skip expired matching rules. - if (re2::RE2::FullMatch(url.spec(), *(matching_rule->pattern()))) { + base::TimeTicks begin = base::TimeTicks::Now(); + bool match = re2::RE2::FullMatch(url.spec(), *(matching_rule->pattern())); + UMA_HISTOGRAM_TIMES("DataUsage.Perf.URLRegexMatchDuration", + base::TimeTicks::Now() - begin); + if (match) { *label = matching_rule->label(); return true; } |
