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

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

Issue 2431193003: [Offline Pages] Defines longer processing budget for immediate bg loads. (Closed)
Patch Set: Fixes tests wrt setting processing state 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 81d90f15620fc27f6a2dd8abcafe48623e2aa976..71070cbf8a25f05f87276125abb20d2953ba1557 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),
@@ -447,7 +448,7 @@ RequestCoordinator::TryImmediateStart() {
return OfflinerImmediateStartStatus::BUSY;
// Make sure we are not on svelte device to start immediately.
- if (base::SysInfo::IsLowEndDevice())
+ if (is_low_end_device_)
return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE;
// Make sure we have reasonable network quality (or at least a connection).
@@ -475,13 +476,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