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

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

Issue 6648009: Modify UpdateLibrary to use async RequestUpdateCheck call (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 case UPDATE_STATUS_ERROR: 127 case UPDATE_STATUS_ERROR:
128 case UPDATE_STATUS_REPORTING_ERROR_EVENT: 128 case UPDATE_STATUS_REPORTING_ERROR_EVENT:
129 ExitUpdate(REASON_UPDATE_ENDED); 129 ExitUpdate(REASON_UPDATE_ENDED);
130 break; 130 break;
131 default: 131 default:
132 NOTREACHED(); 132 NOTREACHED();
133 break; 133 break;
134 } 134 }
135 } 135 }
136 136
137 namespace {
138 void update_callback(void* user_data, UpdateResult result, const char* msg) {
altimofeev 2011/03/09 10:42:27 nit: Please, use BumpyCase for the function's name
stevenjb 2011/03/10 01:23:16 Oops. Relapse. Done.
139 if (result != UPDATE_RESULT_SUCCESS) {
140 DCHECK(user_data);
141 UpdateScreen* screen = static_cast<UpdateScreen*>(user_data);
142 screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED);
altimofeev 2011/03/09 10:42:27 What if update screen has been destroyed before th
stevenjb 2011/03/10 01:23:16 Good catch. I will add an instance list to check.
143 }
144 }
145 } // namespace
146
137 void UpdateScreen::StartUpdate() { 147 void UpdateScreen::StartUpdate() {
138 // Reset view if view was created. 148 // Reset view if view was created.
139 if (view()) { 149 if (view()) {
140 view()->Reset(); 150 view()->Reset();
141 view()->set_controller(this); 151 view()->set_controller(this);
142 is_downloading_update_ = false; 152 is_downloading_update_ = false;
143 view()->SetProgress(kBeforeUpdateCheckProgress); 153 view()->SetProgress(kBeforeUpdateCheckProgress);
144 } 154 }
145 155
146 if (!CrosLibrary::Get()->EnsureLoaded()) { 156 if (!CrosLibrary::Get()->EnsureLoaded()) {
147 LOG(ERROR) << "Error loading CrosLibrary"; 157 LOG(ERROR) << "Error loading CrosLibrary";
148 ExitUpdate(REASON_UPDATE_INIT_FAILED); 158 ExitUpdate(REASON_UPDATE_INIT_FAILED);
149 } else { 159 } else {
150 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); 160 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this);
151 VLOG(1) << "Initiate update check"; 161 VLOG(1) << "Initiate update check";
152 if (!CrosLibrary::Get()->GetUpdateLibrary()->CheckForUpdate()) { 162 CrosLibrary::Get()->GetUpdateLibrary()->RequestUpdate(
153 ExitUpdate(REASON_UPDATE_INIT_FAILED); 163 update_callback, this);
154 }
155 } 164 }
156 } 165 }
157 166
158 void UpdateScreen::CancelUpdate() { 167 void UpdateScreen::CancelUpdate() {
159 // Screen has longer lifetime than it's view. 168 // Screen has longer lifetime than it's view.
160 // View is deleted after wizard proceeds to the next screen. 169 // View is deleted after wizard proceeds to the next screen.
161 if (view()) 170 if (view())
162 ExitUpdate(REASON_UPDATE_CANCELED); 171 ExitUpdate(REASON_UPDATE_CANCELED);
163 } 172 }
164 173
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // TODO(dpolukhin): Analyze file content. Now we can just assume that 258 // TODO(dpolukhin): Analyze file content. Now we can just assume that
250 // if the file exists and not empty, there is critical update. 259 // if the file exists and not empty, there is critical update.
251 return true; 260 return true;
252 } 261 }
253 262
254 void UpdateScreen::SetAllUpdatesCritical(bool is_critical) { 263 void UpdateScreen::SetAllUpdatesCritical(bool is_critical) {
255 is_all_updates_critical_ = is_critical; 264 is_all_updates_critical_ = is_critical;
256 } 265 }
257 266
258 } // namespace chromeos 267 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698