summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-02 15:54:13 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-02 15:54:13 +0000
commit86ecb8e13fab03be788c7c4fa9f06123e3ae3faf (patch)
tree24b8e0b20724a32ab98517237c1f78d34641b185 /chrome/installer
parent7a8f3e97d066af2a82226eb459402d8ea315c099 (diff)
downloadchromium_src-86ecb8e13fab03be788c7c4fa9f06123e3ae3faf.zip
chromium_src-86ecb8e13fab03be788c7c4fa9f06123e3ae3faf.tar.gz
chromium_src-86ecb8e13fab03be788c7c4fa9f06123e3ae3faf.tar.bz2
Start putting stage info into the new InstallerExtraCode1 value in Google Update's installer result API. A future change will stop putting the value in the Google Update "ap" value ("-stage:foo") and clear any stage info laying around.
BUG=none TEST=confirm that the InstallerExtraCode1 rolls along throughout processing and is removed when all is well. Review URL: http://codereview.chromium.org/7027036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/util/install_util.cc17
-rw-r--r--chrome/installer/util/install_util_unittest.cc53
-rw-r--r--chrome/installer/util/util_constants.cc4
-rw-r--r--chrome/installer/util/util_constants.h6
4 files changed, 72 insertions, 8 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index e36fa43..15a9dab 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -195,8 +195,21 @@ void InstallUtil::UpdateInstallerStage(bool system_install,
LONG result = state_key.Open(root, state_key_path.c_str(),
KEY_QUERY_VALUE | KEY_SET_VALUE);
if (result == ERROR_SUCCESS) {
- // TODO(grt): switch to using Google Update's new InstallerExtraCode1 value
- // once it exists. In the meantime, encode the stage into the channel name.
+ if (stage == installer::NO_STAGE) {
+ result = state_key.DeleteValue(installer::kInstallerExtraCode1);
+ LOG_IF(ERROR, result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND)
+ << "Failed deleting installer stage from " << state_key_path
+ << "; result: " << result;
+ } else {
+ const DWORD extra_code_1 = static_cast<DWORD>(stage);
+ result = state_key.WriteValue(installer::kInstallerExtraCode1,
+ extra_code_1);
+ LOG_IF(ERROR, result != ERROR_SUCCESS)
+ << "Failed writing installer stage to " << state_key_path
+ << "; result: " << result;
+ }
+ // TODO(grt): Remove code below here once we're convinced that our use of
+ // Google Update's new InstallerExtraCode1 value is good.
installer::ChannelInfo channel_info;
// This will return false if the "ap" value isn't present, which is fine.
channel_info.Initialize(state_key);
diff --git a/chrome/installer/util/install_util_unittest.cc b/chrome/installer/util/install_util_unittest.cc
index c5654f1..b579746 100644
--- a/chrome/installer/util/install_util_unittest.cc
+++ b/chrome/installer/util/install_util_unittest.cc
@@ -69,7 +69,7 @@ TEST_F(InstallUtilTest, GetCurrentDate) {
}
}
-TEST_F(InstallUtilTest, UpdateInstallerStage) {
+TEST_F(InstallUtilTest, UpdateInstallerStageAP) {
const bool system_level = false;
const HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
std::wstring state_key_path(L"PhonyClientState");
@@ -119,6 +119,57 @@ TEST_F(InstallUtilTest, UpdateInstallerStage) {
TempRegKeyOverride::DeleteAllTempKeys();
}
+TEST_F(InstallUtilTest, UpdateInstallerStage) {
+ const bool system_level = false;
+ const HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ std::wstring state_key_path(L"PhonyClientState");
+
+ // Update the stage when there's no "InstallerExtraCode1" value.
+ {
+ TempRegKeyOverride override(root, L"root_inst_res");
+ RegKey(root, state_key_path.c_str(), KEY_SET_VALUE)
+ .DeleteValue(installer::kInstallerExtraCode1);
+ InstallUtil::UpdateInstallerStage(system_level, state_key_path,
+ installer::BUILDING);
+ DWORD value;
+ EXPECT_EQ(ERROR_SUCCESS,
+ RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE)
+ .ReadValueDW(installer::kInstallerExtraCode1, &value));
+ EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value);
+ }
+ TempRegKeyOverride::DeleteAllTempKeys();
+
+ // Update the stage when there is an "InstallerExtraCode1" value.
+ {
+ TempRegKeyOverride override(root, L"root_inst_res");
+ RegKey(root, state_key_path.c_str(), KEY_SET_VALUE)
+ .WriteValue(installer::kInstallerExtraCode1,
+ static_cast<DWORD>(installer::UNPACKING));
+ InstallUtil::UpdateInstallerStage(system_level, state_key_path,
+ installer::BUILDING);
+ DWORD value;
+ EXPECT_EQ(ERROR_SUCCESS,
+ RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE)
+ .ReadValueDW(installer::kInstallerExtraCode1, &value));
+ EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value);
+ }
+ TempRegKeyOverride::DeleteAllTempKeys();
+
+ // Clear the stage.
+ {
+ TempRegKeyOverride override(root, L"root_inst_res");
+ RegKey(root, state_key_path.c_str(), KEY_SET_VALUE)
+ .WriteValue(installer::kInstallerExtraCode1, static_cast<DWORD>(5));
+ InstallUtil::UpdateInstallerStage(system_level, state_key_path,
+ installer::NO_STAGE);
+ DWORD value;
+ EXPECT_EQ(ERROR_FILE_NOT_FOUND,
+ RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE)
+ .ReadValueDW(installer::kInstallerExtraCode1, &value));
+ }
+ TempRegKeyOverride::DeleteAllTempKeys();
+}
+
TEST_F(InstallUtilTest, DeleteRegistryKeyIf) {
const HKEY root = HKEY_CURRENT_USER;
std::wstring parent_key_path(L"SomeKey\\ToDelete");
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index 63baee9..c65b1de 100644
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -182,13 +182,13 @@ const wchar_t kUninstallArgumentsField[] = L"UninstallArguments";
const wchar_t kUninstallDisplayNameField[] = L"DisplayName";
const char kUninstallMetricsName[] = "uninstall_metrics";
const wchar_t kUninstallInstallationDate[] = L"installation_date";
-const wchar_t kInstallerResult[] = L"InstallerResult";
const wchar_t kInstallerError[] = L"InstallerError";
+const wchar_t kInstallerExtraCode1[] = L"InstallerExtraCode1";
+const wchar_t kInstallerResult[] = L"InstallerResult";
const wchar_t kInstallerResultUIString[] = L"InstallerResultUIString";
const wchar_t kInstallerSuccessLaunchCmdLine[] =
L"InstallerSuccessLaunchCmdLine";
-const wchar_t kOptionCeee[] = L"ceee";
const wchar_t kOptionMultiInstall[] = L"multi-install";
const wchar_t kOptionReadyMode[] = L"ready-mode";
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index cb183f0..3aced6c 100644
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -186,14 +186,14 @@ extern const wchar_t kUninstallInstallationDate[];
extern const char kUninstallMetricsName[];
extern const wchar_t kUninstallStringField[];
-// Used by InstallUtil::WriteInstallerResult.
-extern const wchar_t kInstallerResult[];
+// Google Update installer result API
extern const wchar_t kInstallerError[];
+extern const wchar_t kInstallerExtraCode1[];
+extern const wchar_t kInstallerResult[];
extern const wchar_t kInstallerResultUIString[];
extern const wchar_t kInstallerSuccessLaunchCmdLine[];
// Product options.
-extern const wchar_t kOptionCeee[];
extern const wchar_t kOptionMultiInstall[];
extern const wchar_t kOptionReadyMode[];