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

Unified Diff: components/password_manager/core/browser/affiliation_backend.cc

Issue 1090163004: Add experiment to exercise AffiliationService with dummy data, plus add related UMA histograms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_copy
Patch Set: Comment phrasing. Created 5 years, 8 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/password_manager/core/browser/affiliation_backend.cc
diff --git a/components/password_manager/core/browser/affiliation_backend.cc b/components/password_manager/core/browser/affiliation_backend.cc
index fe7e31d8bfabf869508c8668dd0324927bc83a63..48301dbf24bca77b18b2b5a67b2d51509f16cfa3 100644
--- a/components/password_manager/core/browser/affiliation_backend.cc
+++ b/components/password_manager/core/browser/affiliation_backend.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/location.h"
+#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "base/time/clock.h"
@@ -30,6 +31,7 @@ AffiliationBackend::AffiliationBackend(
task_runner_(task_runner),
clock_(time_source.Pass()),
tick_clock_(time_tick_source.Pass()),
+ construction_time_(clock_->Now()),
weak_ptr_factory_(this) {
DCHECK_LT(base::Time(), clock_->Now());
}
@@ -225,9 +227,28 @@ bool AffiliationBackend::OnCanSendNetworkRequest() {
fetcher_.reset(AffiliationFetcher::Create(request_context_getter_.get(),
requested_facet_uris, this));
fetcher_->StartRequest();
+ ReportStatistics(requested_facet_uris.size());
return true;
}
+void AffiliationBackend::ReportStatistics(size_t requested_facet_uri_count) {
+ UMA_HISTOGRAM_COUNTS_100("PasswordManager.AffiliationBackend.FetchSize",
+ requested_facet_uri_count);
+
+ if (last_request_time_.is_null()) {
+ base::TimeDelta delay = clock_->Now() - construction_time_;
+ UMA_HISTOGRAM_CUSTOM_TIMES(
+ "PasswordManager.AffiliationBackend.FirstFetchDelay", delay,
+ base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(3), 50);
+ } else {
+ base::TimeDelta delay = clock_->Now() - last_request_time_;
+ UMA_HISTOGRAM_CUSTOM_TIMES(
+ "PasswordManager.AffiliationBackend.SubsequentFetchDelay", delay,
+ base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(3), 50);
+ }
+ last_request_time_ = clock_->Now();
+}
+
void AffiliationBackend::SetThrottlerForTesting(
scoped_ptr<AffiliationFetchThrottler> throttler) {
throttler_ = throttler.Pass();

Powered by Google App Engine
This is Rietveld 408576698