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

Unified Diff: chrome/installer/setup/install_worker.cc

Issue 869153004: Support migrating multi-install Chrome to single-install. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: verifier fix Created 5 years, 11 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 | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/install_worker.cc
diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc
index d73091468999d797d7028a8e868595b66b831350..3aa98959beec47e9ece8554c74e42893a84c9899 100644
--- a/chrome/installer/setup/install_worker.cc
+++ b/chrome/installer/setup/install_worker.cc
@@ -974,6 +974,58 @@ void AddUsageStatsWorkItems(const InstallationState& original_state,
}
}
+// Migrates the usagestats value from the binaries to Chrome when migrating
+// multi-install Chrome to single-install.
+void AddMigrateUsageStatesWorkItems(const InstallationState& original_state,
+ const InstallerState& installer_state,
+ WorkItemList* install_list) {
+ // Ensure that a non-multi install or update is being processed (i.e.,
+ // no "--multi-install" on the command line).
+ if (installer_state.is_multi_install())
+ return;
+
+ // Ensure that Chrome is the product being installed or updated (there are no
+ // other products, so it is especially unexpected for this to fail).
+ const Product* chrome_product =
+ installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);
+ if (!chrome_product) {
+ LOG(DFATAL) << "Not operating on Chrome while migrating to single-install.";
+ return;
+ }
+
+ const ProductState* chrome_state = original_state.GetProductState(
+ installer_state.system_install(),
+ BrowserDistribution::CHROME_BROWSER);
+ // Bail out if there is not an existing multi-install Chrome that is being
+ // updated.
+ if (!chrome_state || !chrome_state->is_multi_install()) {
+ VLOG(1) << "No multi-install Chrome found to migrate to single-install.";
+ return;
+ }
+
+ const ProductState* binaries_state = original_state.GetProductState(
+ installer_state.system_install(),
+ BrowserDistribution::CHROME_BINARIES);
+
+ // There is nothing to be done if the binaries do not have stats.
+ DWORD usagestats = 0;
+ if (!binaries_state || !binaries_state->GetUsageStats(&usagestats)) {
+ VLOG(1) << "No usagestats value found to migrate to single-install.";
+ return;
+ }
+
+ VLOG(1) << "Migrating usagestats value from multi-install to single-install.";
+
+ // Write the value that was read to Chrome's ClientState key.
+ install_list->AddSetRegValueWorkItem(
+ installer_state.root_key(),
+ chrome_product->distribution()->GetStateKey(),
+ KEY_WOW64_32KEY,
+ google_update::kRegUsageStatsField,
+ usagestats,
+ true);
+}
+
bool AppendPostInstallTasks(const InstallerState& installer_state,
const base::FilePath& setup_path,
const Version* current_version,
@@ -1189,6 +1241,16 @@ void AddInstallWorkItems(const InstallationState& original_state,
install_list);
}
+ // Ensure that the Clients key for the binaries is gone for single installs.
+ if (!installer_state.is_multi_install()) {
+ BrowserDistribution* binaries_dist =
+ BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BINARIES);
+ install_list->AddDeleteRegKeyWorkItem(root,
+ binaries_dist->GetVersionKey(),
+ KEY_WOW64_32KEY);
+ }
+
#if defined(GOOGLE_CHROME_BUILD)
if (!InstallUtil::IsChromeSxSProcess())
AddRemoveLegacyAppCommandsWorkItems(installer_state, install_list);
@@ -1207,6 +1269,9 @@ void AddInstallWorkItems(const InstallationState& original_state,
// Copy over brand, usagestats, and other values.
AddGoogleUpdateWorkItems(original_state, installer_state, install_list);
+ // Migrate usagestats back to Chrome.
+ AddMigrateUsageStatesWorkItems(original_state, installer_state, install_list);
+
// Append the tasks that run after the installation.
AppendPostInstallTasks(installer_state,
setup_path,
« no previous file with comments | « no previous file | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698