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

Unified Diff: chrome/browser/chromeos/policy/status_uploader.cc

Issue 1963703002: Add delay when scheduling next status upload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change tests to match the new behavior Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/status_uploader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/policy/status_uploader.cc
diff --git a/chrome/browser/chromeos/policy/status_uploader.cc b/chrome/browser/chromeos/policy/status_uploader.cc
index 83f7cc9740d22ee25100f49a9e849320fbdb4c0b..a24ff1fb4dddc6269f4d14be1b8a9c9200ffa388 100644
--- a/chrome/browser/chromeos/policy/status_uploader.cc
+++ b/chrome/browser/chromeos/policy/status_uploader.cc
@@ -23,7 +23,10 @@
#include "ui/base/user_activity/user_activity_detector.h"
namespace {
+// Minimum delay between two consecutive uploads
const int kMinUploadDelayMs = 60 * 1000; // 60 seconds
+// Minimum delay after scheduling an upload
+const int kMinUploadScheduleDelayMs = 60 * 1000; // 60 seconds
} // namespace
namespace policy {
@@ -67,9 +70,9 @@ StatusUploader::StatusUploader(
// Update the upload frequency from settings.
RefreshUploadFrequency();
- // Immediately schedule our next status upload (last_upload_ is set to the
- // start of the epoch, so this will trigger an update in the immediate
- // future).
+ // Schedule our next status upload in a minute (last_upload_ is set to the
+ // start of the epoch, so this will trigger an update in
+ // kMinUploadScheduleDelayMs from now).
ScheduleNextStatusUpload();
}
@@ -79,10 +82,10 @@ StatusUploader::~StatusUploader() {
void StatusUploader::ScheduleNextStatusUpload() {
// Calculate when to fire off the next update (if it should have already
- // happened, this yields a TimeDelta of 0).
+ // happened, this yields a TimeDelta of kMinUploadScheduleDelayMs).
base::TimeDelta delay = std::max(
(last_upload_ + upload_frequency_) - base::Time::NowFromSystemTime(),
- base::TimeDelta());
+ base::TimeDelta::FromMilliseconds(kMinUploadScheduleDelayMs));
upload_callback_.Reset(base::Bind(&StatusUploader::UploadStatus,
base::Unretained(this)));
task_runner_->PostDelayedTask(FROM_HERE, upload_callback_.callback(), delay);
@@ -113,7 +116,8 @@ void StatusUploader::RefreshUploadFrequency() {
// Schedule a new upload with the new frequency - only do this if we've
// already performed the initial upload, because we want the initial upload
- // to happen immediately on startup and not get cancelled by settings changes.
+ // to happen in a minute after startup and not get cancelled by settings
+ // changes.
if (!last_upload_.is_null())
ScheduleNextStatusUpload();
}
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/status_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698