diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-01 06:00:25 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-01 06:00:25 +0000 |
commit | bf6117c7e9b66f3648af83c047a3428d66353451 (patch) | |
tree | 42d42291596c7b70ff1bdace230473277d5a1cd5 /chrome/installer/util/browser_distribution.cc | |
parent | 8a0989f01fff18edb0f56dcc06db2742eb6a1dcb (diff) | |
download | chromium_src-bf6117c7e9b66f3648af83c047a3428d66353451.zip chromium_src-bf6117c7e9b66f3648af83c047a3428d66353451.tar.gz chromium_src-bf6117c7e9b66f3648af83c047a3428d66353451.tar.bz2 |
Refactor the installer to support multi-install.
The installer now does its work based on distributions and target installation paths.
Each distribution has exactly one target installation path but each installation path can have more than one distribution.
In the absense of the --multi-install switch, the installer should continue to work as before.
The biggest difference here is that we don't rely on a single global distribution object that controls the entire installation flow and we have a few classes for the new abstractions instead of global functions.
It's far from perfect, but it's a step towards separating the core file package required for all distributions from the distributions themselves.
Additionally, there are tons of little changes here such as consistant usage of FilePath and CommandLine instead of mixing them with std::wstring.
TEST=Install, uninstall, upgrade, etc. Everything install related.
BUG=61609
Review URL: http://codereview.chromium.org/5172011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67818 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/browser_distribution.cc')
-rw-r--r-- | chrome/installer/util/browser_distribution.cc | 83 |
1 files changed, 60 insertions, 23 deletions
diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc index 2e2ccf2..db98298 100644 --- a/chrome/installer/util/browser_distribution.cc +++ b/chrome/installer/util/browser_distribution.cc @@ -9,10 +9,12 @@ #include "chrome/installer/util/browser_distribution.h" +#include "base/atomicops.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/path_service.h" #include "base/lock.h" +#include "base/logging.h" #include "base/win/registry.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" @@ -25,6 +27,11 @@ #include "installer_util_strings.h" namespace { +// The BrowserDistribution objects are never freed. +BrowserDistribution* g_browser_distribution = NULL; +BrowserDistribution* g_chrome_frame_distribution = NULL; +BrowserDistribution* g_ceee_distribution = NULL; + // Returns true if currently running in npchrome_frame.dll bool IsChromeFrameModule() { FilePath module_path; @@ -41,40 +48,69 @@ bool IsCeeeBrokerProcess() { installer_util::kCeeeBrokerExe); } +BrowserDistribution::DistributionType GetCurrentDistributionType() { + static BrowserDistribution::DistributionType type = + (InstallUtil::IsChromeFrameProcess() || IsChromeFrameModule()) ? + BrowserDistribution::CHROME_FRAME : + (IsCeeeBrokerProcess() ? BrowserDistribution::CEEE : + BrowserDistribution::CHROME_BROWSER); + return type; +} + } // end namespace +template<class DistributionClass> +BrowserDistribution* BrowserDistribution::GetOrCreateBrowserDistribution( + BrowserDistribution** dist) { + if (!*dist) { + DistributionClass* temp = new DistributionClass(); + if (base::subtle::NoBarrier_CompareAndSwap( + reinterpret_cast<base::subtle::AtomicWord*>(dist), NULL, + reinterpret_cast<base::subtle::AtomicWord>(temp)) != NULL) + delete temp; + } + + return *dist; +} + BrowserDistribution* BrowserDistribution::GetDistribution() { - return GetDistribution(InstallUtil::IsChromeFrameProcess() || - IsChromeFrameModule() || - IsCeeeBrokerProcess()); -} - -BrowserDistribution* BrowserDistribution::GetDistribution(bool chrome_frame) { - static BrowserDistribution* dist = NULL; - static Lock dist_lock; - AutoLock lock(dist_lock); - if (dist == NULL) { - if (chrome_frame) { - // TODO(robertshield): Make one of these for Google Chrome vs - // non Google Chrome builds? - dist = new ChromeFrameDistribution(); - } else { + return GetSpecificDistribution(GetCurrentDistributionType()); +} + +// static +BrowserDistribution* BrowserDistribution::GetSpecificDistribution( + BrowserDistribution::DistributionType type) { + BrowserDistribution* dist = NULL; + + // TODO(tommi): initialize g_ceee_distribution when appropriate. Right now + // we treat CEEE as Chrome Frame. + + if (type == CHROME_FRAME || type == CEEE) { + // TODO(robertshield): Make one of these for Google Chrome vs + // non Google Chrome builds? + dist = GetOrCreateBrowserDistribution<ChromeFrameDistribution>( + &g_chrome_frame_distribution); + } else { + DCHECK_EQ(CHROME_BROWSER, type); #if defined(GOOGLE_CHROME_BUILD) if (InstallUtil::IsChromeSxSProcess()) { - dist = new GoogleChromeSxSDistribution(); + dist = GetOrCreateBrowserDistribution<GoogleChromeSxSDistribution>( + &g_browser_distribution); } else { - dist = new GoogleChromeDistribution(); + dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>( + &g_browser_distribution); } #else - dist = new BrowserDistribution(); + dist = GetOrCreateBrowserDistribution<BrowserDistribution>( + &g_browser_distribution); #endif - } } + return dist; } void BrowserDistribution::DoPostUninstallOperations( - const installer::Version& version, const std::wstring& local_data_path, + const installer::Version& version, const FilePath& local_data_path, const std::wstring& distribution_data) { } @@ -116,6 +152,7 @@ std::wstring BrowserDistribution::GetLongAppDescription() { return app_description; } +// static int BrowserDistribution::GetInstallReturnCode( installer_util::InstallStatus status) { switch (status) { @@ -145,7 +182,7 @@ std::wstring BrowserDistribution::GetStatsServerURL() { return L""; } -std::wstring BrowserDistribution::GetDistributionData(base::win::RegKey* key) { +std::wstring BrowserDistribution::GetDistributionData(HKEY root_key) { return L""; } @@ -183,10 +220,10 @@ void BrowserDistribution::UpdateDiffInstallStatus(bool system_install, void BrowserDistribution::LaunchUserExperiment( installer_util::InstallStatus status, const installer::Version& version, - bool system_install) { + const installer::Product& installation, bool system_level) { } void BrowserDistribution::InactiveUserToastExperiment(int flavor, - bool system_install) { + const installer::Product& installation) { } |