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

Side by Side Diff: chrome/browser/google/google_update_win.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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) 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/google/google_update_win.h" 5 #include "chrome/browser/google/google_update_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 NOTREACHED(); 169 NOTREACHED();
170 result_ = UPGRADE_ERROR; 170 result_ = UPGRADE_ERROR;
171 break; 171 break;
172 } 172 }
173 } 173 }
174 174
175 event_sink_ = NULL; 175 event_sink_ = NULL;
176 176
177 // No longer need to spin the message loop that started spinning in 177 // No longer need to spin the message loop that started spinning in
178 // InitiateGoogleUpdateCheck. 178 // InitiateGoogleUpdateCheck.
179 MessageLoop::current()->Quit(); 179 base::MessageLoop::current()->Quit();
180 return S_OK; 180 return S_OK;
181 } 181 }
182 STDMETHOD(SetEventSink)(IProgressWndEvents* event_sink) { 182 STDMETHOD(SetEventSink)(IProgressWndEvents* event_sink) {
183 event_sink_ = event_sink; 183 event_sink_ = event_sink;
184 return S_OK; 184 return S_OK;
185 } 185 }
186 186
187 // Returns the results of the update operation. 187 // Returns the results of the update operation.
188 STDMETHOD(GetResult)(GoogleUpdateUpgradeResult* result) { 188 STDMETHOD(GetResult)(GoogleUpdateUpgradeResult* result) {
189 // Intermediary steps should never be reported to the client. 189 // Intermediary steps should never be reported to the client.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 GoogleUpdate::GoogleUpdate() 228 GoogleUpdate::GoogleUpdate()
229 : listener_(NULL) { 229 : listener_(NULL) {
230 } 230 }
231 231
232 GoogleUpdate::~GoogleUpdate() { 232 GoogleUpdate::~GoogleUpdate() {
233 } 233 }
234 234
235 void GoogleUpdate::CheckForUpdate(bool install_if_newer, HWND window) { 235 void GoogleUpdate::CheckForUpdate(bool install_if_newer, HWND window) {
236 // Need to shunt this request over to InitiateGoogleUpdateCheck and have 236 // Need to shunt this request over to InitiateGoogleUpdateCheck and have
237 // it run in the file thread. 237 // it run in the file thread.
238 BrowserThread::PostTask( 238 BrowserThread::PostTask(BrowserThread::FILE,
239 BrowserThread::FILE, FROM_HERE, 239 FROM_HERE,
240 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck, this, 240 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck,
241 install_if_newer, window, MessageLoop::current())); 241 this,
242 install_if_newer,
243 window,
244 base::MessageLoop::current()));
242 } 245 }
243 246
244 //////////////////////////////////////////////////////////////////////////////// 247 ////////////////////////////////////////////////////////////////////////////////
245 // GoogleUpdate, private: 248 // GoogleUpdate, private:
246 249
247 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, 250 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
248 HWND window, 251 HWND window,
249 MessageLoop* main_loop) { 252 base::MessageLoop* main_loop) {
250 base::FilePath chrome_exe; 253 base::FilePath chrome_exe;
251 if (!PathService::Get(base::DIR_EXE, &chrome_exe)) 254 if (!PathService::Get(base::DIR_EXE, &chrome_exe))
252 NOTREACHED(); 255 NOTREACHED();
253 256
254 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe); 257 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe);
255 if (error_code != GOOGLE_UPDATE_NO_ERROR) { 258 if (error_code != GOOGLE_UPDATE_NO_ERROR) {
256 main_loop->PostTask( 259 main_loop->PostTask(
257 FROM_HERE, 260 FROM_HERE,
258 base::Bind(&GoogleUpdate::ReportResults, this, 261 base::Bind(&GoogleUpdate::ReportResults, this,
259 UPGRADE_ERROR, error_code, string16())); 262 UPGRADE_ERROR, error_code, string16()));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, 333 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED,
331 error_code), 334 error_code),
332 main_loop); 335 main_loop);
333 return; 336 return;
334 } 337 }
335 338
336 // Need to spin the message loop while Google Update is running so that it 339 // Need to spin the message loop while Google Update is running so that it
337 // can report back to us through GoogleUpdateJobObserver. This message loop 340 // can report back to us through GoogleUpdateJobObserver. This message loop
338 // will terminate once Google Update sends us the completion status 341 // will terminate once Google Update sends us the completion status
339 // (success/error). See OnComplete(). 342 // (success/error). See OnComplete().
340 MessageLoop::current()->Run(); 343 base::MessageLoop::current()->Run();
341 344
342 GoogleUpdateUpgradeResult results; 345 GoogleUpdateUpgradeResult results;
343 hr = job_observer->GetResult(&results); 346 hr = job_observer->GetResult(&results);
344 347
345 if (hr != S_OK) { 348 if (hr != S_OK) {
346 GoogleUpdateErrorCode error = GOOGLE_UPDATE_GET_RESULT_CALL_FAILED; 349 GoogleUpdateErrorCode error = GOOGLE_UPDATE_GET_RESULT_CALL_FAILED;
347 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); 350 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr);
348 ReportFailure(hr, error, 351 ReportFailure(hr, error,
349 l10n_util::GetStringFUTF16( 352 l10n_util::GetStringFUTF16(
350 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, 353 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 error_code == GOOGLE_UPDATE_NO_ERROR); 391 error_code == GOOGLE_UPDATE_NO_ERROR);
389 if (listener_) { 392 if (listener_) {
390 listener_->OnReportResults( 393 listener_->OnReportResults(
391 results, error_code, error_message, version_available_); 394 results, error_code, error_message, version_available_);
392 } 395 }
393 } 396 }
394 397
395 bool GoogleUpdate::ReportFailure(HRESULT hr, 398 bool GoogleUpdate::ReportFailure(HRESULT hr,
396 GoogleUpdateErrorCode error_code, 399 GoogleUpdateErrorCode error_code,
397 const string16& error_message, 400 const string16& error_message,
398 MessageLoop* main_loop) { 401 base::MessageLoop* main_loop) {
399 NOTREACHED() << "Communication with Google Update failed: " << hr 402 NOTREACHED() << "Communication with Google Update failed: " << hr
400 << " error: " << error_code 403 << " error: " << error_code
401 << ", message: " << error_message.c_str(); 404 << ", message: " << error_message.c_str();
402 main_loop->PostTask( 405 main_loop->PostTask(
403 FROM_HERE, 406 FROM_HERE,
404 base::Bind(&GoogleUpdate::ReportResults, this, 407 base::Bind(&GoogleUpdate::ReportResults, this,
405 UPGRADE_ERROR, error_code, error_message)); 408 UPGRADE_ERROR, error_code, error_message));
406 return false; 409 return false;
407 } 410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698