Chromium Code Reviews| Index: components/offline_pages/background/request_coordinator.cc |
| diff --git a/components/offline_pages/background/request_coordinator.cc b/components/offline_pages/background/request_coordinator.cc |
| index cfc32ed6421536e1e1db56baee43602706767d15..c0018998f2a7f70ace5b8f63eade504dcfdf8b94 100644 |
| --- a/components/offline_pages/background/request_coordinator.cc |
| +++ b/components/offline_pages/background/request_coordinator.cc |
| @@ -120,6 +120,23 @@ void RecordAttemptCount(const SavePageRequest& request, |
| } |
| } |
| +// Record the network quality at request creation time per namespace. |
| +void RecordSavePageLaterNetworkQuality( |
| + const ClientId& client_id, |
| + const net::EffectiveConnectionType effective_connection) { |
| + // The histogram below is an expansion of the UMA_HISTOGRAM_ENUMERATION |
| + // macro adapted to allow for a dynamically suffixed histogram name. |
| + // Note: The factory creates and owns the histogram. |
| + base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( |
| + AddHistogramSuffix( |
| + client_id, |
| + "OfflinePages.Background.EffectiveConnectionType.SavePageLater"), |
| + 1, net::EFFECTIVE_CONNECTION_TYPE_LAST - 1, |
| + net::EFFECTIVE_CONNECTION_TYPE_LAST, |
| + base::HistogramBase::kUmaTargetedHistogramFlag); |
| + histogram->Add(effective_connection); |
| +} |
| + |
| // This should use the same algorithm as we use for OfflinePageItem, so the IDs |
| // are similar. |
| int64_t GenerateOfflineId() { |
| @@ -190,6 +207,13 @@ int64_t RequestCoordinator::SavePageLater(const GURL& url, |
| queue_->AddRequest(request, |
| base::Bind(&RequestCoordinator::AddRequestResultCallback, |
| weak_ptr_factory_.GetWeakPtr())); |
| + |
| + // Record the network quality when this request is made. |
| + if (network_quality_estimator_) { |
| + RecordSavePageLaterNetworkQuality( |
| + client_id, network_quality_estimator_->GetEffectiveConnectionType()); |
| + } |
| + |
| return id; |
| } |
| void RequestCoordinator::GetAllRequests(const GetRequestsCallback& callback) { |
| @@ -322,6 +346,17 @@ void RequestCoordinator::RemoveRequests( |
| base::Bind(&RequestCoordinator::HandleRemovedRequestsAndCallback, |
| weak_ptr_factory_.GetWeakPtr(), callback, |
| BackgroundSavePageResult::REMOVED)); |
| + |
| + // Record the network quality when this request is made. |
| + // TODO(dougarnett): Should we update api to pass namespace so we |
| + // can record per namespace? |
| + if (network_quality_estimator_) { |
|
Pete Williamson
2016/11/01 19:58:47
These three added sections are very similar - can
dewittj
2016/11/01 21:52:41
I suspect there won't be much to gain from that, s
|
| + UMA_HISTOGRAM_ENUMERATION( |
| + "OfflinePages.Background.EffectiveConnectionType.RemoveRequests", |
| + network_quality_estimator_->GetEffectiveConnectionType(), |
| + net::EFFECTIVE_CONNECTION_TYPE_LAST); |
| + } |
| + |
| if (canceled) |
| TryNextRequest(); |
| } |
| @@ -334,6 +369,14 @@ void RequestCoordinator::PauseRequests( |
| base::Bind(&RequestCoordinator::UpdateMultipleRequestsCallback, |
| weak_ptr_factory_.GetWeakPtr())); |
| + // Record the network quality when this request is made. |
| + if (network_quality_estimator_) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "OfflinePages.Background.EffectiveConnectionType.PauseRequests", |
| + network_quality_estimator_->GetEffectiveConnectionType(), |
| + net::EFFECTIVE_CONNECTION_TYPE_LAST); |
| + } |
| + |
| if (canceled) |
| TryNextRequest(); |
| } |
| @@ -344,6 +387,15 @@ void RequestCoordinator::ResumeRequests( |
| request_ids, SavePageRequest::RequestState::AVAILABLE, |
| base::Bind(&RequestCoordinator::UpdateMultipleRequestsCallback, |
| weak_ptr_factory_.GetWeakPtr())); |
| + |
| + // Record the network quality when this request is made. |
| + if (network_quality_estimator_) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "OfflinePages.Background.EffectiveConnectionType.ResumeRequests", |
| + network_quality_estimator_->GetEffectiveConnectionType(), |
| + net::EFFECTIVE_CONNECTION_TYPE_LAST); |
| + } |
| + |
| // Schedule a task, in case there is not one scheduled. |
| ScheduleAsNeeded(); |
| } |