Skip to content

Commit

Permalink
Add starboard version check to Evergreen updater.
Browse files Browse the repository at this point in the history
b/369218154

Change-Id: Ia5d4240f3b992131577d8d0063cffec5c4169ee6
  • Loading branch information
yjzhang111 committed Oct 22, 2024
1 parent 1e7bfb9 commit 4882340
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
6 changes: 4 additions & 2 deletions components/update_client/component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ void InstallOnBlockingTaskRunner(
// Write the version of the unpacked update package to the persisted data.
if (metadata != nullptr) {
main_task_runner->PostTask(
FROM_HERE, base::BindOnce(&PersistedData::SetLastInstalledVersion,
base::Unretained(metadata), id, version));
FROM_HERE, base::BindOnce(
&PersistedData::SetLastInstalledEgAndSbVersion,
base::Unretained(metadata), id, version,
std::to_string(SB_API_VERSION)));
}
} else {

Expand Down
12 changes: 9 additions & 3 deletions components/update_client/persisted_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ std::string PersistedData::GetPingFreshness(const std::string& id) const {
}

#if defined(STARBOARD)
std::string PersistedData::GetLastInstalledSbVersion(const std::string& id) const {
return GetString(id, "sbversion");
}

std::string PersistedData::GetLastInstalledVersion(const std::string& id) const {
return GetString(id, "version");
}
Expand Down Expand Up @@ -149,9 +153,11 @@ void PersistedData::SetString(const std::string& id,
}

#if defined(STARBOARD)
void PersistedData::SetLastInstalledVersion(const std::string& id,
const std::string& version) {
SetString(id, "version", version);
void PersistedData::SetLastInstalledEgAndSbVersion(const std::string& id,
const std::string& eg_version,
const std::string& sb_version) {
SetString(id, "version", eg_version);
SetString(id, "sbversion", sb_version);
}
void PersistedData::SetUpdaterChannel(const std::string& id,
const std::string& channel) {
Expand Down
14 changes: 10 additions & 4 deletions components/update_client/persisted_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class PersistedData {
int GetDateLastActive(const std::string& id) const;

#if defined(STARBOARD)
// Returns the starboard version of the last successfully installed update
// for the specified |id|. "" indicates that there is no recorded version value
// for the |id|.
std::string GetLastInstalledSbVersion(const std::string& id) const;

// Returns the version of the update that was last successfully installed for
// the specified |id|. "" indicates that there is no recorded version value
// for the |id|.
Expand Down Expand Up @@ -85,10 +90,11 @@ class PersistedData {
void SetDateLastActive(const std::vector<std::string>& ids, int datenum);

#if defined(STARBOARD)
// Records the version of the update that is successfully installed for
// the specified |id|.
void SetLastInstalledVersion(const std::string& id,
const std::string& version);
// Records the Evergreen version and the starboard version of the update that
// is successfully installed for the specified |id|.
void SetLastInstalledEgAndSbVersion(const std::string& id,
const std::string& eg_version,
const std::string& sb_version);

// Records the updater channel that is set for the specified |id|.
void SetUpdaterChannel(const std::string& id, const std::string& channel);
Expand Down
9 changes: 7 additions & 2 deletions components/update_client/update_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,15 @@ void UpdateCheckerImpl::CheckForUpdatesHelper(

std::string last_installed_version =
GetPersistedData()->GetLastInstalledVersion(app_id);
std::string last_installed_starboard =
GetPersistedData()->GetLastInstalledSbVersion(app_id);
// If the version of the last installed update package is higher than the
// version of the running binary, use the former to indicate the current
// update version in the update check request.
// version of the running binary and the starboard version of the last
// installed update matched the binary currently running, use the last
// installed version to indicate the current update version in the update
// check request.
if (!last_installed_version.empty() &&
last_installed_starboard == std::to_string(SB_API_VERSION) &&
base::Version(last_installed_version).CompareTo(current_version) > 0) {
current_version = base::Version(last_installed_version);
}
Expand Down

0 comments on commit 4882340

Please sign in to comment.