Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/update_screen.h" | 5 #include "chrome/browser/chromeos/login/update_screen.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 | 43 |
| 44 // Minimum timestep between two consecutive measurements for the | 44 // Minimum timestep between two consecutive measurements for the |
| 45 // download rate. | 45 // download rate. |
| 46 const base::TimeDelta kMinTimeStep = base::TimeDelta::FromSeconds(1); | 46 const base::TimeDelta kMinTimeStep = base::TimeDelta::FromSeconds(1); |
| 47 | 47 |
| 48 // Minimum allowed progress between two consecutive ETAs. | 48 // Minimum allowed progress between two consecutive ETAs. |
| 49 const double kMinProgressStep = 1e-3; | 49 const double kMinProgressStep = 1e-3; |
| 50 | 50 |
| 51 // Smooth factor that is used for the average downloading speed | 51 // Smooth factor that is used for the average downloading speed |
| 52 // estimation. | 52 // estimation. |
| 53 const double kDownloadSpeedSmoothFactor = 0.005; | 53 const double kDownloadSpeedSmoothFactor = 0.1; |
|
Ivan Korotkov
2012/08/24 09:01:36
Please comment what that means.
ygorshenin1
2012/08/27 12:54:16
Done.
| |
| 54 | 54 |
| 55 // Minumum allowed value for the average downloading speed. | 55 // Minumum allowed value for the average downloading speed. |
| 56 const double kDownloadAverageSpeedDropBound = 1e-8; | 56 const double kDownloadAverageSpeedDropBound = 1e-8; |
| 57 | 57 |
| 58 // An upper bound for possible downloading time left estimations. | 58 // An upper bound for possible downloading time left estimations. |
| 59 const double kMaxTimeLeft = 24 * 60 * 60; | 59 const double kMaxTimeLeft = 24 * 60 * 60; |
| 60 | 60 |
| 61 // Invoked from call to RequestUpdateCheck upon completion of the DBus call. | 61 // Invoked from call to RequestUpdateCheck upon completion of the DBus call. |
| 62 void StartUpdateCallback(UpdateScreen* screen, | 62 void StartUpdateCallback(UpdateScreen* screen, |
| 63 UpdateEngineClient::UpdateCheckResult result) { | 63 UpdateEngineClient::UpdateCheckResult result) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 MakeSureScreenIsShown(); | 132 MakeSureScreenIsShown(); |
| 133 actor_->SetProgress(kBeforeDownloadProgress); | 133 actor_->SetProgress(kBeforeDownloadProgress); |
| 134 actor_->ShowEstimatedTimeLeft(false); | 134 actor_->ShowEstimatedTimeLeft(false); |
| 135 if (!HasCriticalUpdate()) { | 135 if (!HasCriticalUpdate()) { |
| 136 LOG(INFO) << "Noncritical update available: " | 136 LOG(INFO) << "Noncritical update available: " |
| 137 << status.new_version; | 137 << status.new_version; |
| 138 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 138 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
| 139 } else { | 139 } else { |
| 140 LOG(INFO) << "Critical update available: " | 140 LOG(INFO) << "Critical update available: " |
| 141 << status.new_version; | 141 << status.new_version; |
| 142 actor_->ShowPreparingUpdatesInfo(true); | 142 actor_->SetProgressMessage( |
| 143 UpdateScreenActor::PROGRESS_MESSAGE_UPDATE_AVAILABLE); | |
| 144 actor_->ShowProgressMessage(true); | |
| 143 actor_->ShowCurtain(false); | 145 actor_->ShowCurtain(false); |
| 144 } | 146 } |
| 145 break; | 147 break; |
| 146 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: | 148 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| 147 { | 149 { |
| 148 MakeSureScreenIsShown(); | 150 MakeSureScreenIsShown(); |
| 149 if (!is_downloading_update_) { | 151 if (!is_downloading_update_) { |
| 150 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE | 152 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE |
| 151 // we need to is update critical on first downloading notification. | 153 // we need to is update critical on first downloading notification. |
| 152 is_downloading_update_ = true; | 154 is_downloading_update_ = true; |
| 153 download_start_time_ = download_last_time_ = base::Time::Now(); | 155 download_start_time_ = download_last_time_ = base::Time::Now(); |
| 154 download_start_progress_ = status.download_progress; | 156 download_start_progress_ = status.download_progress; |
| 155 download_last_progress_ = status.download_progress; | 157 download_last_progress_ = status.download_progress; |
| 156 is_download_average_speed_computed_ = false; | 158 is_download_average_speed_computed_ = false; |
| 157 download_average_speed_ = 0.0; | 159 download_average_speed_ = 0.0; |
| 158 if (!HasCriticalUpdate()) { | 160 if (!HasCriticalUpdate()) { |
| 159 LOG(INFO) << "Non-critical update available: " | 161 LOG(INFO) << "Non-critical update available: " |
| 160 << status.new_version; | 162 << status.new_version; |
| 161 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 163 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
| 162 } else { | 164 } else { |
| 163 LOG(INFO) << "Critical update available: " | 165 LOG(INFO) << "Critical update available: " |
| 164 << status.new_version; | 166 << status.new_version; |
| 165 actor_->ShowPreparingUpdatesInfo(false); | 167 actor_->SetProgressMessage( |
| 168 UpdateScreenActor::PROGRESS_MESSAGE_INSTALLING_UPDATE); | |
| 169 actor_->ShowProgressMessage(true); | |
| 166 actor_->ShowCurtain(false); | 170 actor_->ShowCurtain(false); |
| 167 } | 171 } |
| 168 } | 172 } |
| 169 UpdateDownloadingStats(status); | 173 UpdateDownloadingStats(status); |
| 170 } | 174 } |
| 171 break; | 175 break; |
| 172 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: | 176 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: |
| 173 MakeSureScreenIsShown(); | 177 MakeSureScreenIsShown(); |
| 174 actor_->SetProgress(kBeforeVerifyingProgress); | 178 actor_->SetProgress(kBeforeVerifyingProgress); |
| 175 actor_->ShowEstimatedTimeLeft(false); | 179 actor_->SetProgressMessage(UpdateScreenActor::PROGRESS_MESSAGE_VERIFYING); |
| 180 actor_->ShowProgressMessage(true); | |
| 176 break; | 181 break; |
| 177 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: | 182 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: |
| 178 MakeSureScreenIsShown(); | 183 MakeSureScreenIsShown(); |
| 179 actor_->SetProgress(kBeforeFinalizingProgress); | 184 actor_->SetProgress(kBeforeFinalizingProgress); |
| 180 actor_->ShowEstimatedTimeLeft(false); | 185 actor_->SetProgressMessage( |
| 186 UpdateScreenActor::PROGRESS_MESSAGE_FINALIZING); | |
| 187 actor_->ShowProgressMessage(true); | |
| 181 break; | 188 break; |
| 182 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: | 189 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| 183 MakeSureScreenIsShown(); | 190 MakeSureScreenIsShown(); |
| 184 // Make sure that first OOBE stage won't be shown after reboot. | 191 // Make sure that first OOBE stage won't be shown after reboot. |
| 185 WizardController::MarkOobeCompleted(); | 192 WizardController::MarkOobeCompleted(); |
| 186 actor_->SetProgress(kProgressComplete); | 193 actor_->SetProgress(kProgressComplete); |
| 187 actor_->ShowEstimatedTimeLeft(false); | 194 actor_->ShowEstimatedTimeLeft(false); |
| 188 if (HasCriticalUpdate()) { | 195 if (HasCriticalUpdate()) { |
| 189 actor_->ShowCurtain(false); | 196 actor_->ShowCurtain(false); |
| 190 VLOG(1) << "Initiate reboot after update"; | 197 VLOG(1) << "Initiate reboot after update"; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 | 321 |
| 315 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { | 322 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { |
| 316 ignore_idle_status_ = ignore_idle_status; | 323 ignore_idle_status_ = ignore_idle_status; |
| 317 } | 324 } |
| 318 | 325 |
| 319 void UpdateScreen::UpdateDownloadingStats( | 326 void UpdateScreen::UpdateDownloadingStats( |
| 320 const UpdateEngineClient::Status& status) { | 327 const UpdateEngineClient::Status& status) { |
| 321 if (!actor_) | 328 if (!actor_) |
| 322 return; | 329 return; |
| 323 base::Time download_current_time = base::Time::Now(); | 330 base::Time download_current_time = base::Time::Now(); |
| 324 if (download_current_time >= download_last_time_ + kMinTimeStep && | 331 if (download_current_time >= download_last_time_ + kMinTimeStep) { |
| 325 status.download_progress >= | |
| 326 download_last_progress_ + kMinProgressStep) { | |
| 327 // Estimate downloading rate. | 332 // Estimate downloading rate. |
| 328 double progress_delta = | 333 double progress_delta = |
| 329 std::max(status.download_progress - download_last_progress_, 0.0); | 334 std::max(status.download_progress - download_last_progress_, 0.0); |
| 330 double time_delta = | 335 double time_delta = |
| 331 (download_current_time - download_last_time_).InSecondsF(); | 336 (download_current_time - download_last_time_).InSecondsF(); |
| 332 double download_rate = status.new_size * progress_delta / time_delta; | 337 double download_rate = status.new_size * progress_delta / time_delta; |
| 333 | 338 |
| 334 download_last_time_ = download_current_time; | 339 download_last_time_ = download_current_time; |
| 335 download_last_progress_ = status.download_progress; | 340 download_last_progress_ = status.download_progress; |
| 336 | 341 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 // if the file exists and not empty, there is critical update. | 390 // if the file exists and not empty, there is critical update. |
| 386 return true; | 391 return true; |
| 387 } | 392 } |
| 388 | 393 |
| 389 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { | 394 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { |
| 390 if (actor_ == actor) | 395 if (actor_ == actor) |
| 391 actor_ = NULL; | 396 actor_ = NULL; |
| 392 } | 397 } |
| 393 | 398 |
| 394 } // namespace chromeos | 399 } // namespace chromeos |
| OLD | NEW |