Commit f91ea3c8 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Compare w/ active version before installing a new updater version.

If an active version of the updater is detected, and it is greater or
equal than the version of the updater running `--install` then the
setup execution path is skipped, and the code proceeds with
installing the app, if needed.

Otherwise, the code sets up the updater, as before.

Bug: 1141037
Change-Id: I95e78c150acba7a5fadca2140cad4a9c22def5c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490543
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819508}
parent 242f5b07
...@@ -91,6 +91,21 @@ void AppInstall::FirstTaskRun() { ...@@ -91,6 +91,21 @@ void AppInstall::FirstTaskRun() {
splash_screen_ = splash_screen_maker_.Run(); splash_screen_ = splash_screen_maker_.Run();
splash_screen_->Show(); splash_screen_->Show();
// Capture `update_service` to manage the object lifetime.
scoped_refptr<UpdateService> update_service = CreateUpdateService();
update_service->GetVersion(
base::BindOnce(&AppInstall::GetVersionDone, this, update_service));
}
void AppInstall::GetVersionDone(scoped_refptr<UpdateService>,
const base::Version& version) {
VLOG_IF(1, (version.IsValid()))
<< "Found active version: " << version.GetString();
if (version.IsValid() && version >= base::Version(UPDATER_VERSION_STRING)) {
splash_screen_->Dismiss(base::BindOnce(&AppInstall::MaybeInstallApp, this));
return;
}
InstallCandidate( InstallCandidate(
false, false,
base::BindOnce( base::BindOnce(
......
...@@ -16,11 +16,13 @@ ...@@ -16,11 +16,13 @@
namespace base { namespace base {
class TaskRunner; class TaskRunner;
class Version;
} }
namespace updater { namespace updater {
struct RegistrationResponse; struct RegistrationResponse;
class UpdateService;
// This class defines an interface for installing an application. The interface // This class defines an interface for installing an application. The interface
// is intended to be implemented for scenerios where UI and RPC calls to // is intended to be implemented for scenerios where UI and RPC calls to
...@@ -54,6 +56,10 @@ class AppInstall : public App { ...@@ -54,6 +56,10 @@ class AppInstall : public App {
void Initialize() override; void Initialize() override;
void FirstTaskRun() override; void FirstTaskRun() override;
// Called after the version of the active updater has been retrieved.
void GetVersionDone(scoped_refptr<UpdateService>,
const base::Version& version);
void InstallCandidateDone(int result); void InstallCandidateDone(int result);
void WakeCandidate(); void WakeCandidate();
......
...@@ -292,7 +292,6 @@ void UpdateServiceOutOfProcess::GetVersion( ...@@ -292,7 +292,6 @@ void UpdateServiceOutOfProcess::GetVersion(
[](scoped_refptr<base::SequencedTaskRunner> taskrunner, [](scoped_refptr<base::SequencedTaskRunner> taskrunner,
base::OnceCallback<void(const base::Version&)> callback, base::OnceCallback<void(const base::Version&)> callback,
const base::Version& version) { const base::Version& version) {
DCHECK(version.IsValid());
taskrunner->PostTask( taskrunner->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), version)); FROM_HERE, base::BindOnce(std::move(callback), version));
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment