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

Side by Side Diff: chrome/browser/chromeos/login/update_screen.cc

Issue 10832009: Additional checks/calls for cases when WebUI may be already gone but OOBE screen instance is not (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix tests Created 8 years, 4 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 unified diff | Download patch
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, 89 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer,
90 UpdateScreenActor* actor) 90 UpdateScreenActor* actor)
91 : WizardScreen(screen_observer), 91 : WizardScreen(screen_observer),
92 reboot_check_delay_(0), 92 reboot_check_delay_(0),
93 is_checking_for_update_(true), 93 is_checking_for_update_(true),
94 is_downloading_update_(false), 94 is_downloading_update_(false),
95 is_ignore_update_deadlines_(false), 95 is_ignore_update_deadlines_(false),
96 is_shown_(false), 96 is_shown_(false),
97 ignore_idle_status_(true), 97 ignore_idle_status_(true),
98 actor_(actor) { 98 actor_(actor) {
99 actor_->SetDelegate(this); 99 DCHECK(actor_);
100 if (actor_)
101 actor_->SetDelegate(this);
100 GetInstanceSet().insert(this); 102 GetInstanceSet().insert(this);
101 } 103 }
102 104
103 UpdateScreen::~UpdateScreen() { 105 UpdateScreen::~UpdateScreen() {
104 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); 106 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
105 GetInstanceSet().erase(this); 107 GetInstanceSet().erase(this);
106 if (actor_) 108 if (actor_)
107 actor_->SetDelegate(NULL); 109 actor_->SetDelegate(NULL);
108 } 110 }
109 111
110 void UpdateScreen::UpdateStatusChanged( 112 void UpdateScreen::UpdateStatusChanged(
111 const UpdateEngineClient::Status& status) { 113 const UpdateEngineClient::Status& status) {
114 if (!actor_)
115 return;
116
112 if (is_checking_for_update_ && 117 if (is_checking_for_update_ &&
113 status.status > UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE) { 118 status.status > UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE) {
114 is_checking_for_update_ = false; 119 is_checking_for_update_ = false;
115 } 120 }
116 if (ignore_idle_status_ && status.status > 121 if (ignore_idle_status_ && status.status >
117 UpdateEngineClient::UPDATE_STATUS_IDLE) { 122 UpdateEngineClient::UPDATE_STATUS_IDLE) {
118 ignore_idle_status_ = false; 123 ignore_idle_status_ = false;
119 } 124 }
120 125
121 switch (status.status) { 126 switch (status.status) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 base::Bind(StartUpdateCallback, this)); 221 base::Bind(StartUpdateCallback, this));
217 } 222 }
218 223
219 void UpdateScreen::CancelUpdate() { 224 void UpdateScreen::CancelUpdate() {
220 VLOG(1) << "Forced update cancel"; 225 VLOG(1) << "Forced update cancel";
221 ExitUpdate(REASON_UPDATE_CANCELED); 226 ExitUpdate(REASON_UPDATE_CANCELED);
222 } 227 }
223 228
224 void UpdateScreen::Show() { 229 void UpdateScreen::Show() {
225 is_shown_ = true; 230 is_shown_ = true;
226 actor_->Show(); 231 if (actor_) {
227 actor_->SetProgress(kBeforeUpdateCheckProgress); 232 actor_->Show();
233 actor_->SetProgress(kBeforeUpdateCheckProgress);
234 }
228 } 235 }
229 236
230 void UpdateScreen::Hide() { 237 void UpdateScreen::Hide() {
231 actor_->Hide(); 238 if (actor_)
239 actor_->Hide();
232 is_shown_ = false; 240 is_shown_ = false;
233 } 241 }
234 242
235 std::string UpdateScreen::GetName() const { 243 std::string UpdateScreen::GetName() const {
236 return WizardController::kUpdateScreenName; 244 return WizardController::kUpdateScreenName;
237 } 245 }
238 246
239 void UpdateScreen::PrepareToShow() { 247 void UpdateScreen::PrepareToShow() {
240 actor_->PrepareToShow(); 248 if (actor_)
249 actor_->PrepareToShow();
241 } 250 }
242 251
243 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { 252 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) {
244 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); 253 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
245 254
246 switch (reason) { 255 switch (reason) {
247 case REASON_UPDATE_CANCELED: 256 case REASON_UPDATE_CANCELED:
248 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); 257 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE);
249 break; 258 break;
250 case REASON_UPDATE_INIT_FAILED: 259 case REASON_UPDATE_INIT_FAILED:
(...skipping 29 matching lines...) Expand all
280 } 289 }
281 break; 290 break;
282 default: 291 default:
283 NOTREACHED(); 292 NOTREACHED();
284 } 293 }
285 } 294 }
286 295
287 void UpdateScreen::OnWaitForRebootTimeElapsed() { 296 void UpdateScreen::OnWaitForRebootTimeElapsed() {
288 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot."; 297 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot.";
289 MakeSureScreenIsShown(); 298 MakeSureScreenIsShown();
290 actor_->ShowManualRebootInfo(); 299 if (actor_)
300 actor_->ShowManualRebootInfo();
291 } 301 }
292 302
293 void UpdateScreen::MakeSureScreenIsShown() { 303 void UpdateScreen::MakeSureScreenIsShown() {
294 if (!is_shown_) 304 if (!is_shown_)
295 get_screen_observer()->ShowCurrentScreen(); 305 get_screen_observer()->ShowCurrentScreen();
296 } 306 }
297 307
298 void UpdateScreen::SetRebootCheckDelay(int seconds) { 308 void UpdateScreen::SetRebootCheckDelay(int seconds) {
299 if (seconds <= 0) 309 if (seconds <= 0)
300 reboot_timer_.Stop(); 310 reboot_timer_.Stop();
301 DCHECK(!reboot_timer_.IsRunning()); 311 DCHECK(!reboot_timer_.IsRunning());
302 reboot_check_delay_ = seconds; 312 reboot_check_delay_ = seconds;
303 } 313 }
304 314
305 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { 315 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) {
306 ignore_idle_status_ = ignore_idle_status; 316 ignore_idle_status_ = ignore_idle_status;
307 } 317 }
308 318
309 void UpdateScreen::UpdateDownloadingStats( 319 void UpdateScreen::UpdateDownloadingStats(
310 const UpdateEngineClient::Status& status) { 320 const UpdateEngineClient::Status& status) {
321 if (!actor_)
322 return;
311 base::Time download_current_time = base::Time::Now(); 323 base::Time download_current_time = base::Time::Now();
312 if (download_current_time >= download_last_time_ + kMinTimeStep && 324 if (download_current_time >= download_last_time_ + kMinTimeStep &&
313 status.download_progress >= 325 status.download_progress >=
314 download_last_progress_ + kMinProgressStep) { 326 download_last_progress_ + kMinProgressStep) {
315 // Estimate downloading rate. 327 // Estimate downloading rate.
316 double progress_delta = 328 double progress_delta =
317 std::max(status.download_progress - download_last_progress_, 0.0); 329 std::max(status.download_progress - download_last_progress_, 0.0);
318 double time_delta = 330 double time_delta =
319 (download_current_time - download_last_time_).InSecondsF(); 331 (download_current_time - download_last_time_).InSecondsF();
320 double download_rate = status.new_size * progress_delta / time_delta; 332 double download_rate = status.new_size * progress_delta / time_delta;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // if the file exists and not empty, there is critical update. 385 // if the file exists and not empty, there is critical update.
374 return true; 386 return true;
375 } 387 }
376 388
377 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { 389 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) {
378 if (actor_ == actor) 390 if (actor_ == actor)
379 actor_ = NULL; 391 actor_ = NULL;
380 } 392 }
381 393
382 } // namespace chromeos 394 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/network_screen_actor.h ('k') | chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698