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

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: rebase again Created 7 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) 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
239 BrowserThread::FILE, FROM_HERE, 239 BrowserThread::FILE, FROM_HERE,
240 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck, this, 240 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck, this,
241 install_if_newer, window, MessageLoop::current())); 241 install_if_newer, window, base::MessageLoop::current()));
242 } 242 }
243 243
244 //////////////////////////////////////////////////////////////////////////////// 244 ////////////////////////////////////////////////////////////////////////////////
245 // GoogleUpdate, private: 245 // GoogleUpdate, private:
246 246
247 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, 247 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
248 HWND window, 248 HWND window,
249 MessageLoop* main_loop) { 249 base::MessageLoop* main_loop) {
250 base::FilePath chrome_exe; 250 base::FilePath chrome_exe;
251 if (!PathService::Get(base::DIR_EXE, &chrome_exe)) 251 if (!PathService::Get(base::DIR_EXE, &chrome_exe))
252 NOTREACHED(); 252 NOTREACHED();
253 253
254 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe); 254 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe);
255 if (error_code != GOOGLE_UPDATE_NO_ERROR) { 255 if (error_code != GOOGLE_UPDATE_NO_ERROR) {
256 main_loop->PostTask( 256 main_loop->PostTask(
257 FROM_HERE, 257 FROM_HERE,
258 base::Bind(&GoogleUpdate::ReportResults, this, 258 base::Bind(&GoogleUpdate::ReportResults, this,
259 UPGRADE_ERROR, error_code, string16())); 259 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, 330 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED,
331 error_code), 331 error_code),
332 main_loop); 332 main_loop);
333 return; 333 return;
334 } 334 }
335 335
336 // Need to spin the message loop while Google Update is running so that it 336 // 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 337 // can report back to us through GoogleUpdateJobObserver. This message loop
338 // will terminate once Google Update sends us the completion status 338 // will terminate once Google Update sends us the completion status
339 // (success/error). See OnComplete(). 339 // (success/error). See OnComplete().
340 MessageLoop::current()->Run(); 340 base::MessageLoop::current()->Run();
341 341
342 GoogleUpdateUpgradeResult results; 342 GoogleUpdateUpgradeResult results;
343 hr = job_observer->GetResult(&results); 343 hr = job_observer->GetResult(&results);
344 344
345 if (hr != S_OK) { 345 if (hr != S_OK) {
346 GoogleUpdateErrorCode error = GOOGLE_UPDATE_GET_RESULT_CALL_FAILED; 346 GoogleUpdateErrorCode error = GOOGLE_UPDATE_GET_RESULT_CALL_FAILED;
347 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); 347 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr);
348 ReportFailure(hr, error, 348 ReportFailure(hr, error,
349 l10n_util::GetStringFUTF16( 349 l10n_util::GetStringFUTF16(
350 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, 350 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); 388 error_code == GOOGLE_UPDATE_NO_ERROR);
389 if (listener_) { 389 if (listener_) {
390 listener_->OnReportResults( 390 listener_->OnReportResults(
391 results, error_code, error_message, version_available_); 391 results, error_code, error_message, version_available_);
392 } 392 }
393 } 393 }
394 394
395 bool GoogleUpdate::ReportFailure(HRESULT hr, 395 bool GoogleUpdate::ReportFailure(HRESULT hr,
396 GoogleUpdateErrorCode error_code, 396 GoogleUpdateErrorCode error_code,
397 const string16& error_message, 397 const string16& error_message,
398 MessageLoop* main_loop) { 398 base::MessageLoop* main_loop) {
399 NOTREACHED() << "Communication with Google Update failed: " << hr 399 NOTREACHED() << "Communication with Google Update failed: " << hr
400 << " error: " << error_code 400 << " error: " << error_code
401 << ", message: " << error_message.c_str(); 401 << ", message: " << error_message.c_str();
402 main_loop->PostTask( 402 main_loop->PostTask(
403 FROM_HERE, 403 FROM_HERE,
404 base::Bind(&GoogleUpdate::ReportResults, this, 404 base::Bind(&GoogleUpdate::ReportResults, this,
405 UPGRADE_ERROR, error_code, error_message)); 405 UPGRADE_ERROR, error_code, error_message));
406 return false; 406 return false;
407 } 407 }
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/geolocation_settings_state_unittest.cc ('k') | chrome/browser/google/google_url_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698