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

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

Issue 2207523002: Move on-demand update checks from the FILE thread to the blocking pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@threadfix
Patch Set: GitCookie Created 4 years, 4 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
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 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
11 11
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/location.h" 18 #include "base/location.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/metrics/sparse_histogram.h" 21 #include "base/metrics/sparse_histogram.h"
22 #include "base/path_service.h" 22 #include "base/path_service.h"
23 #include "base/sequenced_task_runner.h"
23 #include "base/sequenced_task_runner_helpers.h" 24 #include "base/sequenced_task_runner_helpers.h"
24 #include "base/single_thread_task_runner.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
27 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "base/threading/thread_task_runner_handle.h" 28 #include "base/threading/sequenced_task_runner_handle.h"
29 #include "base/time/time.h" 29 #include "base/time/time.h"
30 #include "base/version.h" 30 #include "base/version.h"
31 #include "base/win/scoped_bstr.h" 31 #include "base/win/scoped_bstr.h"
32 #include "base/win/windows_version.h" 32 #include "base/win/windows_version.h"
33 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
34 #include "chrome/grit/generated_resources.h" 34 #include "chrome/grit/generated_resources.h"
35 #include "chrome/installer/util/browser_distribution.h" 35 #include "chrome/installer/util/browser_distribution.h"
36 #include "chrome/installer/util/google_update_settings.h" 36 #include "chrome/installer/util/google_update_settings.h"
37 #include "chrome/installer/util/helper.h" 37 #include "chrome/installer/util/helper.h"
38 #include "chrome/installer/util/install_util.h" 38 #include "chrome/installer/util/install_util.h"
(...skipping 14 matching lines...) Expand all
53 UPGRADE_IS_AVAILABLE = 2, 53 UPGRADE_IS_AVAILABLE = 2,
54 // The upgrade happened successfully. 54 // The upgrade happened successfully.
55 UPGRADE_SUCCESSFUL = 3, 55 UPGRADE_SUCCESSFUL = 3,
56 // No need to upgrade, Chrome is up to date. 56 // No need to upgrade, Chrome is up to date.
57 UPGRADE_ALREADY_UP_TO_DATE = 4, 57 UPGRADE_ALREADY_UP_TO_DATE = 4,
58 // An error occurred. 58 // An error occurred.
59 UPGRADE_ERROR = 5, 59 UPGRADE_ERROR = 5,
60 NUM_UPGRADE_STATUS 60 NUM_UPGRADE_STATUS
61 }; 61 };
62 62
63 GlobalInterfaceTableClassFactory* g_git_factory = nullptr;
Peter Kasting 2016/08/03 01:24:34 Nit: Prefer to avoid unusual abbreviations; |g_int
grt (UTC plus 2) 2016/08/03 05:36:30 Done.
63 GoogleUpdate3ClassFactory* g_google_update_factory = nullptr; 64 GoogleUpdate3ClassFactory* g_google_update_factory = nullptr;
64 65
65 // The time interval, in milliseconds, between polls to Google Update. This 66 // The time interval, in milliseconds, between polls to Google Update. This
66 // value was chosen unscientificaly during an informal discussion. 67 // value was chosen unscientificaly during an informal discussion.
67 const int64_t kGoogleUpdatePollIntervalMs = 250; 68 const int64_t kGoogleUpdatePollIntervalMs = 250;
68 69
69 const int kGoogleAllowedRetries = 1; 70 const int kGoogleAllowedRetries = 1;
70 const int kGoogleRetryIntervalSeconds = 5; 71 const int kGoogleRetryIntervalSeconds = 5;
71 72
72 // Constants from Google Update. 73 // Constants from Google Update.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ::CoSetProxyBlanket(interface_pointer, 116 ::CoSetProxyBlanket(interface_pointer,
116 RPC_C_AUTHN_DEFAULT, 117 RPC_C_AUTHN_DEFAULT,
117 RPC_C_AUTHZ_DEFAULT, 118 RPC_C_AUTHZ_DEFAULT,
118 COLE_DEFAULT_PRINCIPAL, 119 COLE_DEFAULT_PRINCIPAL,
119 RPC_C_AUTHN_LEVEL_PKT_PRIVACY, 120 RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
120 RPC_C_IMP_LEVEL_IMPERSONATE, 121 RPC_C_IMP_LEVEL_IMPERSONATE,
121 nullptr, 122 nullptr,
122 EOAC_DYNAMIC_CLOAKING); 123 EOAC_DYNAMIC_CLOAKING);
123 } 124 }
124 125
126 HRESULT CreateGlobalInterfaceTable(
127 base::win::ScopedComPtr<IGlobalInterfaceTable>* git) {
128 if (g_git_factory)
129 return g_git_factory->Run(git);
130
131 return git->CreateInstance(CLSID_StdGlobalInterfaceTable, nullptr,
132 CLSCTX_INPROC_SERVER);
133 }
134
125 // Creates a class factory for a COM Local Server class using either plain 135 // Creates a class factory for a COM Local Server class using either plain
126 // vanilla CoGetClassObject, or using the Elevation moniker if running on 136 // vanilla CoGetClassObject, or using the Elevation moniker if running on
127 // Vista+. |hwnd| must refer to a foregound window in order to get the UAC 137 // Vista+. |hwnd| must refer to a foregound window in order to get the UAC
128 // prompt to appear in the foreground if running on Vista+. It can also be NULL 138 // prompt to appear in the foreground if running on Vista+. It can also be NULL
129 // if background UAC prompts are desired. 139 // if background UAC prompts are desired.
130 HRESULT CoGetClassObjectAsAdmin(REFCLSID class_id, 140 HRESULT CoGetClassObjectAsAdmin(REFCLSID class_id,
131 REFIID interface_id, 141 REFIID interface_id,
132 gfx::AcceleratedWidget hwnd, 142 gfx::AcceleratedWidget hwnd,
133 void** interface_ptr) { 143 void** interface_ptr) {
134 if (!interface_ptr) 144 if (!interface_ptr)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return hresult; 206 return hresult;
197 207
198 ConfigureProxyBlanket(class_factory.get()); 208 ConfigureProxyBlanket(class_factory.get());
199 209
200 return class_factory->CreateInstance( 210 return class_factory->CreateInstance(
201 nullptr, 211 nullptr,
202 base::win::ScopedComPtr<IGoogleUpdate3Web>::iid(), 212 base::win::ScopedComPtr<IGoogleUpdate3Web>::iid(),
203 google_update->ReceiveVoid()); 213 google_update->ReceiveVoid());
204 } 214 }
205 215
216 // GitCookie -------------------------------------------------------------------
217
218 // Manages the lifetime of an interface's cookie in the COM Global Interface
219 // Table.
220 template <class T>
221 class GitCookie {
222 public:
223 GitCookie() = default;
224 ~GitCookie() { Revoke(); }
Peter Kasting 2016/08/03 01:24:34 Nit: You may do either, but personally I find it s
grt (UTC plus 2) 2016/08/03 05:36:30 Done.
225
226 void Initialize(base::win::ScopedComPtr<IGlobalInterfaceTable> git) {
227 DCHECK(!git_);
228 git_ = std::move(git);
229 }
230
231 // Registers |interface_pointer| in the process's Global Interface Table.
232 HRESULT Register(const base::win::ScopedComPtr<T>& interface_pointer) {
233 DCHECK(git_);
234 DCHECK_EQ(0U, cookie_);
235 HRESULT hresult = git_->RegisterInterfaceInGlobal(
236 interface_pointer.get(), base::win::ScopedComPtr<T>::iid(), &cookie_);
237 DCHECK_EQ(S_OK, hresult);
238 return hresult;
Peter Kasting 2016/08/03 01:24:34 This function and the next two should not return v
grt (UTC plus 2) 2016/08/03 05:36:30 Done.
239 }
240
241 // Populates |interface_pointer| with the cookie's interface in the process's
242 // Global Interface Table.
243 HRESULT Get(base::win::ScopedComPtr<T>* interface_pointer) const {
244 DCHECK(git_);
245 DCHECK(interface_pointer);
246 DCHECK_NE(0U, cookie_);
247 HRESULT hresult = git_->GetInterfaceFromGlobal(
248 cookie_,
249 base::win::ScopedComPtr<T>::iid(),
250 interface_pointer->ReceiveVoid());
251 DCHECK_EQ(S_OK, hresult);
252 return hresult;
253 }
254
255 // Revokes the cookie from the Global Interface Table. This function is safe
256 // to call when the cookie is empty.
257 HRESULT Revoke() {
258 HRESULT hresult = S_OK;
259 if (cookie_) {
260 DCHECK(git_);
261 hresult = git_->RevokeInterfaceFromGlobal(cookie_);
262 DCHECK_EQ(S_OK, hresult);
263 cookie_ = 0;
264 }
265 return hresult;
266 }
267
268 explicit operator bool() const { return cookie_ != 0; }
269
270 private:
271 base::win::ScopedComPtr<IGlobalInterfaceTable> git_;
272 DWORD cookie_ = 0;
273
274 DISALLOW_COPY_AND_ASSIGN(GitCookie);
275 };
276
206 // UpdateCheckDriver ----------------------------------------------------------- 277 // UpdateCheckDriver -----------------------------------------------------------
207 278
208 // A driver that is created and destroyed on the caller's thread and drives 279 // A driver that is created and destroyed on the caller's sequence and drives
209 // Google Update on another. 280 // Google Update on another.
210 class UpdateCheckDriver { 281 class UpdateCheckDriver {
211 public: 282 public:
212 // Runs an update check on |task_runner|, invoking methods of |delegate| on 283 // Runs an update check on |task_runner|, invoking methods of |delegate| on
213 // the caller's thread to report progress and final results. 284 // the caller's sequence to report progress and final results.
214 static void RunUpdateCheck( 285 static void RunUpdateCheck(
215 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 286 scoped_refptr<base::SequencedTaskRunner> task_runner,
216 const std::string& locale, 287 const std::string& locale,
217 bool install_update_if_possible, 288 bool install_update_if_possible,
218 gfx::AcceleratedWidget elevation_window, 289 gfx::AcceleratedWidget elevation_window,
219 const base::WeakPtr<UpdateCheckDelegate>& delegate); 290 const base::WeakPtr<UpdateCheckDelegate>& delegate);
220 291
221 private: 292 private:
222 friend class base::DeleteHelper<UpdateCheckDriver>; 293 friend class base::DeleteHelper<UpdateCheckDriver>;
223 294
224 UpdateCheckDriver( 295 UpdateCheckDriver(scoped_refptr<base::SequencedTaskRunner> task_runner,
225 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 296 const std::string& locale,
226 const std::string& locale, 297 bool install_update_if_possible,
227 bool install_update_if_possible, 298 gfx::AcceleratedWidget elevation_window,
228 gfx::AcceleratedWidget elevation_window, 299 const base::WeakPtr<UpdateCheckDelegate>& delegate);
229 const base::WeakPtr<UpdateCheckDelegate>& delegate);
230 300
231 // Invokes a completion or error method on all delegates, as appropriate. 301 // Invokes a completion or error method on all delegates, as appropriate.
232 ~UpdateCheckDriver(); 302 ~UpdateCheckDriver();
233 303
234 // If an UpdateCheckDriver is already running, the delegate is added to the 304 // If an UpdateCheckDriver is already running, the delegate is added to the
235 // existing one instead of creating a new one. 305 // existing one instead of creating a new one.
236 void AddDelegate(const base::WeakPtr<UpdateCheckDelegate>& delegate); 306 void AddDelegate(const base::WeakPtr<UpdateCheckDelegate>& delegate);
237 307
238 // Notifies delegates of an update's progress. |progress|, a number between 0 308 // Notifies delegates of an update's progress. |progress|, a number between 0
239 // and 100 (inclusive), is an estimation as to what percentage of the upgrade 309 // and 100 (inclusive), is an estimation as to what percentage of the upgrade
(...skipping 16 matching lines...) Expand all
256 // to the user. This call should be followed by deletion of the driver, 326 // to the user. This call should be followed by deletion of the driver,
257 // which will result in callers being notified via their delegates. 327 // which will result in callers being notified via their delegates.
258 void OnUpgradeError(GoogleUpdateErrorCode error_code, 328 void OnUpgradeError(GoogleUpdateErrorCode error_code,
259 HRESULT hresult, 329 HRESULT hresult,
260 int installer_exit_code, 330 int installer_exit_code,
261 const base::string16& error_string); 331 const base::string16& error_string);
262 332
263 // Returns true if |current_state| and |state_value| can be obtained from the 333 // Returns true if |current_state| and |state_value| can be obtained from the
264 // ongoing update check. Otherwise, populates |hresult| with the reason they 334 // ongoing update check. Otherwise, populates |hresult| with the reason they
265 // could not be obtained. 335 // could not be obtained.
266 bool GetCurrentState(base::win::ScopedComPtr<ICurrentState>* current_state, 336 bool GetCurrentState(base::win::ScopedComPtr<IAppBundleWeb>* app_bundle,
337 base::win::ScopedComPtr<ICurrentState>* current_state,
267 CurrentState* state_value, 338 CurrentState* state_value,
268 HRESULT* hresult) const; 339 HRESULT* hresult) const;
269 340
270 // Returns true if |current_state| and |state_value| constitute an error state 341 // Returns true if |current_state| and |state_value| constitute an error state
271 // for the ongoing update check, in which case |error_code| is populated with 342 // for the ongoing update check, in which case |error_code| is populated with
272 // one of GOOGLE_UPDATE_ERROR_UPDATING, GOOGLE_UPDATE_DISABLED_BY_POLICY, or 343 // one of GOOGLE_UPDATE_ERROR_UPDATING, GOOGLE_UPDATE_DISABLED_BY_POLICY, or
273 // GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR. |hresult| is populated with 344 // GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR. |hresult| is populated with
274 // the most relevant HRESULT (which may be a value from Google Update; see 345 // the most relevant HRESULT (which may be a value from Google Update; see
275 // https://code.google.com/p/omaha/source/browse/trunk/base/error.h). In case 346 // https://code.google.com/p/omaha/source/browse/trunk/base/error.h). In case
276 // Chrome's installer failed during execution, |installer_exit_code| may be 347 // Chrome's installer failed during execution, |installer_exit_code| may be
277 // populated with its process exit code (see enum installer::InstallStatus in 348 // populated with its process exit code (see enum installer::InstallStatus in
278 // chrome/installer/util/util_constants.h); otherwise, it will be -1. 349 // chrome/installer/util/util_constants.h); otherwise, it will be -1.
279 // |error_string| will be populated with a completion message if one is 350 // |error_string| will be populated with a completion message if one is
280 // provided by Google Update. 351 // provided by Google Update.
281 bool IsErrorState(const base::win::ScopedComPtr<ICurrentState>& current_state, 352 bool IsErrorState(const base::win::ScopedComPtr<IAppBundleWeb>& app_bundle,
353 const base::win::ScopedComPtr<ICurrentState>& current_state,
282 CurrentState state_value, 354 CurrentState state_value,
283 GoogleUpdateErrorCode* error_code, 355 GoogleUpdateErrorCode* error_code,
284 HRESULT* hresult, 356 HRESULT* hresult,
285 int* installer_exit_code, 357 int* installer_exit_code,
286 base::string16* error_string) const; 358 base::string16* error_string) const;
287 359
288 // Returns true if |current_state| and |state_value| constitute a final state 360 // Returns true if |current_state| and |state_value| constitute a final state
289 // for the ongoing update check, in which case |upgrade_status| is populated 361 // for the ongoing update check, in which case |upgrade_status| is populated
290 // with one of UPGRADE_ALREADY_UP_TO_DATE or UPGRADE_IS_AVAILABLE (in case a 362 // with one of UPGRADE_ALREADY_UP_TO_DATE or UPGRADE_IS_AVAILABLE (in case a
291 // pure check is being performed rather than an update) or UPGRADE_SUCCESSFUL 363 // pure check is being performed rather than an update) or UPGRADE_SUCCESSFUL
(...skipping 17 matching lines...) Expand all
309 base::string16* new_version, 381 base::string16* new_version,
310 int* progress) const; 382 int* progress) const;
311 383
312 // Polls Google Update to determine the state of the ongoing check or 384 // Polls Google Update to determine the state of the ongoing check or
313 // update. If the process has reached a terminal state, this instance will be 385 // update. If the process has reached a terminal state, this instance will be
314 // deleted and the caller will be notified of the final status. Otherwise, the 386 // deleted and the caller will be notified of the final status. Otherwise, the
315 // caller will be notified of the intermediate state (iff it differs from a 387 // caller will be notified of the intermediate state (iff it differs from a
316 // previous notification) and another future poll will be scheduled. 388 // previous notification) and another future poll will be scheduled.
317 void PollGoogleUpdate(); 389 void PollGoogleUpdate();
318 390
319 // The global driver instance. Accessed only on the caller's thread. 391 // The global driver instance. Accessed only on the caller's sequence.
320 static UpdateCheckDriver* driver_; 392 static UpdateCheckDriver* driver_;
321 393
322 // The task runner on which the update checks runs. 394 // The task runner on which the update checks runs.
323 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 395 scoped_refptr<base::SequencedTaskRunner> task_runner_;
324 396
325 // The caller's task runner, on which methods of the |delegates_| will be 397 // The caller's task runner, on which methods of the |delegates_| will be
326 // invoked. 398 // invoked.
327 scoped_refptr<base::SingleThreadTaskRunner> result_runner_; 399 scoped_refptr<base::SequencedTaskRunner> result_runner_;
328 400
329 // The UI locale. 401 // The UI locale.
330 std::string locale_; 402 std::string locale_;
331 403
332 // False to only check for an update; true to also install one if available. 404 // False to only check for an update; true to also install one if available.
333 bool install_update_if_possible_; 405 bool install_update_if_possible_;
334 406
335 // A parent window in case any UX is required (e.g., an elevation prompt). 407 // A parent window in case any UX is required (e.g., an elevation prompt).
336 gfx::AcceleratedWidget elevation_window_; 408 gfx::AcceleratedWidget elevation_window_;
337 409
338 // Contains all delegates by which feedback is conveyed. Accessed only on the 410 // Contains all delegates by which feedback is conveyed. Accessed only on the
339 // caller's thread. 411 // caller's sequence.
340 std::vector<base::WeakPtr<UpdateCheckDelegate>> delegates_; 412 std::vector<base::WeakPtr<UpdateCheckDelegate>> delegates_;
341 413
342 // Number of remaining retries allowed when errors occur. 414 // Number of remaining retries allowed when errors occur.
343 int allowed_retries_; 415 int allowed_retries_;
344 416
345 // True if operating on a per-machine installation rather than a per-user one. 417 // True if operating on a per-machine installation rather than a per-user one.
346 bool system_level_install_; 418 bool system_level_install_;
347 419
348 // The on-demand updater that is doing the work. 420 // The COM Global Interface Table for the process.
349 base::win::ScopedComPtr<IGoogleUpdate3Web> google_update_; 421 base::win::ScopedComPtr<IGlobalInterfaceTable> git_;
350 422
351 // An app bundle containing the application being updated. 423 // A cookie in the Global Interface Table for the on-demand updater that is
352 base::win::ScopedComPtr<IAppBundleWeb> app_bundle_; 424 // doing the work.
425 GitCookie<IGoogleUpdate3Web> google_update_cookie_;
353 426
354 // The application being updated (Chrome, Chrome Binaries, or Chrome SxS). 427 // A cookie in the Global Interface Table for the app bundle containing the
355 base::win::ScopedComPtr<IAppWeb> app_; 428 // application being updated.
429 GitCookie<IAppBundleWeb> app_bundle_cookie_;
356 430
357 // The progress value reported most recently to the caller. 431 // The progress value reported most recently to the caller.
358 int last_reported_progress_; 432 int last_reported_progress_;
359 433
360 // The results of the update check to be logged via UMA and/or reported to the 434 // The results of the update check to be logged via UMA and/or reported to the
361 // caller. 435 // caller.
362 GoogleUpdateUpgradeStatus status_; 436 GoogleUpdateUpgradeStatus status_;
363 GoogleUpdateErrorCode error_code_; 437 GoogleUpdateErrorCode error_code_;
364 base::string16 html_error_message_; 438 base::string16 html_error_message_;
365 base::string16 new_version_; 439 base::string16 new_version_;
366 HRESULT hresult_; 440 HRESULT hresult_;
367 int installer_exit_code_; 441 int installer_exit_code_;
368 442
369 DISALLOW_COPY_AND_ASSIGN(UpdateCheckDriver); 443 DISALLOW_COPY_AND_ASSIGN(UpdateCheckDriver);
370 }; 444 };
371 445
372 UpdateCheckDriver* UpdateCheckDriver::driver_ = nullptr; 446 UpdateCheckDriver* UpdateCheckDriver::driver_ = nullptr;
373 447
374 // static 448 // static
375 void UpdateCheckDriver::RunUpdateCheck( 449 void UpdateCheckDriver::RunUpdateCheck(
376 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 450 scoped_refptr<base::SequencedTaskRunner> task_runner,
377 const std::string& locale, 451 const std::string& locale,
378 bool install_update_if_possible, 452 bool install_update_if_possible,
379 gfx::AcceleratedWidget elevation_window, 453 gfx::AcceleratedWidget elevation_window,
380 const base::WeakPtr<UpdateCheckDelegate>& delegate) { 454 const base::WeakPtr<UpdateCheckDelegate>& delegate) {
381 // Create the driver if it doesn't exist, or add the delegate to the existing 455 // Create the driver if it doesn't exist, or add the delegate to the existing
382 // one. 456 // one.
383 if (!driver_) { 457 if (!driver_) {
384 // The driver is owned by itself, and will self-destruct when its work is 458 // The driver is owned by itself, and will self-destruct when its work is
385 // done. 459 // done.
386 driver_ = 460 driver_ =
387 new UpdateCheckDriver(task_runner, locale, install_update_if_possible, 461 new UpdateCheckDriver(task_runner, locale, install_update_if_possible,
388 elevation_window, delegate); 462 elevation_window, delegate);
389 task_runner->PostTask(FROM_HERE, 463 task_runner->PostTask(FROM_HERE,
390 base::Bind(&UpdateCheckDriver::BeginUpdateCheck, 464 base::Bind(&UpdateCheckDriver::BeginUpdateCheck,
391 base::Unretained(driver_))); 465 base::Unretained(driver_)));
392 } else { 466 } else {
393 DCHECK_EQ(driver_->task_runner_, task_runner); 467 DCHECK_EQ(driver_->task_runner_, task_runner);
394 driver_->AddDelegate(delegate); 468 driver_->AddDelegate(delegate);
395 } 469 }
396 } 470 }
397 471
398 // Runs on the caller's thread. 472 // Runs on the caller's sequence.
399 UpdateCheckDriver::UpdateCheckDriver( 473 UpdateCheckDriver::UpdateCheckDriver(
400 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 474 scoped_refptr<base::SequencedTaskRunner> task_runner,
401 const std::string& locale, 475 const std::string& locale,
402 bool install_update_if_possible, 476 bool install_update_if_possible,
403 gfx::AcceleratedWidget elevation_window, 477 gfx::AcceleratedWidget elevation_window,
404 const base::WeakPtr<UpdateCheckDelegate>& delegate) 478 const base::WeakPtr<UpdateCheckDelegate>& delegate)
405 : task_runner_(std::move(task_runner)), 479 : task_runner_(std::move(task_runner)),
406 result_runner_(base::ThreadTaskRunnerHandle::Get()), 480 result_runner_(base::SequencedTaskRunnerHandle::Get()),
407 locale_(locale), 481 locale_(locale),
408 install_update_if_possible_(install_update_if_possible), 482 install_update_if_possible_(install_update_if_possible),
409 elevation_window_(elevation_window), 483 elevation_window_(elevation_window),
410 delegates_(1, delegate), 484 delegates_(1, delegate),
411 allowed_retries_(kGoogleAllowedRetries), 485 allowed_retries_(kGoogleAllowedRetries),
412 system_level_install_(false), 486 system_level_install_(false),
413 last_reported_progress_(0), 487 last_reported_progress_(0),
414 status_(UPGRADE_ERROR), 488 status_(UPGRADE_ERROR),
415 error_code_(GOOGLE_UPDATE_NO_ERROR), 489 error_code_(GOOGLE_UPDATE_NO_ERROR),
416 hresult_(S_OK), 490 hresult_(S_OK),
417 installer_exit_code_(-1) {} 491 installer_exit_code_(-1) {}
418 492
419 UpdateCheckDriver::~UpdateCheckDriver() { 493 UpdateCheckDriver::~UpdateCheckDriver() {
420 DCHECK(result_runner_->BelongsToCurrentThread()); 494 DCHECK(result_runner_->RunsTasksOnCurrentThread());
495
Peter Kasting 2016/08/03 01:24:34 Nit: Unnecessary blank line
grt (UTC plus 2) 2016/08/03 05:36:30 Done.
496 DCHECK(!google_update_cookie_);
497 DCHECK(!app_bundle_cookie_);
498
421 // If there is an error, then error_code must not be blank, and vice versa. 499 // If there is an error, then error_code must not be blank, and vice versa.
422 DCHECK_NE(status_ == UPGRADE_ERROR, error_code_ == GOOGLE_UPDATE_NO_ERROR); 500 DCHECK_NE(status_ == UPGRADE_ERROR, error_code_ == GOOGLE_UPDATE_NO_ERROR);
423 UMA_HISTOGRAM_ENUMERATION("GoogleUpdate.UpgradeResult", status_, 501 UMA_HISTOGRAM_ENUMERATION("GoogleUpdate.UpgradeResult", status_,
424 NUM_UPGRADE_STATUS); 502 NUM_UPGRADE_STATUS);
425 if (status_ == UPGRADE_ERROR) { 503 if (status_ == UPGRADE_ERROR) {
426 UMA_HISTOGRAM_ENUMERATION("GoogleUpdate.UpdateErrorCode", error_code_, 504 UMA_HISTOGRAM_ENUMERATION("GoogleUpdate.UpdateErrorCode", error_code_,
427 NUM_ERROR_CODES); 505 NUM_ERROR_CODES);
428 if (FAILED(hresult_)) 506 if (FAILED(hresult_))
429 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.ErrorHresult", hresult_); 507 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.ErrorHresult", hresult_);
430 if (installer_exit_code_ != -1) { 508 if (installer_exit_code_ != -1) {
(...skipping 14 matching lines...) Expand all
445 else if (install_update_if_possible_) 523 else if (install_update_if_possible_)
446 delegate->OnUpgradeComplete(new_version_); 524 delegate->OnUpgradeComplete(new_version_);
447 else 525 else
448 delegate->OnUpdateCheckComplete(new_version_); 526 delegate->OnUpdateCheckComplete(new_version_);
449 } 527 }
450 } 528 }
451 } 529 }
452 530
453 void UpdateCheckDriver::AddDelegate( 531 void UpdateCheckDriver::AddDelegate(
454 const base::WeakPtr<UpdateCheckDelegate>& delegate) { 532 const base::WeakPtr<UpdateCheckDelegate>& delegate) {
455 DCHECK(result_runner_->BelongsToCurrentThread()); 533 DCHECK(result_runner_->RunsTasksOnCurrentThread());
456 delegates_.push_back(delegate); 534 delegates_.push_back(delegate);
457 } 535 }
458 536
459 void UpdateCheckDriver::NotifyUpgradeProgress( 537 void UpdateCheckDriver::NotifyUpgradeProgress(
460 int progress, 538 int progress,
461 const base::string16& new_version) { 539 const base::string16& new_version) {
462 DCHECK(result_runner_->BelongsToCurrentThread()); 540 DCHECK(result_runner_->RunsTasksOnCurrentThread());
463 541
464 for (const auto& delegate : delegates_) { 542 for (const auto& delegate : delegates_) {
465 if (delegate) 543 if (delegate)
466 delegate->OnUpgradeProgress(progress, new_version); 544 delegate->OnUpgradeProgress(progress, new_version);
467 } 545 }
468 } 546 }
469 547
470 void UpdateCheckDriver::BeginUpdateCheck() { 548 void UpdateCheckDriver::BeginUpdateCheck() {
471 GoogleUpdateErrorCode error_code = GOOGLE_UPDATE_NO_ERROR; 549 GoogleUpdateErrorCode error_code = GOOGLE_UPDATE_NO_ERROR;
472 HRESULT hresult = BeginUpdateCheckInternal(&error_code); 550 HRESULT hresult = BeginUpdateCheckInternal(&error_code);
(...skipping 17 matching lines...) Expand all
490 } 568 }
491 569
492 DCHECK(FAILED(hresult)); 570 DCHECK(FAILED(hresult));
493 // Return results immediately since the driver is not polling Google Update. 571 // Return results immediately since the driver is not polling Google Update.
494 OnUpgradeError(error_code, hresult, -1, base::string16()); 572 OnUpgradeError(error_code, hresult, -1, base::string16());
495 result_runner_->DeleteSoon(FROM_HERE, this); 573 result_runner_->DeleteSoon(FROM_HERE, this);
496 } 574 }
497 575
498 HRESULT UpdateCheckDriver::BeginUpdateCheckInternal( 576 HRESULT UpdateCheckDriver::BeginUpdateCheckInternal(
499 GoogleUpdateErrorCode* error_code) { 577 GoogleUpdateErrorCode* error_code) {
578 // All errors prior to creation of the main update class are reported as:
579 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND;
500 HRESULT hresult = S_OK; 580 HRESULT hresult = S_OK;
501 // Instantiate GoogleUpdate3Web{Machine,User}Class. 581
502 if (!google_update_) { 582 // Create/get the process's Global Interface Table.
583 if (!git_) {
584 // Make sure ATL is initialized in this module.
585 ui::win::CreateATLModuleIfNeeded();
586
587 hresult = CreateGlobalInterfaceTable(&git_);
588 if (FAILED(hresult))
589 return hresult;
590
591 google_update_cookie_.Initialize(git_);
592 app_bundle_cookie_.Initialize(git_);
593 }
594
595 // Create or get the GoogleUpdate3Web class.
596 base::win::ScopedComPtr<IGoogleUpdate3Web> google_update;
597 if (!google_update_cookie_) {
598 // Instantiate GoogleUpdate3Web{Machine,User}Class.
503 base::FilePath chrome_exe; 599 base::FilePath chrome_exe;
504 if (!PathService::Get(base::DIR_EXE, &chrome_exe)) 600 if (!PathService::Get(base::DIR_EXE, &chrome_exe))
505 NOTREACHED(); 601 NOTREACHED();
506 602
507 system_level_install_ = !InstallUtil::IsPerUserInstall(chrome_exe); 603 system_level_install_ = !InstallUtil::IsPerUserInstall(chrome_exe);
508 604
509 // Make sure ATL is initialized in this module.
510 ui::win::CreateATLModuleIfNeeded();
511
512 *error_code = CanUpdateCurrentChrome(chrome_exe, system_level_install_); 605 *error_code = CanUpdateCurrentChrome(chrome_exe, system_level_install_);
513 if (*error_code != GOOGLE_UPDATE_NO_ERROR) 606 if (*error_code != GOOGLE_UPDATE_NO_ERROR)
514 return E_FAIL; 607 return E_FAIL;
608 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND;
515 609
Peter Kasting 2016/08/03 01:24:34 Nit: Seems like this blank line should be above th
grt (UTC plus 2) 2016/08/03 05:36:30 I grouped it that way because I saw it as revertin
516 hresult = CreateGoogleUpdate3WebClass(system_level_install_, 610 hresult = CreateGoogleUpdate3WebClass(system_level_install_,
517 install_update_if_possible_, 611 install_update_if_possible_,
518 elevation_window_, &google_update_); 612 elevation_window_, &google_update);
519 if (FAILED(hresult)) { 613 if (SUCCEEDED(hresult)) {
520 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND; 614 ConfigureProxyBlanket(google_update.get());
521 return hresult; 615
616 hresult = google_update_cookie_.Register(google_update);
522 } 617 }
523 618
524 ConfigureProxyBlanket(google_update_.get()); 619 if (FAILED(hresult))
620 return hresult;
621 } else {
622 hresult = google_update_cookie_.Get(&google_update);
623 if (FAILED(hresult))
624 return hresult;
525 } 625 }
526 626
527 // The class was created, so all subsequent errors are reported as: 627 // The class was created, so all subsequent errors are reported as:
528 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR; 628 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR;
529 629
530 // Create an app bundle. 630 // Create or get the AppBundleWeb used to update Chrome.
531 if (!app_bundle_) { 631 if (!app_bundle_cookie_) {
532 base::win::ScopedComPtr<IAppBundleWeb> app_bundle; 632 base::win::ScopedComPtr<IAppBundleWeb> app_bundle;
533 base::win::ScopedComPtr<IDispatch> dispatch; 633 base::win::ScopedComPtr<IDispatch> dispatch;
534 hresult = google_update_->createAppBundleWeb(dispatch.Receive()); 634 hresult = google_update->createAppBundleWeb(dispatch.Receive());
535 if (FAILED(hresult)) 635 if (FAILED(hresult))
536 return hresult; 636 return hresult;
537 hresult = dispatch.QueryInterface(app_bundle.Receive()); 637 hresult = dispatch.QueryInterface(app_bundle.Receive());
538 if (FAILED(hresult)) 638 if (FAILED(hresult))
539 return hresult; 639 return hresult;
540 dispatch.Release(); 640 dispatch.Release();
541 641
542 ConfigureProxyBlanket(app_bundle.get()); 642 ConfigureProxyBlanket(app_bundle.get());
543 643
544 if (!locale_.empty()) { 644 if (!locale_.empty()) {
545 // Ignore the result of this since, while setting the display language is 645 // Ignore the result of this since, while setting the display language is
546 // nice to have, a failure to do so does not affect the likelihood that 646 // nice to have, a failure to do so does not affect the likelihood that
547 // the update check and/or install will succeed. 647 // the update check and/or install will succeed.
548 app_bundle->put_displayLanguage( 648 app_bundle->put_displayLanguage(
549 base::win::ScopedBstr(base::UTF8ToUTF16(locale_).c_str())); 649 base::win::ScopedBstr(base::UTF8ToUTF16(locale_).c_str()));
550 } 650 }
551 651
552 hresult = app_bundle->initialize(); 652 hresult = app_bundle->initialize();
553 if (FAILED(hresult)) 653 if (FAILED(hresult))
554 return hresult; 654 return hresult;
555 if (elevation_window_) { 655 if (elevation_window_) {
556 // Likewise, a failure to set the parent window need not block an update 656 // Likewise, a failure to set the parent window need not block an update
557 // check. 657 // check.
558 app_bundle->put_parentHWND( 658 app_bundle->put_parentHWND(
559 reinterpret_cast<ULONG_PTR>(elevation_window_)); 659 reinterpret_cast<ULONG_PTR>(elevation_window_));
560 } 660 }
561 app_bundle_.swap(app_bundle);
562 }
563
564 // Get a reference to the Chrome app in the bundle.
565 if (!app_) {
566 base::string16 app_guid = 661 base::string16 app_guid =
567 installer::GetAppGuidForUpdates(system_level_install_); 662 installer::GetAppGuidForUpdates(system_level_install_);
568 DCHECK(!app_guid.empty()); 663 DCHECK(!app_guid.empty());
569 664
570 base::win::ScopedComPtr<IDispatch> dispatch;
571 // It is common for this call to fail with APP_USING_EXTERNAL_UPDATER if 665 // It is common for this call to fail with APP_USING_EXTERNAL_UPDATER if
572 // an auto update is in progress. 666 // an auto update is in progress.
573 hresult = app_bundle_->createInstalledApp( 667 hresult =
574 base::win::ScopedBstr(app_guid.c_str())); 668 app_bundle->createInstalledApp(base::win::ScopedBstr(app_guid.c_str()));
575 if (FAILED(hresult)) 669 if (FAILED(hresult))
576 return hresult; 670 return hresult;
577 // Move the IAppBundleWeb reference into a local now so that failures from
578 // this point onward result in it being released.
579 base::win::ScopedComPtr<IAppBundleWeb> app_bundle;
580 app_bundle.swap(app_bundle_);
581 hresult = app_bundle->get_appWeb(0, dispatch.Receive());
582 if (FAILED(hresult))
583 return hresult;
584 base::win::ScopedComPtr<IAppWeb> app;
585 hresult = dispatch.QueryInterface(app.Receive());
586 if (FAILED(hresult))
587 return hresult;
588 ConfigureProxyBlanket(app.get());
589 hresult = app_bundle->checkForUpdate(); 671 hresult = app_bundle->checkForUpdate();
590 if (FAILED(hresult)) 672 if (FAILED(hresult))
591 return hresult; 673 return hresult;
592 app_bundle_.swap(app_bundle); 674
593 app_.swap(app); 675 hresult = app_bundle_cookie_.Register(app_bundle);
676 if (FAILED(hresult))
677 return hresult;
594 } 678 }
595 679
596 return hresult; 680 return hresult;
597 } 681 }
598 682
599 bool UpdateCheckDriver::GetCurrentState( 683 bool UpdateCheckDriver::GetCurrentState(
684 base::win::ScopedComPtr<IAppBundleWeb>* app_bundle,
600 base::win::ScopedComPtr<ICurrentState>* current_state, 685 base::win::ScopedComPtr<ICurrentState>* current_state,
601 CurrentState* state_value, 686 CurrentState* state_value,
602 HRESULT* hresult) const { 687 HRESULT* hresult) const {
688 // Get the bundle being checked or updated.
689 *hresult = app_bundle_cookie_.Get(app_bundle);
690 if (FAILED(*hresult))
691 return false;
692
693 // Get Chrome's app from the bundle.
603 base::win::ScopedComPtr<IDispatch> dispatch; 694 base::win::ScopedComPtr<IDispatch> dispatch;
604 *hresult = app_->get_currentState(dispatch.Receive()); 695 *hresult = (*app_bundle)->get_appWeb(0, dispatch.Receive());
696 if (FAILED(*hresult))
697 return false;
698 base::win::ScopedComPtr<IAppWeb> app;
699 *hresult = dispatch.QueryInterface(app.Receive());
700 if (FAILED(*hresult))
701 return false;
702 dispatch.Release();
703 ConfigureProxyBlanket(app.get());
704
705 // Get the status of Chrome's update check or update.
706 *hresult = app->get_currentState(dispatch.Receive());
605 if (FAILED(*hresult)) 707 if (FAILED(*hresult))
606 return false; 708 return false;
607 *hresult = dispatch.QueryInterface(current_state->Receive()); 709 *hresult = dispatch.QueryInterface(current_state->Receive());
608 if (FAILED(*hresult)) 710 if (FAILED(*hresult))
609 return false; 711 return false;
712 dispatch.Release();
610 ConfigureProxyBlanket(current_state->get()); 713 ConfigureProxyBlanket(current_state->get());
611 LONG value = 0; 714 LONG value = 0;
612 *hresult = (*current_state)->get_stateValue(&value); 715 *hresult = (*current_state)->get_stateValue(&value);
613 if (FAILED(*hresult)) 716 if (FAILED(*hresult))
614 return false; 717 return false;
615 *state_value = static_cast<CurrentState>(value); 718 *state_value = static_cast<CurrentState>(value);
616 return true; 719 return true;
617 } 720 }
618 721
619 bool UpdateCheckDriver::IsErrorState( 722 bool UpdateCheckDriver::IsErrorState(
723 const base::win::ScopedComPtr<IAppBundleWeb>& app_bundle,
620 const base::win::ScopedComPtr<ICurrentState>& current_state, 724 const base::win::ScopedComPtr<ICurrentState>& current_state,
621 CurrentState state_value, 725 CurrentState state_value,
622 GoogleUpdateErrorCode* error_code, 726 GoogleUpdateErrorCode* error_code,
623 HRESULT* hresult, 727 HRESULT* hresult,
624 int* installer_exit_code, 728 int* installer_exit_code,
625 base::string16* error_string) const { 729 base::string16* error_string) const {
626 if (state_value == STATE_ERROR) { 730 if (state_value == STATE_ERROR) {
627 // In general, errors reported by Google Update fall under this category 731 // In general, errors reported by Google Update fall under this category
628 // (see special case below). 732 // (see special case below).
629 *error_code = GOOGLE_UPDATE_ERROR_UPDATING; 733 *error_code = GOOGLE_UPDATE_ERROR_UPDATING;
(...skipping 24 matching lines...) Expand all
654 *installer_exit_code = code; 758 *installer_exit_code = code;
655 } 759 }
656 760
657 base::win::ScopedBstr message; 761 base::win::ScopedBstr message;
658 if (SUCCEEDED(current_state->get_completionMessage(message.Receive()))) 762 if (SUCCEEDED(current_state->get_completionMessage(message.Receive())))
659 error_string->assign(message, message.Length()); 763 error_string->assign(message, message.Length());
660 764
661 return true; 765 return true;
662 } 766 }
663 if (state_value == STATE_UPDATE_AVAILABLE && install_update_if_possible_) { 767 if (state_value == STATE_UPDATE_AVAILABLE && install_update_if_possible_) {
664 *hresult = app_bundle_->install(); 768 *hresult = app_bundle->install();
665 if (FAILED(*hresult)) { 769 if (FAILED(*hresult)) {
666 // Report a failure to start the install as a general error while trying 770 // Report a failure to start the install as a general error while trying
667 // to interact with Google Update. 771 // to interact with Google Update.
668 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR; 772 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR;
669 *installer_exit_code = -1; 773 *installer_exit_code = -1;
670 return true; 774 return true;
671 } 775 }
672 // Return false for handling in IsIntermediateState. 776 // Return false for handling in IsIntermediateState.
673 } 777 }
674 return false; 778 return false;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 case STATE_ERROR: 871 case STATE_ERROR:
768 default: 872 default:
769 NOTREACHED(); 873 NOTREACHED();
770 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.UnexpectedState", state_value); 874 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.UnexpectedState", state_value);
771 return false; 875 return false;
772 } 876 }
773 return true; 877 return true;
774 } 878 }
775 879
776 void UpdateCheckDriver::PollGoogleUpdate() { 880 void UpdateCheckDriver::PollGoogleUpdate() {
881 base::win::ScopedComPtr<IAppBundleWeb> app_bundle;
777 base::win::ScopedComPtr<ICurrentState> state; 882 base::win::ScopedComPtr<ICurrentState> state;
778 CurrentState state_value = STATE_INIT; 883 CurrentState state_value = STATE_INIT;
779 HRESULT hresult = S_OK; 884 HRESULT hresult = S_OK;
780 GoogleUpdateErrorCode error_code = GOOGLE_UPDATE_NO_ERROR; 885 GoogleUpdateErrorCode error_code = GOOGLE_UPDATE_NO_ERROR;
781 int installer_exit_code = -1; 886 int installer_exit_code = -1;
782 base::string16 error_string; 887 base::string16 error_string;
783 GoogleUpdateUpgradeStatus upgrade_status = UPGRADE_ERROR; 888 GoogleUpdateUpgradeStatus upgrade_status = UPGRADE_ERROR;
784 base::string16 new_version; 889 base::string16 new_version;
785 int progress = 0; 890 int progress = 0;
786 891
787 if (!GetCurrentState(&state, &state_value, &hresult)) { 892 if (!GetCurrentState(&app_bundle, &state, &state_value, &hresult)) {
788 OnUpgradeError(GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, hresult, -1, 893 OnUpgradeError(GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, hresult, -1,
789 base::string16()); 894 base::string16());
790 } else if (IsErrorState(state, state_value, &error_code, &hresult, 895 } else if (IsErrorState(app_bundle, state, state_value, &error_code, &hresult,
791 &installer_exit_code, &error_string)) { 896 &installer_exit_code, &error_string)) {
792 OnUpgradeError(error_code, hresult, installer_exit_code, error_string); 897 OnUpgradeError(error_code, hresult, installer_exit_code, error_string);
793 } else if (IsFinalState(state, state_value, &upgrade_status, &new_version)) { 898 } else if (IsFinalState(state, state_value, &upgrade_status, &new_version)) {
794 status_ = upgrade_status; 899 status_ = upgrade_status;
795 error_code_ = GOOGLE_UPDATE_NO_ERROR; 900 error_code_ = GOOGLE_UPDATE_NO_ERROR;
796 html_error_message_.clear(); 901 html_error_message_.clear();
797 if (!new_version.empty()) 902 if (!new_version.empty())
798 new_version_ = new_version; 903 new_version_ = new_version;
799 hresult_ = S_OK; 904 hresult_ = S_OK;
800 installer_exit_code_ = -1; 905 installer_exit_code_ = -1;
(...skipping 16 matching lines...) Expand all
817 // Schedule the next check. 922 // Schedule the next check.
818 task_runner_->PostDelayedTask( 923 task_runner_->PostDelayedTask(
819 FROM_HERE, base::Bind(&UpdateCheckDriver::PollGoogleUpdate, 924 FROM_HERE, base::Bind(&UpdateCheckDriver::PollGoogleUpdate,
820 base::Unretained(this)), 925 base::Unretained(this)),
821 base::TimeDelta::FromMilliseconds(kGoogleUpdatePollIntervalMs)); 926 base::TimeDelta::FromMilliseconds(kGoogleUpdatePollIntervalMs));
822 // Early return for this non-terminal state. 927 // Early return for this non-terminal state.
823 return; 928 return;
824 } 929 }
825 930
826 // Release the reference on the COM objects before bouncing back to the 931 // Release the reference on the COM objects before bouncing back to the
827 // caller's thread. 932 // caller's sequence.
828 state.Release(); 933 state.Release();
829 app_.Release(); 934 app_bundle.Release();
830 app_bundle_.Release(); 935 app_bundle_cookie_.Revoke();
831 google_update_.Release(); 936 google_update_cookie_.Revoke();
832 937
833 result_runner_->DeleteSoon(FROM_HERE, this); 938 result_runner_->DeleteSoon(FROM_HERE, this);
834 } 939 }
835 940
836 void UpdateCheckDriver::OnUpgradeError(GoogleUpdateErrorCode error_code, 941 void UpdateCheckDriver::OnUpgradeError(GoogleUpdateErrorCode error_code,
837 HRESULT hresult, 942 HRESULT hresult,
838 int installer_exit_code, 943 int installer_exit_code,
839 const base::string16& error_string) { 944 const base::string16& error_string) {
840 status_ = UPGRADE_ERROR; 945 status_ = UPGRADE_ERROR;
841 error_code_ = error_code; 946 error_code_ = error_code;
(...skipping 16 matching lines...) Expand all
858 html_error_msg += base::StringPrintf(L": %d", installer_exit_code_); 963 html_error_msg += base::StringPrintf(L": %d", installer_exit_code_);
859 if (system_level_install_) 964 if (system_level_install_)
860 html_error_msg += L" -- system level"; 965 html_error_msg += L" -- system level";
861 if (error_string.empty()) { 966 if (error_string.empty()) {
862 html_error_message_ = l10n_util::GetStringFUTF16( 967 html_error_message_ = l10n_util::GetStringFUTF16(
863 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, html_error_msg); 968 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, html_error_msg);
864 } else { 969 } else {
865 html_error_message_ = l10n_util::GetStringFUTF16( 970 html_error_message_ = l10n_util::GetStringFUTF16(
866 IDS_ABOUT_BOX_GOOGLE_UPDATE_ERROR, error_string, html_error_msg); 971 IDS_ABOUT_BOX_GOOGLE_UPDATE_ERROR, error_string, html_error_msg);
867 } 972 }
973
974 app_bundle_cookie_.Revoke();
975 google_update_cookie_.Revoke();
868 } 976 }
869 977
870 } // namespace 978 } // namespace
871 979
872 980
873 // Globals --------------------------------------------------------------------- 981 // Globals ---------------------------------------------------------------------
874 982
875 void BeginUpdateCheck( 983 void BeginUpdateCheck(scoped_refptr<base::SequencedTaskRunner> task_runner,
876 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 984 const std::string& locale,
877 const std::string& locale, 985 bool install_update_if_possible,
878 bool install_update_if_possible, 986 gfx::AcceleratedWidget elevation_window,
879 gfx::AcceleratedWidget elevation_window, 987 const base::WeakPtr<UpdateCheckDelegate>& delegate) {
880 const base::WeakPtr<UpdateCheckDelegate>& delegate) {
881 UpdateCheckDriver::RunUpdateCheck(std::move(task_runner), locale, 988 UpdateCheckDriver::RunUpdateCheck(std::move(task_runner), locale,
882 install_update_if_possible, 989 install_update_if_possible,
883 elevation_window, delegate); 990 elevation_window, delegate);
884 } 991 }
885 992
886 993
887 // Private API exposed for testing. -------------------------------------------- 994 // Private API exposed for testing. --------------------------------------------
888 995
889 void SetGoogleUpdateFactoryForTesting( 996 void SetUpdateCheckFactoriesForTesting(
997 const GlobalInterfaceTableClassFactory& git_factory,
890 const GoogleUpdate3ClassFactory& google_update_factory) { 998 const GoogleUpdate3ClassFactory& google_update_factory) {
999 if (g_git_factory) {
1000 delete g_git_factory;
1001 g_git_factory = nullptr;
1002 }
1003 if (!git_factory.is_null())
1004 g_git_factory = new GlobalInterfaceTableClassFactory(git_factory);
1005
891 if (g_google_update_factory) { 1006 if (g_google_update_factory) {
892 delete g_google_update_factory; 1007 delete g_google_update_factory;
893 g_google_update_factory = nullptr; 1008 g_google_update_factory = nullptr;
894 } 1009 }
895 if (!google_update_factory.is_null()) { 1010 if (!google_update_factory.is_null()) {
896 g_google_update_factory = 1011 g_google_update_factory =
897 new GoogleUpdate3ClassFactory(google_update_factory); 1012 new GoogleUpdate3ClassFactory(google_update_factory);
898 } 1013 }
899 } 1014 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698