| Index: chrome/browser/chromeos/policy/system_log_uploader.cc
|
| diff --git a/chrome/browser/chromeos/policy/system_log_uploader.cc b/chrome/browser/chromeos/policy/system_log_uploader.cc
|
| index fce6ed186bb2d712d07869f4996b1ba092029b07..b6db86fb885c9afbe334af616d14b83cd967c6c0 100644
|
| --- a/chrome/browser/chromeos/policy/system_log_uploader.cc
|
| +++ b/chrome/browser/chromeos/policy/system_log_uploader.cc
|
| @@ -2,6 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "chrome/browser/chromeos/policy/system_log_uploader.h"
|
| +
|
| +#include <map>
|
| #include <utility>
|
|
|
| #include "base/bind.h"
|
| @@ -22,7 +25,6 @@
|
| #include "components/feedback/anonymizer_tool.h"
|
| #include "components/policy/core/browser/browser_policy_connector.h"
|
| #include "net/http/http_request_headers.h"
|
| -#include "system_log_uploader.h"
|
|
|
| namespace {
|
| // The maximum number of successive retries.
|
| @@ -200,6 +202,7 @@ void SystemLogUploader::OnSuccess() {
|
| SYSLOG(INFO) << "Upload successful.";
|
| upload_job_.reset();
|
| last_upload_attempt_ = base::Time::NowFromSystemTime();
|
| + log_upload_in_progress_ = false;
|
| retry_count_ = 0;
|
|
|
| // On successful log upload schedule the next log upload after
|
| @@ -210,6 +213,7 @@ void SystemLogUploader::OnSuccess() {
|
| void SystemLogUploader::OnFailure(UploadJob::ErrorCode error_code) {
|
| upload_job_.reset();
|
| last_upload_attempt_ = base::Time::NowFromSystemTime();
|
| + log_upload_in_progress_ = false;
|
|
|
| // If we have hit the maximum number of retries, terminate this upload
|
| // attempt and schedule the next one using the normal delay. Otherwise, retry
|
| @@ -235,6 +239,10 @@ std::string SystemLogUploader::RemoveSensitiveData(
|
| return anonymizer->Anonymize(data);
|
| }
|
|
|
| +void SystemLogUploader::ScheduleNextSystemLogUploadImmediately() {
|
| + ScheduleNextSystemLogUpload(base::TimeDelta());
|
| +}
|
| +
|
| void SystemLogUploader::RefreshUploadSettings() {
|
| // Attempt to fetch the current value of the reporting settings.
|
| // If trusted values are not available, register this function to be called
|
| @@ -289,10 +297,12 @@ void SystemLogUploader::StartLogUpload() {
|
|
|
| if (upload_enabled_) {
|
| SYSLOG(INFO) << "Starting system log upload.";
|
| + log_upload_in_progress_ = true;
|
| syslog_delegate_->LoadSystemLogs(base::Bind(
|
| &SystemLogUploader::UploadSystemLogs, weak_factory_.GetWeakPtr()));
|
| } else {
|
| // If upload is disabled, schedule the next attempt after 12h.
|
| + SYSLOG(INFO) << "System log upload is disabled, rescheduling.";
|
| retry_count_ = 0;
|
| last_upload_attempt_ = base::Time::NowFromSystemTime();
|
| ScheduleNextSystemLogUpload(upload_frequency_);
|
| @@ -300,6 +310,11 @@ void SystemLogUploader::StartLogUpload() {
|
| }
|
|
|
| void SystemLogUploader::ScheduleNextSystemLogUpload(base::TimeDelta frequency) {
|
| + // Don't schedule a new system log upload if there's a log upload in progress
|
| + // (it will be scheduled once the current one completes).
|
| + if (log_upload_in_progress_)
|
| + return;
|
| +
|
| // Calculate when to fire off the next update.
|
| base::TimeDelta delay = std::max(
|
| (last_upload_attempt_ + frequency) - base::Time::NowFromSystemTime(),
|
|
|