Chromium Code Reviews| Index: chrome/browser/chromeos/login/screens/update_screen.cc |
| diff --git a/chrome/browser/chromeos/login/screens/update_screen.cc b/chrome/browser/chromeos/login/screens/update_screen.cc |
| index 96a797ed24a134e20f9afe24d7822205b133bc7b..40712ce5eab1fce6a352b0b60ff3c963aae28e06 100644 |
| --- a/chrome/browser/chromeos/login/screens/update_screen.cc |
| +++ b/chrome/browser/chromeos/login/screens/update_screen.cc |
| @@ -92,6 +92,10 @@ const int kDelayErrorMessageSec = 10; |
| // device periodically during the updating process. |
| const int kHostStatusReportDelay = 5 * 60 * 1000; |
| +// If we check for an update and there is no need to perform an update, |
| +// this is the time in hours we should wait before checking again. |
| +const int kUpdateCheckRecencyThresholdInHours = 1; |
|
xiyuan
2017/05/09 22:03:52
nit: We can move this into where it is used since
kumarniranjan
2017/05/09 22:49:47
Done.
|
| + |
| // Invoked from call to RequestUpdateCheck upon completion of the DBus call. |
| void StartUpdateCallback(UpdateScreen* screen, |
| UpdateEngineClient::UpdateCheckResult result) { |
| @@ -201,6 +205,9 @@ void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { |
| // Noncritical update, just exit screen as if there is no update. |
| // no break |
| case UpdateEngineClient::UPDATE_STATUS_IDLE: |
| + // At this point, there is either no update available, or there is |
| + // a noncritical update available. No need to update during OOBE. |
| + RecordUpdateNotRequired(); |
| Finish(ScreenExitCode::UPDATE_NOUPDATE); |
| break; |
| case UpdateEngineClient::UPDATE_STATUS_ERROR: |
| @@ -552,6 +559,14 @@ void UpdateScreen::StartUpdateCheck() { |
| connect_request_subscription_.reset(); |
| if (state_ == State::STATE_ERROR) |
| HideErrorMessage(); |
| + |
| + if (UsingHandsOffEnrollment() && RecentUpdateCheckWithoutUpdate()) { |
| + LOG(WARNING) << "Skipping update check since one was done recently " |
| + "which did not result in an update."; |
| + CancelUpdate(); |
| + return; |
| + } |
| + |
| state_ = State::STATE_UPDATE; |
| DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this); |
| VLOG(1) << "Initiate update check"; |
| @@ -627,4 +642,14 @@ void UpdateScreen::OnConnectRequested() { |
| } |
| } |
| +void UpdateScreen::RecordUpdateCheckWithoutUpdate() { |
| + StartupUtils::SaveTimeOfLastUpdateCheckWithoutUpdate(base::Time::Now()); |
| +} |
| + |
| +bool UpdateScreen::RecentUpdateCheckWithoutUpdate() { |
| + return (base::Time::Now() - |
|
xiyuan
2017/05/09 22:03:52
Wall clock could go backward. Let's do a compare b
kumarniranjan
2017/05/09 22:49:47
Done.
|
| + StartupUtils::GetTimeOfLastUpdateCheckWithoutUpdate()) > |
|
xiyuan
2017/05/09 22:03:52
GetTimeOfLastUpdateCheckWithoutUpdate() might not
kumarniranjan
2017/05/09 22:49:47
Is adding it to the PrefsRegistry enough? https://
|
| + base::TimeDelta::FromHours(kUpdateCheckRecencyThresholdInHours); |
| +} |
| + |
| } // namespace chromeos |