evergreen: customize installation of updates#10036
evergreen: customize installation of updates#10036yuying-y wants to merge 1 commit intoyoutube:mainfrom
Conversation
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
There was a problem hiding this comment.
Code Review
This pull request introduces Starboard-specific installation logic into the update_client component, enabling Cobalt slot management and version persistence. The review feedback highlights several critical issues regarding object lifetime management, specifically the need to use scoped_refptr for the ref-counted PersistedData object to avoid potential use-after-free errors in asynchronous tasks. Additionally, the Starboard implementation currently leaks the unpack_path directory, which must be addressed to prevent disk space exhaustion. There are also several style-related improvements needed to align with Chromium standards, such as using base::NumberToString and correcting indentation.
| scoped_refptr<CrxInstaller> installer, | ||
| CrxInstaller::ProgressCallback progress_callback, | ||
| #if BUILDFLAG(IS_STARBOARD) | ||
| PersistedData* metadata, |
There was a problem hiding this comment.
| if (metadata != nullptr) { | ||
| base::ThreadPool::PostTask( | ||
| FROM_HERE, base::BindOnce( | ||
| &PersistedData::SetLastInstalledEgAndSbVersion, | ||
| base::Unretained(metadata), id, next_version, | ||
| std::to_string(SB_API_VERSION))); |
There was a problem hiding this comment.
There are several issues in this block:
PersistedDatais a ref-counted object. Usingbase::Unretained(metadata)in aPostTaskis unsafe asmetadatamight be destroyed before the task executes. Passing it as ascoped_refptrensures the object stays alive.- Chromium style prefers
base::NumberToStringoverstd::to_stringfor numeric conversions.
if (metadata) {
base::ThreadPool::PostTask(
FROM_HERE, base::BindOnce(
&PersistedData::SetLastInstalledEgAndSbVersion,
metadata, id, next_version,
base::NumberToString(SB_API_VERSION)));
}| install_error = InstallError::GENERIC_ERROR; | ||
| } | ||
| } | ||
| std::move(callback).Run(CrxInstaller::Result(install_error)); |
There was a problem hiding this comment.
The Starboard implementation of Install appears to leak the unpack_path directory. In the standard implementation (lines 215-240), a CallbackChecker is used to ensure that result.unpack_path is deleted after the installation completes. The Starboard path should also ensure this directory is cleaned up to avoid leaking disk space on every update.
| scoped_refptr<CrxInstaller> installer, | ||
| std::unique_ptr<CrxInstaller::InstallParams> install_params, | ||
| #if BUILDFLAG(IS_STARBOARD) | ||
| PersistedData* metadata, |
There was a problem hiding this comment.
| std::string* crx_str, | ||
| #endif | ||
| #if BUILDFLAG(IS_STARBOARD) | ||
| PersistedData* metadata, |
| const auto installation_api = | ||
| static_cast<const CobaltExtensionInstallationManagerApi*>( | ||
| SbSystemGetExtension(kCobaltExtensionInstallationManagerName)); |
There was a problem hiding this comment.
The indentation of the wrapped static_cast and its arguments does not follow the Chromium style guide (which uses 4 spaces for wrapped lines). Additionally, per Chromium style, auto* should be used for pointer types when the type is clear from the context.
const auto* installation_api =
static_cast<const CobaltExtensionInstallationManagerApi*>(
SbSystemGetExtension(kCobaltExtensionInstallationManagerName));| } else if (CobaltFinishInstallation(installation_api, crx_operation_result.installation_index, | ||
| result.unpack_path.value(), app_key)) { |
There was a problem hiding this comment.
The indentation of the arguments for CobaltFinishInstallation is incorrect. Wrapped arguments should be aligned with the first argument or indented by 4 spaces relative to the start of the function call.
} else if (CobaltFinishInstallation(
installation_api, crx_operation_result.installation_index,
result.unpack_path.value(), app_key)) {
This change introduces logic to finalize installations using the Starboard
API and ensures proper cleanup of installation artifacts, such as drain
files, if unpacking fails. It also persists the installed Evergreen and
Starboard API versions, enabling better tracking of system state.
Issue: 479816505