OLD | NEW |
---|---|
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.h" | 5 #include "chrome/browser/google/google_update.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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 UPGRADE_ERROR, error_code, string16())); | 263 UPGRADE_ERROR, error_code, string16())); |
264 return; | 264 return; |
265 } | 265 } |
266 | 266 |
267 CComObject<GoogleUpdateJobObserver>* job_observer; | 267 CComObject<GoogleUpdateJobObserver>* job_observer; |
268 HRESULT hr = | 268 HRESULT hr = |
269 CComObject<GoogleUpdateJobObserver>::CreateInstance(&job_observer); | 269 CComObject<GoogleUpdateJobObserver>::CreateInstance(&job_observer); |
270 if (hr != S_OK) { | 270 if (hr != S_OK) { |
271 // Most of the error messages come straight from Google Update. This one is | 271 // Most of the error messages come straight from Google Update. This one is |
272 // deemed worthy enough to also warrant its own error. | 272 // deemed worthy enough to also warrant its own error. |
273 string16 error_code = base::StringPrintf(L"0x%x", hr); | 273 string16 error_code = base::StringPrintf( |
274 L"%d: 0x%x", GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED, hr); | |
274 ReportFailure( | 275 ReportFailure( |
275 hr, GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED, | 276 hr, GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED, |
276 l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_COCREATE_FAILED, | 277 l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_COCREATE_FAILED, |
277 error_code), | 278 error_code), |
278 main_loop); | 279 main_loop); |
279 return; | 280 return; |
280 } | 281 } |
281 | 282 |
282 base::win::ScopedComPtr<IJobObserver> job_holder(job_observer); | 283 base::win::ScopedComPtr<IJobObserver> job_holder(job_observer); |
283 | 284 |
(...skipping 16 matching lines...) Expand all Loading... | |
300 } | 301 } |
301 | 302 |
302 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, | 303 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, |
303 IID_IGoogleUpdate, foreground_hwnd, | 304 IID_IGoogleUpdate, foreground_hwnd, |
304 reinterpret_cast<void**>(on_demand.Receive())); | 305 reinterpret_cast<void**>(on_demand.Receive())); |
305 } | 306 } |
306 system_level = true; | 307 system_level = true; |
307 } | 308 } |
308 | 309 |
309 if (hr != S_OK) { | 310 if (hr != S_OK) { |
311 string16 error_code = base::StringPrintf( | |
312 L"%d: 0x%x", GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, hr); | |
313 if (system_level) | |
S. Ganesh
2012/06/07 00:08:01
Prefer { }
Finnur
2012/06/07 10:43:29
Chrome team doesn't.
On 2012/06/07 00:08:01, gan
| |
314 error_code += L" (system level)"; | |
310 ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, | 315 ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, |
311 string16(), main_loop); | 316 l10n_util::GetStringFUTF16( |
317 IDS_ABOUT_BOX_ERROR_COCREATE_FAILED, | |
318 error_code), | |
319 main_loop); | |
312 return; | 320 return; |
313 } | 321 } |
314 | 322 |
315 string16 app_guid = installer::GetAppGuidForUpdates(system_level); | 323 string16 app_guid = installer::GetAppGuidForUpdates(system_level); |
316 DCHECK(!app_guid.empty()); | 324 DCHECK(!app_guid.empty()); |
317 | 325 |
318 if (!install_if_newer) | 326 if (!install_if_newer) |
319 hr = on_demand->CheckForUpdate(app_guid.c_str(), job_observer); | 327 hr = on_demand->CheckForUpdate(app_guid.c_str(), job_observer); |
320 else | 328 else |
321 hr = on_demand->Update(app_guid.c_str(), job_observer); | 329 hr = on_demand->Update(app_guid.c_str(), job_observer); |
322 | 330 |
323 if (hr != S_OK) { | 331 if (hr != S_OK) { |
324 ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, | 332 ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, |
325 string16(), main_loop); | 333 string16(), main_loop); |
S. Ganesh
2012/06/07 00:08:01
Report a string for this case as well?
| |
326 return; | 334 return; |
327 } | 335 } |
328 | 336 |
329 // We need to spin the message loop while Google Update is running so that it | 337 // We need to spin the message loop while Google Update is running so that it |
330 // can report back to us through GoogleUpdateJobObserver. This message loop | 338 // can report back to us through GoogleUpdateJobObserver. This message loop |
331 // will terminate once Google Update sends us the completion status | 339 // will terminate once Google Update sends us the completion status |
332 // (success/error). See OnComplete(). | 340 // (success/error). See OnComplete(). |
333 MessageLoop::current()->Run(); | 341 MessageLoop::current()->Run(); |
334 | 342 |
335 GoogleUpdateUpgradeResult results; | 343 GoogleUpdateUpgradeResult results; |
336 hr = job_observer->GetResult(&results); | 344 hr = job_observer->GetResult(&results); |
337 if (hr != S_OK) { | 345 if (hr != S_OK) { |
338 ReportFailure(hr, GOOGLE_UPDATE_GET_RESULT_CALL_FAILED, | 346 ReportFailure(hr, GOOGLE_UPDATE_GET_RESULT_CALL_FAILED, |
339 string16(), main_loop); | 347 string16(), main_loop); |
S. Ganesh
2012/06/07 00:08:01
Report a string for this case as well?
| |
340 return; | 348 return; |
341 } | 349 } |
342 | 350 |
343 if (results == UPGRADE_ERROR) { | 351 if (results == UPGRADE_ERROR) { |
344 string16 error_message; | 352 string16 error_message; |
345 job_observer->GetErrorMessage(&error_message); | 353 job_observer->GetErrorMessage(&error_message); |
346 ReportFailure(hr, GOOGLE_UPDATE_ERROR_UPDATING, error_message, main_loop); | 354 ReportFailure(hr, GOOGLE_UPDATE_ERROR_UPDATING, error_message, main_loop); |
347 return; | 355 return; |
348 } | 356 } |
349 | 357 |
350 hr = job_observer->GetVersionInfo(&version_available_); | 358 hr = job_observer->GetVersionInfo(&version_available_); |
351 if (hr != S_OK) { | 359 if (hr != S_OK) { |
352 ReportFailure(hr, GOOGLE_UPDATE_GET_VERSION_INFO_FAILED, | 360 ReportFailure(hr, GOOGLE_UPDATE_GET_VERSION_INFO_FAILED, |
353 string16(), main_loop); | 361 string16(), main_loop); |
S. Ganesh
2012/06/07 00:08:01
Report a string for this case as well?
| |
354 return; | 362 return; |
355 } | 363 } |
356 | 364 |
357 main_loop->PostTask( | 365 main_loop->PostTask( |
358 FROM_HERE, | 366 FROM_HERE, |
359 base::Bind(&GoogleUpdate::ReportResults, this, | 367 base::Bind(&GoogleUpdate::ReportResults, this, |
360 results, GOOGLE_UPDATE_NO_ERROR, string16())); | 368 results, GOOGLE_UPDATE_NO_ERROR, string16())); |
361 job_holder = NULL; | 369 job_holder = NULL; |
362 on_demand = NULL; | 370 on_demand = NULL; |
363 } | 371 } |
(...skipping 16 matching lines...) Expand all Loading... | |
380 MessageLoop* main_loop) { | 388 MessageLoop* main_loop) { |
381 NOTREACHED() << "Communication with Google Update failed: " << hr | 389 NOTREACHED() << "Communication with Google Update failed: " << hr |
382 << " error: " << error_code | 390 << " error: " << error_code |
383 << ", message: " << error_message.c_str(); | 391 << ", message: " << error_message.c_str(); |
384 main_loop->PostTask( | 392 main_loop->PostTask( |
385 FROM_HERE, | 393 FROM_HERE, |
386 base::Bind(&GoogleUpdate::ReportResults, this, | 394 base::Bind(&GoogleUpdate::ReportResults, this, |
387 UPGRADE_ERROR, error_code, error_message)); | 395 UPGRADE_ERROR, error_code, error_message)); |
388 return false; | 396 return false; |
389 } | 397 } |
OLD | NEW |