diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 18:40:53 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 18:40:53 +0000 |
commit | 12126d37c6fafd799821164a00bf1fdd240b9ec3 (patch) | |
tree | 8a029e133da6d9ad82265b03dc930045b3ffd046 /chrome/installer | |
parent | 26807c6123b72a2ab30ff3fb2d5ab1e154fc3585 (diff) | |
download | chromium_src-12126d37c6fafd799821164a00bf1fdd240b9ec3.zip chromium_src-12126d37c6fafd799821164a00bf1fdd240b9ec3.tar.gz chromium_src-12126d37c6fafd799821164a00bf1fdd240b9ec3.tar.bz2 |
Remove two deprecated methods from base::Version
BUG=none
TEST=none
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10683005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146157 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/setup/install_worker_unittest.cc | 16 | ||||
-rw-r--r-- | chrome/installer/setup/setup_main.cc | 8 | ||||
-rw-r--r-- | chrome/installer/setup/setup_util.cc | 6 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/installer/util/install_util.cc | 29 | ||||
-rw-r--r-- | chrome/installer/util/install_util.h | 23 | ||||
-rw-r--r-- | chrome/installer/util/installation_state.cc | 15 | ||||
-rw-r--r-- | chrome/installer/util/installation_validator_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/installer/util/installer_state.cc | 12 | ||||
-rw-r--r-- | chrome/installer/util/installer_state_unittest.cc | 52 | ||||
-rw-r--r-- | chrome/installer/util/product_unittest.cc | 9 |
11 files changed, 87 insertions, 90 deletions
diff --git a/chrome/installer/setup/install_worker_unittest.cc b/chrome/installer/setup/install_worker_unittest.cc index a683b0c..9a09805 100644 --- a/chrome/installer/setup/install_worker_unittest.cc +++ b/chrome/installer/setup/install_worker_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -165,8 +165,8 @@ class MockInstallerState : public InstallerState { class InstallWorkerTest : public testing::Test { public: virtual void SetUp() { - current_version_.reset(Version::GetVersionFromString("1.0.0.0")); - new_version_.reset(Version::GetVersionFromString("42.0.0.0")); + current_version_.reset(new Version("1.0.0.0")); + new_version_.reset(new Version("42.0.0.0")); // Don't bother ensuring that these paths exist. Since we're just // building the work item lists and not running them, they shouldn't @@ -190,7 +190,7 @@ class InstallWorkerTest : public testing::Test { if (installation_state->GetProductState( system_level, BrowserDistribution::CHROME_BINARIES) == NULL) { MockProductState product_state; - product_state.set_version(current_version_->Clone()); + product_state.set_version(new Version(*current_version_)); installation_state->SetProductState(system_level, BrowserDistribution::CHROME_BINARIES, product_state); @@ -205,7 +205,7 @@ class InstallWorkerTest : public testing::Test { if (multi_install) MaybeAddBinariesToInstallationState(system_level, installation_state); MockProductState product_state; - product_state.set_version(current_version_->Clone()); + product_state.set_version(new Version(*current_version_)); product_state.set_multi_install(multi_install); product_state.set_brand(L"TEST"); product_state.set_eula_accepted(1); @@ -244,7 +244,7 @@ class InstallWorkerTest : public testing::Test { if (multi_install) MaybeAddBinariesToInstallationState(system_level, installation_state); MockProductState product_state; - product_state.set_version(current_version_->Clone()); + product_state.set_version(new Version(*current_version_)); product_state.set_multi_install(multi_install); BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( @@ -498,7 +498,7 @@ TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) { BuildChromeInstallationState(system_level, false)); MockProductState cf_state; - cf_state.set_version(current_version_->Clone()); + cf_state.set_version(new Version(*current_version_)); cf_state.set_multi_install(false); installation_state->SetProductState(system_level, @@ -571,7 +571,7 @@ TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) { BuildChromeInstallationState(system_level, multi_install)); MockProductState chrome_state; - chrome_state.set_version(current_version_->Clone()); + chrome_state.set_version(new Version(*current_version_)); chrome_state.set_multi_install(false); chrome_state.set_usagestats(1); diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 2010e4c..7925d79 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -1092,16 +1092,16 @@ bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, BrowserDistribution* browser_dist = product->distribution(); // We started as system-level and have been re-launched as user level // to continue with the toast experiment. - scoped_ptr<Version> installed_version( - InstallUtil::GetChromeVersion(browser_dist, true)); - if (!installed_version.get()) { + Version installed_version; + InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); + if (!installed_version.IsValid()) { LOG(ERROR) << "No installation of " << browser_dist->GetAppShortCutName() << " found for system-level toast."; } else { browser_dist->LaunchUserExperiment(cmd_line.GetProgram(), installer::REENTRY_SYS_UPDATE, - *installed_version, *product, true); + installed_version, *product, true); } } } else if (cmd_line.HasSwitch( diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc index 768ac10..340ede9 100644 --- a/chrome/installer/setup/setup_util.cc +++ b/chrome/installer/setup/setup_util.cc @@ -61,7 +61,7 @@ Version* GetMaxVersionFromArchiveDir(const FilePath& chrome_path) { // TODO(tommi): The version directory really should match the version of // setup.exe. To begin with, we should at least DCHECK that that's true. - scoped_ptr<Version> max_version(Version::GetVersionFromString("0.0.0.0")); + scoped_ptr<Version> max_version(new Version("0.0.0.0")); bool version_found = false; while (!version_enum.Next().empty()) { @@ -70,8 +70,8 @@ Version* GetMaxVersionFromArchiveDir(const FilePath& chrome_path) { VLOG(1) << "directory found: " << find_data.cFileName; scoped_ptr<Version> found_version( - Version::GetVersionFromString(WideToASCII(find_data.cFileName))); - if (found_version.get() != NULL && + new Version(WideToASCII(find_data.cFileName))); + if (found_version->IsValid() && found_version->CompareTo(*max_version.get()) > 0) { max_version.reset(found_version.release()); version_found = true; diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index cec1421..de3f2e3 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -398,7 +398,7 @@ TEST_F(GoogleUpdateSettingsTest, SetEULAConsent) { // Chrome is installed. machine_state.AddChrome(system_level, multi_install, - Version::GetVersionFromString(chrome::kChromeVersion)); + new Version(chrome::kChromeVersion)); RegKey key; DWORD value; diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index bb10265..6b327f8 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -171,8 +171,9 @@ CommandLine InstallUtil::GetChromeUninstallCmd( return CommandLine(CommandLine::NO_PROGRAM); } -Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, - bool system_install) { +void InstallUtil::GetChromeVersion(BrowserDistribution* dist, + bool system_install, + Version* version) { DCHECK(dist); RegKey key; HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; @@ -183,22 +184,21 @@ Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, if (result == ERROR_SUCCESS) result = key.ReadValue(google_update::kRegVersionField, &version_str); - Version* ret = NULL; + *version = Version(); if (result == ERROR_SUCCESS && !version_str.empty()) { VLOG(1) << "Existing " << dist->GetAppShortCutName() << " version found " << version_str; - ret = Version::GetVersionFromString(WideToASCII(version_str)); + *version = Version(WideToASCII(version_str)); } else { DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); VLOG(1) << "No existing " << dist->GetAppShortCutName() << " install found."; } - - return ret; } -Version* InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, - bool system_install) { +void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, + bool system_install, + Version* version) { DCHECK(dist); RegKey key; HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; @@ -210,18 +210,16 @@ Version* InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, result = key.ReadValue(google_update::kRegCriticalVersionField, &version_str); - Version* ret = NULL; + *version = Version(); if (result == ERROR_SUCCESS && !version_str.empty()) { VLOG(1) << "Critical Update version for " << dist->GetAppShortCutName() << " found " << version_str; - ret = Version::GetVersionFromString(WideToASCII(version_str)); + *version = Version(WideToASCII(version_str)); } else { DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); VLOG(1) << "No existing " << dist->GetAppShortCutName() << " install found."; } - - return ret; } bool InstallUtil::IsOSSupported() { @@ -345,14 +343,15 @@ bool InstallUtil::HasDelegateExecuteHandler(BrowserDistribution* dist, const string16& chrome_exe) { bool found = false; bool system_install = !IsPerUserInstall(chrome_exe.c_str()); - scoped_ptr<Version> version(GetChromeVersion(dist, system_install)); - if (!version.get()) { + Version version; + GetChromeVersion(dist, system_install, &version); + if (!version.IsValid()) { LOG(ERROR) << __FUNCTION__ << " failed to determine version of " << dist->GetAppShortCutName() << " installed at " << chrome_exe; } else { FilePath handler( FilePath(chrome_exe).DirName() - .AppendASCII(version->GetString()) + .AppendASCII(version.GetString()) .Append(installer::kDelegateExecuteExe)); found = file_util::PathExists(handler); } diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h index 682290f..c3232bd 100644 --- a/chrome/installer/util/install_util.h +++ b/chrome/installer/util/install_util.h @@ -39,20 +39,23 @@ class InstallUtil { BrowserDistribution::Type distribution_type); // Find the version of Chrome installed on the system by checking the - // Google Update registry key. Returns the version or NULL if no version is - // found. + // Google Update registry key. Fills |version| with the version or a + // default-constructed Version if no version is found. // system_install: if true, looks for version number under the HKLM root, // otherwise looks under the HKCU. - static Version* GetChromeVersion(BrowserDistribution* dist, - bool system_install); - - // Find the last critical update (version) of Chrome. Returns the version or - // NULL if no such version is found. A critical update is a specially flagged - // version (by Google Update) that contains an important security fix. + static void GetChromeVersion(BrowserDistribution* dist, + bool system_install, + Version* version); + + // Find the last critical update (version) of Chrome. Fills |version| with the + // version or a default-constructed Version if no version is found. A critical + // update is a specially flagged version (by Google Update) that contains an + // important security fix. // system_install: if true, looks for version number under the HKLM root, // otherwise looks under the HKCU. - static Version* GetCriticalUpdateVersion(BrowserDistribution* dist, - bool system_install); + static void GetCriticalUpdateVersion(BrowserDistribution* dist, + bool system_install, + Version* version); // This function checks if the current OS is supported for Chromium. static bool IsOSSupported(); diff --git a/chrome/installer/util/installation_state.cc b/chrome/installer/util/installation_state.cc index ab09924..6f12eb7 100644 --- a/chrome/installer/util/installation_state.cc +++ b/chrome/installer/util/installation_state.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -60,7 +60,9 @@ bool ProductState::Initialize(bool system_install, std::wstring version_str; if (key.ReadValue(google_update::kRegVersionField, &version_str) == ERROR_SUCCESS) { - version_.reset(Version::GetVersionFromString(WideToASCII(version_str))); + version_.reset(new Version(WideToASCII(version_str))); + if (!version_->IsValid()) + version_.reset(); } // Attempt to read the other values even if the "pv" version value was @@ -68,8 +70,9 @@ bool ProductState::Initialize(bool system_install, // only be accessible via InstallationState::GetNonVersionedProductState. if (key.ReadValue(google_update::kRegOldVersionField, &version_str) == ERROR_SUCCESS) { - old_version_.reset( - Version::GetVersionFromString(WideToASCII(version_str))); + old_version_.reset(new Version(WideToASCII(version_str))); + if (!old_version_->IsValid()) + old_version_.reset(); } key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd_); @@ -151,9 +154,9 @@ const Version& ProductState::version() const { ProductState& ProductState::CopyFrom(const ProductState& other) { channel_.set_value(other.channel_.value()); - version_.reset(other.version_.get() == NULL ? NULL : other.version_->Clone()); + version_.reset(other.version_.get() ? new Version(*other.version_) : NULL); old_version_.reset( - other.old_version_.get() == NULL ? NULL : other.old_version_->Clone()); + other.old_version_.get() ? new Version(*other.old_version_) : NULL); brand_ = other.brand_; rename_cmd_ = other.rename_cmd_; uninstall_command_ = other.uninstall_command_; diff --git a/chrome/installer/util/installation_validator_unittest.cc b/chrome/installer/util/installation_validator_unittest.cc index f4ff1e5..56e854c 100644 --- a/chrome/installer/util/installation_validator_unittest.cc +++ b/chrome/installer/util/installation_validator_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -154,8 +154,7 @@ void FakeProductState::SetChannel(const wchar_t* base, int channel_modifiers) { } void FakeProductState::SetVersion(const char* version) { - version_.reset( - version == NULL ? NULL : Version::GetVersionFromString(version)); + version_.reset(version == NULL ? NULL : new Version(version)); } // Sets the uninstall command for this object. diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index 24572be..34ceff4 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -412,7 +412,7 @@ Version* InstallerState::GetCurrentVersion( if (version == NULL) version = &product_state->version(); - current_version.reset(version->Clone()); + current_version.reset(new Version(*version)); } return current_version.release(); @@ -467,7 +467,7 @@ void InstallerState::RemoveOldVersionDirectories( const Version& new_version, Version* existing_version, const FilePath& temp_path) const { - scoped_ptr<Version> version; + Version version; std::vector<FilePath> key_files; scoped_ptr<WorkItem> item; @@ -478,12 +478,12 @@ void InstallerState::RemoveOldVersionDirectories( for (FilePath next_version = version_enum.Next(); !next_version.empty(); next_version = version_enum.Next()) { FilePath dir_name(next_version.BaseName()); - version.reset(Version::GetVersionFromString(WideToASCII(dir_name.value()))); + version = Version(WideToASCII(dir_name.value())); // Delete the version folder if it is less than the new version and not // equal to the old version (if we have an old version). - if (version.get() && - version->CompareTo(new_version) < 0 && - (existing_version == NULL || !version->Equals(*existing_version))) { + if (version.IsValid() && + version.CompareTo(new_version) < 0 && + (existing_version == NULL || !version.Equals(*existing_version))) { // Collect the key files (relative to the version dir) for all products. key_files.clear(); std::for_each(products_.begin(), products_.end(), diff --git a/chrome/installer/util/installer_state_unittest.cc b/chrome/installer/util/installer_state_unittest.cc index 5029699..316a052 100644 --- a/chrome/installer/util/installer_state_unittest.cc +++ b/chrome/installer/util/installer_state_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -136,12 +136,11 @@ TEST_F(InstallerStateTest, Delete) { MockInstallerState installer_state; BuildSingleChromeState(chrome_dir, &installer_state); - scoped_ptr<Version> latest_version(Version::GetVersionFromString("1.0.4.0")); + Version latest_version("1.0.4.0"); { ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - installer_state.RemoveOldVersionDirectories(*latest_version.get(), - NULL, + installer_state.RemoveOldVersionDirectories(latest_version, NULL, temp_dir.path()); } @@ -217,14 +216,13 @@ TEST_F(InstallerStateTest, DeleteInUsed) { MockInstallerState installer_state; BuildSingleChromeState(chrome_dir, &installer_state); - scoped_ptr<Version> latest_version(Version::GetVersionFromString("1.0.4.0")); - scoped_ptr<Version> existing_version( - Version::GetVersionFromString("1.0.1.0")); + Version latest_version("1.0.4.0"); + Version existing_version("1.0.1.0"); { ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - installer_state.RemoveOldVersionDirectories(*latest_version.get(), - existing_version.get(), + installer_state.RemoveOldVersionDirectories(latest_version, + &existing_version, temp_dir.path()); } @@ -262,19 +260,18 @@ TEST_F(InstallerStateTest, Basic) { const char kOldVersion[] = "1.2.3.4"; const char kNewVersion[] = "2.3.4.5"; - scoped_ptr<Version> new_version(Version::GetVersionFromString(kNewVersion)); - scoped_ptr<Version> old_version(Version::GetVersionFromString(kOldVersion)); - ASSERT_TRUE(new_version.get() != NULL); - ASSERT_TRUE(old_version.get() != NULL); + Version new_version(kNewVersion); + Version old_version(kOldVersion); + ASSERT_TRUE(new_version.IsValid()); + ASSERT_TRUE(old_version.IsValid()); - FilePath installer_dir( - installer_state.GetInstallerDirectory(*new_version.get())); + FilePath installer_dir(installer_state.GetInstallerDirectory(new_version)); EXPECT_FALSE(installer_dir.empty()); FilePath new_version_dir(installer_state.target_path().Append( - UTF8ToWide(new_version->GetString()))); + UTF8ToWide(new_version.GetString()))); FilePath old_version_dir(installer_state.target_path().Append( - UTF8ToWide(old_version->GetString()))); + UTF8ToWide(old_version.GetString()))); EXPECT_FALSE(file_util::PathExists(new_version_dir)); EXPECT_FALSE(file_util::PathExists(old_version_dir)); @@ -304,7 +301,7 @@ TEST_F(InstallerStateTest, Basic) { // Don't explicitly tell the directory cleanup logic not to delete the // old version, rely on the key files to keep it around. - installer_state.RemoveOldVersionDirectories(*new_version.get(), + installer_state.RemoveOldVersionDirectories(new_version, NULL, temp_dir.path()); @@ -315,7 +312,7 @@ TEST_F(InstallerStateTest, Basic) { // Now close the file handle to make it possible to delete our key file. file.Close(); - installer_state.RemoveOldVersionDirectories(*new_version.get(), + installer_state.RemoveOldVersionDirectories(new_version, NULL, temp_dir.path()); // The new directory should still exist. @@ -343,8 +340,7 @@ TEST_F(InstallerStateTest, WithProduct) { EXPECT_EQ(system_level, installer_state.system_install()); const char kCurrentVersion[] = "1.2.3.4"; - scoped_ptr<Version> current_version( - Version::GetVersionFromString(kCurrentVersion)); + Version current_version(kCurrentVersion); HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; EXPECT_EQ(root, installer_state.root_key()); @@ -358,15 +354,13 @@ TEST_F(InstallerStateTest, WithProduct) { EXPECT_TRUE(chrome_key.Valid()); if (chrome_key.Valid()) { chrome_key.WriteValue(google_update::kRegVersionField, - UTF8ToWide(current_version->GetString()).c_str()); + UTF8ToWide(current_version.GetString()).c_str()); machine_state.Initialize(); // TODO(tommi): Also test for when there exists a new_chrome.exe. - scoped_ptr<Version> found_version(installer_state.GetCurrentVersion( - machine_state)); - EXPECT_TRUE(found_version.get() != NULL); - if (found_version.get()) { - EXPECT_TRUE(current_version->Equals(*found_version)); - } + Version found_version(*installer_state.GetCurrentVersion(machine_state)); + EXPECT_TRUE(found_version.IsValid()); + if (found_version.IsValid()) + EXPECT_TRUE(current_version.Equals(found_version)); } } } @@ -454,7 +448,7 @@ TEST_F(InstallerStateTest, GetCurrentVersionMigrateChrome) { // Pretend that this version of single-install Chrome is already installed. machine_state.AddChrome(system_install, false, - Version::GetVersionFromString(chrome::kChromeVersion)); + new Version(chrome::kChromeVersion)); // Now we're invoked to install multi Chrome. CommandLine cmd_line( diff --git a/chrome/installer/util/product_unittest.cc b/chrome/installer/util/product_unittest.cc index b96bba4..8fa3aed 100644 --- a/chrome/installer/util/product_unittest.cc +++ b/chrome/installer/util/product_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -98,10 +98,9 @@ TEST_F(ProductTest, MAYBE_ProductInstallBasic) { ASSERT_TRUE(version_key.Valid()); const char kCurrentVersion[] = "1.2.3.4"; - scoped_ptr<Version> current_version( - Version::GetVersionFromString(kCurrentVersion)); + Version current_version(kCurrentVersion); version_key.WriteValue(google_update::kRegVersionField, - UTF8ToWide(current_version->GetString()).c_str()); + UTF8ToWide(current_version.GetString()).c_str()); // We started out with a non-msi product. machine_state.Initialize(); @@ -109,7 +108,7 @@ TEST_F(ProductTest, MAYBE_ProductInstallBasic) { machine_state.GetProductState(system_level, distribution->GetType()); EXPECT_TRUE(chrome_state != NULL); if (chrome_state != NULL) { - EXPECT_TRUE(chrome_state->version().Equals(*current_version.get())); + EXPECT_TRUE(chrome_state->version().Equals(current_version)); EXPECT_FALSE(chrome_state->is_msi()); } |