Chromium Code Reviews| 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 51419319d80b740f2dc74c1b8418f6e27def6c73..429f221fcdee7728ae74e22df00f1b1fa88659f9 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()); |
| } |
| @@ -220,9 +222,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("AffiliationService.FetchSize", |
| + requested_facet_uri_count); |
| + |
| + if (last_request_time_.is_null()) { |
| + base::TimeDelta delay = clock_->Now() - construction_time_; |
| + UMA_HISTOGRAM_CUSTOM_TIMES("AffiliationService.FirstFetchDelay", delay, |
| + base::TimeDelta::FromMicroseconds(1), |
| + base::TimeDelta::FromDays(7), 100); |
|
Ilya Sherman
2015/04/21 00:38:05
Hmm, do you really need such a large range?
engedy
2015/04/21 18:29:07
I need quite a large range, but on second though,
|
| + } else { |
| + base::TimeDelta delay = clock_->Now() - construction_time_; |
| + UMA_HISTOGRAM_CUSTOM_TIMES("AffiliationService.SubsequentFetchDelay", delay, |
| + base::TimeDelta::FromMicroseconds(1), |
| + base::TimeDelta::FromDays(7), 100); |
| + } |
| + last_request_time_ = clock_->Now(); |
| +} |
| + |
| void AffiliationBackend::SetThrottlerForTesting( |
| scoped_ptr<AffiliationFetchThrottler> throttler) { |
| throttler_ = throttler.Pass(); |