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

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

Issue 7057055: Show progress bar as soon as update state changed to UPDATE_STATUS_UPDATE_AVAILABLE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed test Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return instance_set; 57 return instance_set;
58 } 58 }
59 59
60 // static 60 // static
61 bool UpdateScreen::HasInstance(UpdateScreen* inst) { 61 bool UpdateScreen::HasInstance(UpdateScreen* inst) {
62 InstanceSet& instance_set = GetInstanceSet(); 62 InstanceSet& instance_set = GetInstanceSet();
63 InstanceSet::iterator found = instance_set.find(inst); 63 InstanceSet::iterator found = instance_set.find(inst);
64 return (found != instance_set.end()); 64 return (found != instance_set.end());
65 } 65 }
66 66
67
68 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, 67 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer,
69 UpdateScreenActor* actor) 68 UpdateScreenActor* actor)
70 : WizardScreen(screen_observer), 69 : WizardScreen(screen_observer),
71 reboot_check_delay_(0), 70 reboot_check_delay_(0),
72 is_checking_for_update_(true), 71 is_checking_for_update_(true),
73 is_downloading_update_(false), 72 is_downloading_update_(false),
74 is_ignore_update_deadlines_(false), 73 is_ignore_update_deadlines_(false),
75 is_shown_(false), 74 is_shown_(false),
75 ignore_idle_status_(true),
76 actor_(actor) { 76 actor_(actor) {
77 GetInstanceSet().insert(this); 77 GetInstanceSet().insert(this);
78 } 78 }
79 79
80 UpdateScreen::~UpdateScreen() { 80 UpdateScreen::~UpdateScreen() {
81 CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); 81 CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this);
82 GetInstanceSet().erase(this); 82 GetInstanceSet().erase(this);
83 } 83 }
84 84
85 void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { 85 void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) {
86 UpdateStatusOperation status = library->status().status; 86 UpdateStatusOperation status = library->status().status;
87 if (is_checking_for_update_ && status > UPDATE_STATUS_CHECKING_FOR_UPDATE) { 87 if (is_checking_for_update_ && status > UPDATE_STATUS_CHECKING_FOR_UPDATE) {
88 is_checking_for_update_ = false; 88 is_checking_for_update_ = false;
89 } 89 }
90 if (ignore_idle_status_ && status > UPDATE_STATUS_IDLE) {
Nikita (slow) 2011/06/07 15:31:03 This approach feels a bit dangerous because it rel
Dmitry Polukhin 2011/06/08 07:24:21 My approach assumes that status other than IDLE wi
petkov 2011/06/08 18:29:00 You could use update_engine's GetStatus D-Bus meth
Dmitry Polukhin 2011/06/09 12:51:32 Is it guaranteed that update engine will not delay
petkov 2011/06/09 13:24:20 That's right. As long as the status is IDLE when t
91 ignore_idle_status_ = false;
92 }
90 93
91 switch (status) { 94 switch (status) {
92 case UPDATE_STATUS_CHECKING_FOR_UPDATE: 95 case UPDATE_STATUS_CHECKING_FOR_UPDATE:
93 // Do nothing in these cases, we don't want to notify the user of the 96 // Do nothing in these cases, we don't want to notify the user of the
94 // check unless there is an update. 97 // check unless there is an update.
95 break; 98 break;
96 case UPDATE_STATUS_UPDATE_AVAILABLE: 99 case UPDATE_STATUS_UPDATE_AVAILABLE:
97 MakeSureScreenIsShown(); 100 MakeSureScreenIsShown();
98 actor_->SetProgress(kBeforeDownloadProgress); 101 actor_->SetProgress(kBeforeDownloadProgress);
99 if (!HasCriticalUpdate()) { 102 if (!HasCriticalUpdate()) {
100 LOG(INFO) << "Noncritical update available: " 103 LOG(INFO) << "Noncritical update available: "
101 << library->status().new_version; 104 << library->status().new_version;
102 ExitUpdate(REASON_UPDATE_NON_CRITICAL); 105 ExitUpdate(REASON_UPDATE_NON_CRITICAL);
103 } else { 106 } else {
104 LOG(INFO) << "Critical update available: " 107 LOG(INFO) << "Critical update available: "
105 << library->status().new_version; 108 << library->status().new_version;
109 actor_->ShowPreparingUpdatesInfo(true);
110 actor_->ShowCurtain(false);
106 } 111 }
107 break; 112 break;
108 case UPDATE_STATUS_DOWNLOADING: 113 case UPDATE_STATUS_DOWNLOADING:
109 { 114 {
110 MakeSureScreenIsShown(); 115 MakeSureScreenIsShown();
111 if (!is_downloading_update_) { 116 if (!is_downloading_update_) {
112 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE 117 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE
113 // we need to is update critical on first downloading notification. 118 // we need to is update critical on first downloading notification.
114 is_downloading_update_ = true; 119 is_downloading_update_ = true;
115 if (!HasCriticalUpdate()) { 120 if (!HasCriticalUpdate()) {
116 LOG(INFO) << "Non-critical update available: " 121 LOG(INFO) << "Non-critical update available: "
117 << library->status().new_version; 122 << library->status().new_version;
118 ExitUpdate(REASON_UPDATE_NON_CRITICAL); 123 ExitUpdate(REASON_UPDATE_NON_CRITICAL);
119 } else { 124 } else {
120 LOG(INFO) << "Critical update available: " 125 LOG(INFO) << "Critical update available: "
121 << library->status().new_version; 126 << library->status().new_version;
127 actor_->ShowPreparingUpdatesInfo(false);
128 actor_->ShowCurtain(false);
122 } 129 }
123 } 130 }
124 actor_->ShowCurtain(false);
125 int download_progress = static_cast<int>( 131 int download_progress = static_cast<int>(
126 library->status().download_progress * kDownloadProgressIncrement); 132 library->status().download_progress * kDownloadProgressIncrement);
127 actor_->SetProgress(kBeforeDownloadProgress + download_progress); 133 actor_->SetProgress(kBeforeDownloadProgress + download_progress);
128 } 134 }
129 break; 135 break;
130 case UPDATE_STATUS_VERIFYING: 136 case UPDATE_STATUS_VERIFYING:
131 MakeSureScreenIsShown(); 137 MakeSureScreenIsShown();
132 actor_->SetProgress(kBeforeVerifyingProgress); 138 actor_->SetProgress(kBeforeVerifyingProgress);
133 break; 139 break;
134 case UPDATE_STATUS_FINALIZING: 140 case UPDATE_STATUS_FINALIZING:
(...skipping 10 matching lines...) Expand all
145 VLOG(1) << "Initiate reboot after update"; 151 VLOG(1) << "Initiate reboot after update";
146 CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate(); 152 CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate();
147 reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_), 153 reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_),
148 this, 154 this,
149 &UpdateScreen::OnWaitForRebootTimeElapsed); 155 &UpdateScreen::OnWaitForRebootTimeElapsed);
150 } else { 156 } else {
151 ExitUpdate(REASON_UPDATE_NON_CRITICAL); 157 ExitUpdate(REASON_UPDATE_NON_CRITICAL);
152 } 158 }
153 break; 159 break;
154 case UPDATE_STATUS_IDLE: 160 case UPDATE_STATUS_IDLE:
161 if (ignore_idle_status_) {
162 // It is first IDLE status that is sent before we initiated the check.
163 break;
164 }
165 // else no break
166
155 case UPDATE_STATUS_ERROR: 167 case UPDATE_STATUS_ERROR:
156 case UPDATE_STATUS_REPORTING_ERROR_EVENT: 168 case UPDATE_STATUS_REPORTING_ERROR_EVENT:
157 ExitUpdate(REASON_UPDATE_ENDED); 169 ExitUpdate(REASON_UPDATE_ENDED);
158 break; 170 break;
159 default: 171 default:
160 NOTREACHED(); 172 NOTREACHED();
161 break; 173 break;
162 } 174 }
163 } 175 }
164 176
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 deadline.empty()) { 280 deadline.empty()) {
269 return false; 281 return false;
270 } 282 }
271 283
272 // TODO(dpolukhin): Analyze file content. Now we can just assume that 284 // TODO(dpolukhin): Analyze file content. Now we can just assume that
273 // if the file exists and not empty, there is critical update. 285 // if the file exists and not empty, there is critical update.
274 return true; 286 return true;
275 } 287 }
276 288
277 } // namespace chromeos 289 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698