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

Unified Diff: components/offline_pages/background/request_coordinator.cc

Issue 2431193003: [Offline Pages] Defines longer processing budget for immediate bg loads. (Closed)
Patch Set: Fix merge issue 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 side-by-side diff with in-line comments
Download patch
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 90ab7d27a06643263b55681b5a1c3d4da1e28261..2913fa6e5b26bfdd94c72e333bfccb85db8ffb0e 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -122,7 +122,8 @@ RequestCoordinator::RequestCoordinator(
std::unique_ptr<Scheduler> scheduler,
net::NetworkQualityEstimator::NetworkQualityProvider*
network_quality_estimator)
- : is_busy_(false),
+ : is_low_end_device_(base::SysInfo::IsLowEndDevice()),
+ is_busy_(false),
is_starting_(false),
processing_state_(ProcessingWindowState::STOPPED),
use_test_connection_type_(false),
@@ -466,8 +467,8 @@ RequestCoordinator::TryImmediateStart() {
return OfflinerImmediateStartStatus::BUSY;
// Make sure we are not on svelte device to start immediately.
- // Let the scheduler know we are done processing and failed due to svelte.
- if (base::SysInfo::IsLowEndDevice()) {
+ if (is_low_end_device_) {
+ // Let the scheduler know we are done processing and failed due to svelte.
immediate_schedule_callback_.Run(false);
return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE;
}
@@ -497,13 +498,21 @@ RequestCoordinator::TryImmediateStart() {
}
void RequestCoordinator::TryNextRequest() {
+ base::TimeDelta processing_time_budget;
+ if (processing_state_ == ProcessingWindowState::SCHEDULED_WINDOW) {
+ processing_time_budget = base::TimeDelta::FromSeconds(
+ policy_->GetProcessingTimeBudgetWhenBackgroundScheduledInSeconds());
+ } else {
+ DCHECK(processing_state_ == ProcessingWindowState::IMMEDIATE_WINDOW);
+ processing_time_budget = base::TimeDelta::FromSeconds(
+ policy_->GetProcessingTimeBudgetForImmediateLoadInSeconds());
+ }
+
// If there is no time left in the budget, return to the scheduler.
// We do not remove the pending task that was set up earlier in case
// we run out of time, so the background scheduler will return to us
// at the next opportunity to run background tasks.
- if (base::Time::Now() - operation_start_time_ >
- base::TimeDelta::FromSeconds(
- policy_->GetBackgroundProcessingTimeBudgetSeconds())) {
+ if ((base::Time::Now() - operation_start_time_) > processing_time_budget) {
is_starting_ = false;
// Let the scheduler know we are done processing.

Powered by Google App Engine
This is Rietveld 408576698