Commit 33819cef authored by grt's avatar grt Committed by Commit bot

Multi-install cleanups in setup.

Including:
- Removes the "multi-install" crash key from setup.exe.
- Removes some dead test code.
- Removes duplicated code in IsActivelyUsedIn.

BUG=577816

Review-Url: https://codereview.chromium.org/2619963005
Cr-Commit-Position: refs/heads/master@{#442883}
parent 3861e32a
...@@ -32,7 +32,6 @@ namespace { ...@@ -32,7 +32,6 @@ namespace {
// Crash Keys // Crash Keys
const char kCurrentVersion[] = "current-version"; const char kCurrentVersion[] = "current-version";
const char kIsMultiInstall[] = "multi-install";
const char kIsSystemLevel[] = "system-level"; const char kIsSystemLevel[] = "system-level";
const char kOperation[] = "operation"; const char kOperation[] = "operation";
const char kStateKey[] = "state-key"; const char kStateKey[] = "state-key";
...@@ -105,7 +104,6 @@ size_t RegisterCrashKeys() { ...@@ -105,7 +104,6 @@ size_t RegisterCrashKeys() {
const base::debug::CrashKey kFixedKeys[] = { const base::debug::CrashKey kFixedKeys[] = {
{ crash_keys::kMetricsClientId, crash_keys::kSmallSize }, { crash_keys::kMetricsClientId, crash_keys::kSmallSize },
{ kCurrentVersion, crash_keys::kSmallSize }, { kCurrentVersion, crash_keys::kSmallSize },
{ kIsMultiInstall, crash_keys::kSmallSize },
{ kIsSystemLevel, crash_keys::kSmallSize }, { kIsSystemLevel, crash_keys::kSmallSize },
{ kOperation, crash_keys::kSmallSize }, { kOperation, crash_keys::kSmallSize },
...@@ -126,7 +124,6 @@ void SetInitialCrashKeys(const InstallerState& state) { ...@@ -126,7 +124,6 @@ void SetInitialCrashKeys(const InstallerState& state) {
using base::debug::SetCrashKeyValue; using base::debug::SetCrashKeyValue;
SetCrashKeyValue(kOperation, OperationToString(state.operation())); SetCrashKeyValue(kOperation, OperationToString(state.operation()));
SetCrashKeyValue(kIsMultiInstall, "false");
SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false"); SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false");
const base::string16 state_key = state.state_key(); const base::string16 state_key = state.state_key();
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "chrome/installer/util/fake_installation_state.h" #include "chrome/installer/util/fake_installation_state.h"
#include "chrome/installer/util/fake_product_state.h" #include "chrome/installer/util/fake_product_state.h"
#include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/installation_state.h" #include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/installer_util_strings.h" #include "chrome/installer/util/installer_util_strings.h"
#include "chrome/installer/util/master_preferences.h" #include "chrome/installer/util/master_preferences.h"
...@@ -151,30 +150,6 @@ TEST_F(InstallerStateTest, InstallerResult) { ...@@ -151,30 +150,6 @@ TEST_F(InstallerStateTest, InstallerResult) {
} }
} }
// Test GetCurrentVersion when migrating single Chrome to multi
TEST_F(InstallerStateTest, GetCurrentVersionMigrateChrome) {
using installer::FakeInstallationState;
const bool system_install = false;
FakeInstallationState machine_state;
// Pretend that this version of single-install Chrome is already installed.
machine_state.AddChrome(system_install,
new base::Version(chrome::kChromeVersion));
// Now we're invoked to install multi Chrome.
base::CommandLine cmd_line(
base::CommandLine::FromString(L"setup.exe --multi-install --chrome"));
MasterPreferences prefs(cmd_line);
InstallerState installer_state;
installer_state.Initialize(cmd_line, prefs, machine_state);
// Is the Chrome version picked up?
std::unique_ptr<base::Version> version(
installer_state.GetCurrentVersion(machine_state));
EXPECT_TRUE(version.get() != NULL);
}
TEST_F(InstallerStateTest, InitializeTwice) { TEST_F(InstallerStateTest, InitializeTwice) {
// Override these paths so that they can be found after the registry override // Override these paths so that they can be found after the registry override
// manager is in place. // manager is in place.
...@@ -214,7 +189,7 @@ TEST_F(InstallerStateTest, InitializeTwice) { ...@@ -214,7 +189,7 @@ TEST_F(InstallerStateTest, InitializeTwice) {
EXPECT_EQ(installer_state.state_key(), EXPECT_EQ(installer_state.state_key(),
BrowserDistribution::GetDistribution()->GetStateKey()); BrowserDistribution::GetDistribution()->GetStateKey());
// Now initialize it to install system-level single Chrome. // Now initialize it to install system-level Chrome.
{ {
base::CommandLine cmd_line(base::CommandLine::FromString( base::CommandLine cmd_line(base::CommandLine::FromString(
L"setup.exe --system-level --verbose-logging")); L"setup.exe --system-level --verbose-logging"));
......
...@@ -26,10 +26,8 @@ ...@@ -26,10 +26,8 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/version.h" #include "base/version.h"
#include "base/win/registry.h" #include "base/win/registry.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
...@@ -38,6 +36,7 @@ ...@@ -38,6 +36,7 @@
#include "chrome/installer/setup/user_hive_visitor.h" #include "chrome/installer/setup/user_hive_visitor.h"
#include "chrome/installer/util/app_registration_data.h" #include "chrome/installer/util/app_registration_data.h"
#include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/install_util.h" #include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/installation_state.h" #include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/master_preferences.h" #include "chrome/installer/util/master_preferences.h"
...@@ -73,41 +72,14 @@ base::string16 InstallFullName() { ...@@ -73,41 +72,14 @@ base::string16 InstallFullName() {
// ClientState key for a user) indicates that Chrome has been used within the // ClientState key for a user) indicates that Chrome has been used within the
// last 28 days. // last 28 days.
bool IsActivelyUsedIn(HKEY root, const wchar_t* key_path) { bool IsActivelyUsedIn(HKEY root, const wchar_t* key_path) {
// This duplicates some logic in GoogleUpdateSettings::GetLastRunTime, which
// is suitable for use from the context of Chrome but not from the installer
// because it was implemented with the assumption that
// BrowserDistribution::GetDistribution() will always be the right thing.
// This is true in Chrome, but not in the installer in a multi-install world.
// Once multi-install goes away, this assumption will once again become true
// for the installer, and this new code here can then be deleted.
VLOG(1) << "IsActivelyUsedIn probing " << root << "\\" << key_path; VLOG(1) << "IsActivelyUsedIn probing " << root << "\\" << key_path;
base::win::RegKey key; int days_ago_last_run = GoogleUpdateSettings::GetLastRunTime();
LONG result = key.Open(root, key_path, KEY_WOW64_32KEY | KEY_QUERY_VALUE); if (days_ago_last_run >= 0) {
if (result != ERROR_SUCCESS) { VLOG(1) << "Found a user that last ran Chrome " << days_ago_last_run
::SetLastError(result); << " days ago.";
PLOG_IF(ERROR, result != ERROR_FILE_NOT_FOUND) << "Failed opening " << root return days_ago_last_run <= 28;
<< "\\" << key_path;
return false;
}
base::string16 last_run_time_string;
result =
key.ReadValue(google_update::kRegLastRunTimeField, &last_run_time_string);
if (result != ERROR_SUCCESS) {
::SetLastError(result);
PLOG_IF(ERROR, result != ERROR_FILE_NOT_FOUND)
<< "Failed reading " << root << "\\" << key_path << "@"
<< google_update::kRegLastRunTimeField;
return false;
} }
int64_t last_run_time_value = 0; return false;
if (!base::StringToInt64(last_run_time_string, &last_run_time_value))
return false;
base::Time last_run_time = base::Time::FromInternalValue(last_run_time_value);
int days_ago_last_run =
(base::Time::NowFromSystemTime() - last_run_time).InDays();
VLOG(1) << "Found a user that last ran Chrome " << days_ago_last_run
<< " days ago.";
return days_ago_last_run <= 28;
} }
// A visitor for user hives, run by VisitUserHives. |client_state_path| is the // A visitor for user hives, run by VisitUserHives. |client_state_path| is the
......
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