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

Side by Side Diff: components/offline_pages/background/request_coordinator.cc

Issue 2388303007: [Offline Pages] Adds UMA for result of attempts to immediately start background loading. (Closed)
Patch Set: Two comment improvements Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 is_stopped_ = false; 365 is_stopped_ = false;
366 scheduler_callback_ = callback; 366 scheduler_callback_ = callback;
367 367
368 TryNextRequest(); 368 TryNextRequest();
369 369
370 return true; 370 return true;
371 } 371 }
372 372
373 void RequestCoordinator::StartProcessingIfConnected() { 373 void RequestCoordinator::StartProcessingIfConnected() {
374 OfflinerImmediateStartStatus immediate_start_status = TryImmediateStart();
375 UMA_HISTOGRAM_ENUMERATION(
376 "OfflinePages.Background.ImmediateStartStatus", immediate_start_status,
377 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT);
378 }
379
380 RequestCoordinator::OfflinerImmediateStartStatus
381 RequestCoordinator::TryImmediateStart() {
374 // Make sure not already busy processing. 382 // Make sure not already busy processing.
375 if (is_busy_) return; 383 if (is_busy_)
384 return OfflinerImmediateStartStatus::BUSY;
376 385
377 // Make sure we are not on svelte device to start immediately. 386 // Make sure we are not on svelte device to start immediately.
378 if (base::SysInfo::IsLowEndDevice()) return; 387 if (base::SysInfo::IsLowEndDevice())
388 return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE;
379 389
380 // Make sure we have reasonable network quality (or at least a connection). 390 // Make sure we have reasonable network quality (or at least a connection).
381 if (network_quality_estimator_) { 391 if (network_quality_estimator_) {
382 // TODO(dougarnett): Add UMA for quality type experienced. 392 // TODO(dougarnett): Add UMA for quality type experienced.
383 net::EffectiveConnectionType quality = 393 net::EffectiveConnectionType quality =
384 network_quality_estimator_->GetEffectiveConnectionType(); 394 network_quality_estimator_->GetEffectiveConnectionType();
385 if (quality < net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_2G) { 395 if (quality < net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_2G)
386 return; 396 return OfflinerImmediateStartStatus::WEAK_CONNECTION;
387 }
388 } else if (GetConnectionType() == 397 } else if (GetConnectionType() ==
389 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) { 398 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) {
390 return; 399 return OfflinerImmediateStartStatus::NO_CONNECTION;
391 } 400 }
392 401
393 // Start processing with manufactured conservative battery conditions 402 // Start processing with manufactured conservative battery conditions
394 // (i.e., assume no battery). 403 // (i.e., assume no battery).
395 // TODO(dougarnett): Obtain actual battery conditions (from Android/Java). 404 // TODO(dougarnett): Obtain actual battery conditions (from Android/Java).
396 DeviceConditions device_conditions(false, 0, GetConnectionType()); 405 DeviceConditions device_conditions(false, 0, GetConnectionType());
397 StartProcessing(device_conditions, base::Bind(&EmptySchedulerCallback)); 406 if (StartProcessing(device_conditions, base::Bind(&EmptySchedulerCallback)))
407 return OfflinerImmediateStartStatus::STARTED;
408 else
409 return OfflinerImmediateStartStatus::NOT_ACCEPTED;
398 } 410 }
399 411
400 void RequestCoordinator::TryNextRequest() { 412 void RequestCoordinator::TryNextRequest() {
401 // If there is no time left in the budget, return to the scheduler. 413 // If there is no time left in the budget, return to the scheduler.
402 // We do not remove the pending task that was set up earlier in case 414 // We do not remove the pending task that was set up earlier in case
403 // we run out of time, so the background scheduler will return to us 415 // we run out of time, so the background scheduler will return to us
404 // at the next opportunity to run background tasks. 416 // at the next opportunity to run background tasks.
405 if (base::Time::Now() - operation_start_time_ > 417 if (base::Time::Now() - operation_start_time_ >
406 base::TimeDelta::FromSeconds( 418 base::TimeDelta::FromSeconds(
407 policy_->GetBackgroundProcessingTimeBudgetSeconds())) { 419 policy_->GetBackgroundProcessingTimeBudgetSeconds())) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 611
600 ClientPolicyController* RequestCoordinator::GetPolicyController() { 612 ClientPolicyController* RequestCoordinator::GetPolicyController() {
601 return policy_controller_.get(); 613 return policy_controller_.get();
602 } 614 }
603 615
604 void RequestCoordinator::Shutdown() { 616 void RequestCoordinator::Shutdown() {
605 network_quality_estimator_ = nullptr; 617 network_quality_estimator_ = nullptr;
606 } 618 }
607 619
608 } // namespace offline_pages 620 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/request_coordinator.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698