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 // avg_speed = smooth_factor * cur_speed + (1.0 - smooth_factor) * avg_speed. |
| 54 const double kDownloadSpeedSmoothFactor = 0.1; |
54 | 55 |
55 // Minumum allowed value for the average downloading speed. | 56 // Minumum allowed value for the average downloading speed. |
56 const double kDownloadAverageSpeedDropBound = 1e-8; | 57 const double kDownloadAverageSpeedDropBound = 1e-8; |
57 | 58 |
58 // An upper bound for possible downloading time left estimations. | 59 // An upper bound for possible downloading time left estimations. |
59 const double kMaxTimeLeft = 24 * 60 * 60; | 60 const double kMaxTimeLeft = 24 * 60 * 60; |
60 | 61 |
61 // Invoked from call to RequestUpdateCheck upon completion of the DBus call. | 62 // Invoked from call to RequestUpdateCheck upon completion of the DBus call. |
62 void StartUpdateCallback(UpdateScreen* screen, | 63 void StartUpdateCallback(UpdateScreen* screen, |
63 UpdateEngineClient::UpdateCheckResult result) { | 64 UpdateEngineClient::UpdateCheckResult result) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 MakeSureScreenIsShown(); | 133 MakeSureScreenIsShown(); |
133 actor_->SetProgress(kBeforeDownloadProgress); | 134 actor_->SetProgress(kBeforeDownloadProgress); |
134 actor_->ShowEstimatedTimeLeft(false); | 135 actor_->ShowEstimatedTimeLeft(false); |
135 if (!HasCriticalUpdate()) { | 136 if (!HasCriticalUpdate()) { |
136 LOG(INFO) << "Noncritical update available: " | 137 LOG(INFO) << "Noncritical update available: " |
137 << status.new_version; | 138 << status.new_version; |
138 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 139 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
139 } else { | 140 } else { |
140 LOG(INFO) << "Critical update available: " | 141 LOG(INFO) << "Critical update available: " |
141 << status.new_version; | 142 << status.new_version; |
142 actor_->ShowPreparingUpdatesInfo(true); | 143 actor_->SetProgressMessage( |
| 144 UpdateScreenActor::PROGRESS_MESSAGE_UPDATE_AVAILABLE); |
| 145 actor_->ShowProgressMessage(true); |
143 actor_->ShowCurtain(false); | 146 actor_->ShowCurtain(false); |
144 } | 147 } |
145 break; | 148 break; |
146 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: | 149 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
147 { | 150 { |
148 MakeSureScreenIsShown(); | 151 MakeSureScreenIsShown(); |
149 if (!is_downloading_update_) { | 152 if (!is_downloading_update_) { |
150 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE | 153 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE |
151 // we need to is update critical on first downloading notification. | 154 // we need to is update critical on first downloading notification. |
152 is_downloading_update_ = true; | 155 is_downloading_update_ = true; |
153 download_start_time_ = download_last_time_ = base::Time::Now(); | 156 download_start_time_ = download_last_time_ = base::Time::Now(); |
154 download_start_progress_ = status.download_progress; | 157 download_start_progress_ = status.download_progress; |
155 download_last_progress_ = status.download_progress; | 158 download_last_progress_ = status.download_progress; |
156 is_download_average_speed_computed_ = false; | 159 is_download_average_speed_computed_ = false; |
157 download_average_speed_ = 0.0; | 160 download_average_speed_ = 0.0; |
158 if (!HasCriticalUpdate()) { | 161 if (!HasCriticalUpdate()) { |
159 LOG(INFO) << "Non-critical update available: " | 162 LOG(INFO) << "Non-critical update available: " |
160 << status.new_version; | 163 << status.new_version; |
161 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 164 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
162 } else { | 165 } else { |
163 LOG(INFO) << "Critical update available: " | 166 LOG(INFO) << "Critical update available: " |
164 << status.new_version; | 167 << status.new_version; |
165 actor_->ShowPreparingUpdatesInfo(false); | 168 actor_->SetProgressMessage( |
| 169 UpdateScreenActor::PROGRESS_MESSAGE_INSTALLING_UPDATE); |
| 170 actor_->ShowProgressMessage(true); |
166 actor_->ShowCurtain(false); | 171 actor_->ShowCurtain(false); |
167 } | 172 } |
168 } | 173 } |
169 UpdateDownloadingStats(status); | 174 UpdateDownloadingStats(status); |
170 } | 175 } |
171 break; | 176 break; |
172 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: | 177 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: |
173 MakeSureScreenIsShown(); | 178 MakeSureScreenIsShown(); |
174 actor_->SetProgress(kBeforeVerifyingProgress); | 179 actor_->SetProgress(kBeforeVerifyingProgress); |
175 actor_->ShowEstimatedTimeLeft(false); | 180 actor_->SetProgressMessage(UpdateScreenActor::PROGRESS_MESSAGE_VERIFYING); |
| 181 actor_->ShowProgressMessage(true); |
176 break; | 182 break; |
177 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: | 183 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: |
178 MakeSureScreenIsShown(); | 184 MakeSureScreenIsShown(); |
179 actor_->SetProgress(kBeforeFinalizingProgress); | 185 actor_->SetProgress(kBeforeFinalizingProgress); |
180 actor_->ShowEstimatedTimeLeft(false); | 186 actor_->SetProgressMessage( |
| 187 UpdateScreenActor::PROGRESS_MESSAGE_FINALIZING); |
| 188 actor_->ShowProgressMessage(true); |
181 break; | 189 break; |
182 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: | 190 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
183 MakeSureScreenIsShown(); | 191 MakeSureScreenIsShown(); |
184 // Make sure that first OOBE stage won't be shown after reboot. | 192 // Make sure that first OOBE stage won't be shown after reboot. |
185 WizardController::MarkOobeCompleted(); | 193 WizardController::MarkOobeCompleted(); |
186 actor_->SetProgress(kProgressComplete); | 194 actor_->SetProgress(kProgressComplete); |
187 actor_->ShowEstimatedTimeLeft(false); | 195 actor_->ShowEstimatedTimeLeft(false); |
188 if (HasCriticalUpdate()) { | 196 if (HasCriticalUpdate()) { |
189 actor_->ShowCurtain(false); | 197 actor_->ShowCurtain(false); |
190 VLOG(1) << "Initiate reboot after update"; | 198 VLOG(1) << "Initiate reboot after update"; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 322 |
315 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { | 323 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { |
316 ignore_idle_status_ = ignore_idle_status; | 324 ignore_idle_status_ = ignore_idle_status; |
317 } | 325 } |
318 | 326 |
319 void UpdateScreen::UpdateDownloadingStats( | 327 void UpdateScreen::UpdateDownloadingStats( |
320 const UpdateEngineClient::Status& status) { | 328 const UpdateEngineClient::Status& status) { |
321 if (!actor_) | 329 if (!actor_) |
322 return; | 330 return; |
323 base::Time download_current_time = base::Time::Now(); | 331 base::Time download_current_time = base::Time::Now(); |
324 if (download_current_time >= download_last_time_ + kMinTimeStep && | 332 if (download_current_time >= download_last_time_ + kMinTimeStep) { |
325 status.download_progress >= | |
326 download_last_progress_ + kMinProgressStep) { | |
327 // Estimate downloading rate. | 333 // Estimate downloading rate. |
328 double progress_delta = | 334 double progress_delta = |
329 std::max(status.download_progress - download_last_progress_, 0.0); | 335 std::max(status.download_progress - download_last_progress_, 0.0); |
330 double time_delta = | 336 double time_delta = |
331 (download_current_time - download_last_time_).InSecondsF(); | 337 (download_current_time - download_last_time_).InSecondsF(); |
332 double download_rate = status.new_size * progress_delta / time_delta; | 338 double download_rate = status.new_size * progress_delta / time_delta; |
333 | 339 |
334 download_last_time_ = download_current_time; | 340 download_last_time_ = download_current_time; |
335 download_last_progress_ = status.download_progress; | 341 download_last_progress_ = status.download_progress; |
336 | 342 |
(...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. | 391 // if the file exists and not empty, there is critical update. |
386 return true; | 392 return true; |
387 } | 393 } |
388 | 394 |
389 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { | 395 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { |
390 if (actor_ == actor) | 396 if (actor_ == actor) |
391 actor_ = NULL; | 397 actor_ = NULL; |
392 } | 398 } |
393 | 399 |
394 } // namespace chromeos | 400 } // namespace chromeos |
OLD | NEW |