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 2e68e13dadb0e40786bcbae28920bc4293dcf01e..ac3f06348f68c3df50e0caea22c5312f6b9e8384 100644 |
--- a/components/offline_pages/background/request_coordinator.cc |
+++ b/components/offline_pages/background/request_coordinator.cc |
@@ -371,30 +371,44 @@ bool RequestCoordinator::StartProcessing( |
} |
void RequestCoordinator::StartProcessingIfConnected() { |
+ OfflinerImmediateStartStatus immediate_start_status = TryImmediateStart(); |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "OfflinePages.Background.ImmediateStartStatus", |
+ static_cast<int>(immediate_start_status), |
Mark P
2016/10/06 18:54:41
Do you need static_casts here? I've never seen an
dougarnett
2016/10/06 23:05:00
Needed for scoped enums ("enum class"). Switched t
|
+ static_cast<int>( |
+ RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT)); |
+} |
+ |
+RequestCoordinator::OfflinerImmediateStartStatus |
+RequestCoordinator::TryImmediateStart() { |
// Make sure not already busy processing. |
- if (is_busy_) return; |
+ if (is_busy_) |
+ return OfflinerImmediateStartStatus::BUSY; |
// Make sure we are not on svelte device to start immediately. |
- if (base::SysInfo::IsLowEndDevice()) return; |
+ if (base::SysInfo::IsLowEndDevice()) |
+ return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE; |
// Make sure we have reasonable network quality (or at least a connection). |
if (network_quality_estimator_) { |
// TODO(dougarnett): Add UMA for quality type experienced. |
net::EffectiveConnectionType quality = |
network_quality_estimator_->GetEffectiveConnectionType(); |
- if (quality < net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_2G) { |
- return; |
- } |
+ if (quality < net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_2G) |
+ return OfflinerImmediateStartStatus::NO_EFFECTIVE_CONNECTION; |
} else if (GetConnectionType() == |
net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) { |
- return; |
+ return OfflinerImmediateStartStatus::NO_CONNECTION; |
} |
// Start processing with manufactured conservative battery conditions |
// (i.e., assume no battery). |
// TODO(dougarnett): Obtain actual battery conditions (from Android/Java). |
DeviceConditions device_conditions(false, 0, GetConnectionType()); |
- StartProcessing(device_conditions, base::Bind(&EmptySchedulerCallback)); |
+ if (StartProcessing(device_conditions, base::Bind(&EmptySchedulerCallback))) |
+ return OfflinerImmediateStartStatus::STARTED; |
+ else |
+ return OfflinerImmediateStartStatus::NOT_ACCEPTED; |
} |
void RequestCoordinator::TryNextRequest() { |