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

Unified Diff: chrome/browser/ui/webui/help/version_updater_win.cc

Issue 1129733003: Fix detection of restart needed in VersionUpdaterWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle shutdown case as UPDATED Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/help/version_updater_win.cc
diff --git a/chrome/browser/ui/webui/help/version_updater_win.cc b/chrome/browser/ui/webui/help/version_updater_win.cc
index 2c59ece83bbb6fd19c57e5e1eec0b674df7846e3..9e47d47e07783cc9f3e51fc18705c79f0be6398d 100644
--- a/chrome/browser/ui/webui/help/version_updater_win.cc
+++ b/chrome/browser/ui/webui/help/version_updater_win.cc
@@ -4,10 +4,11 @@
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
+#include "base/task_runner_util.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/first_run/upgrade_util_win.h"
+#include "chrome/browser/first_run/upgrade_util.h"
#include "chrome/browser/google/google_update_win.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
@@ -49,6 +50,10 @@ class VersionUpdaterWin : public VersionUpdater, public UpdateCheckDelegate {
void BeginUpdateCheckOnFileThread(bool install_update_if_possible);
#endif // GOOGLE_CHROME_BUILD
+ // A task run on the UI thread with the result of checking for a pending
+ // restart.
+ void OnPendingRestartCheck(bool is_update_pending_restart);
+
// The widget owning the UI for the update check.
gfx::AcceleratedWidget owner_widget_;
@@ -99,7 +104,19 @@ void VersionUpdaterWin::OnUpdateCheckComplete(
if (new_version.empty()) {
// Google Update says that no new version is available. Check to see if a
// restart is needed for a previously-applied update to take effect.
- status = upgrade_util::IsRunningOldChrome() ? NEARLY_UPDATED : UPDATED;
+ if (base::PostTaskAndReplyWithResult(
+ content::BrowserThread::GetBlockingPool(),
+ FROM_HERE,
+ base::Bind(&upgrade_util::IsUpdatePendingRestart),
+ base::Bind(&VersionUpdaterWin::OnPendingRestartCheck,
+ weak_factory_.GetWeakPtr()))) {
+ // Early exit since callback_ will be Run in OnPendingRestartCheck.
+ return;
+ }
+ // Failure to post the task means that Chrome is shutting down. A pending
+ // update (if there is one) will be applied as Chrome exits, so tell the
+ // caller that it is up to date in either case.
+ status = UPDATED;
} else {
// Notify the caller that the update is now beginning and initiate it.
status = UPDATING;
@@ -156,6 +173,11 @@ void VersionUpdaterWin::BeginUpdateCheckOnFileThread(
}
#endif // GOOGLE_CHROME_BUILD
+void VersionUpdaterWin::OnPendingRestartCheck(bool is_update_pending_restart) {
+ callback_.Run(is_update_pending_restart ? NEARLY_UPDATED : UPDATED, 0,
+ base::string16());
+}
+
} // namespace
VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698