diff options
author | bauerb <bauerb@chromium.org> | 2015-02-04 17:09:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-05 01:09:55 +0000 |
commit | 810e60f487982e8edc208b78b0b4b2b2a12a77a0 (patch) | |
tree | f76a8cb2498a8e32804fd0a9eb04703ed7a84127 /components/component_updater | |
parent | abfbde8049ea4726e3c750a15aad66c5ab9f5093 (diff) | |
download | chromium_src-810e60f487982e8edc208b78b0b4b2b2a12a77a0.zip chromium_src-810e60f487982e8edc208b78b0b4b2b2a12a77a0.tar.gz chromium_src-810e60f487982e8edc208b78b0b4b2b2a12a77a0.tar.bz2 |
Make ComponentInstaller refcounted.
Before this CL, component installers were leaked in almost all cases. If we allow uninstalling components (see https://codereview.chromium.org/879993005/), we need to fix those leaks.
BUG=436459
Review URL: https://codereview.chromium.org/897873002
Cr-Commit-Position: refs/heads/master@{#314701}
Diffstat (limited to 'components/component_updater')
3 files changed, 13 insertions, 12 deletions
diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc index 4b97bae..89195c4 100644 --- a/components/component_updater/component_updater_service.cc +++ b/components/component_updater/component_updater_service.cc @@ -108,7 +108,7 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { // Context for a crx download url request. struct CRXContext { - ComponentInstaller* installer; + scoped_refptr<ComponentInstaller> installer; std::vector<uint8_t> pk_hash; std::string id; std::string fingerprint; diff --git a/components/component_updater/default_component_installer.cc b/components/component_updater/default_component_installer.cc index 6588973..d73b4fc 100644 --- a/components/component_updater/default_component_installer.cc +++ b/components/component_updater/default_component_installer.cc @@ -55,8 +55,7 @@ void DefaultComponentInstaller::Register(ComponentUpdateService* cus) { task_runner_->PostTask( FROM_HERE, base::Bind(&DefaultComponentInstaller::StartRegistration, - base::Unretained(this), - cus)); + this, cus)); } void DefaultComponentInstaller::OnUpdateError(int error) { @@ -103,11 +102,8 @@ bool DefaultComponentInstaller::Install(const base::DictionaryValue& manifest, current_manifest_->DeepCopy()); main_task_runner_->PostTask( FROM_HERE, - base::Bind(&ComponentInstallerTraits::ComponentReady, - base::Unretained(installer_traits_.get()), - current_version_, - GetInstallDirectory(), - base::Passed(&manifest_copy))); + base::Bind(&DefaultComponentInstaller::ComponentReady, + this, base::Passed(&manifest_copy))); return true; } @@ -197,8 +193,7 @@ void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) { main_task_runner_->PostTask( FROM_HERE, base::Bind(&DefaultComponentInstaller::FinishRegistration, - base::Unretained(this), - cus)); + this, cus)); } base::FilePath DefaultComponentInstaller::GetInstallDirectory() { @@ -230,8 +225,13 @@ void DefaultComponentInstaller::FinishRegistration( scoped_ptr<base::DictionaryValue> manifest_copy( current_manifest_->DeepCopy()); + ComponentReady(manifest_copy.Pass()); +} + +void DefaultComponentInstaller::ComponentReady( + scoped_ptr<base::DictionaryValue> manifest) { installer_traits_->ComponentReady( - current_version_, GetInstallDirectory(), manifest_copy.Pass()); + current_version_, GetInstallDirectory(), manifest.Pass()); } } // namespace component_updater diff --git a/components/component_updater/default_component_installer.h b/components/component_updater/default_component_installer.h index 120d3a5..8a39993 100644 --- a/components/component_updater/default_component_installer.h +++ b/components/component_updater/default_component_installer.h @@ -99,15 +99,16 @@ class DefaultComponentInstaller : public update_client::ComponentInstaller { bool GetInstalledFile(const std::string& file, base::FilePath* installed_file) override; + private: ~DefaultComponentInstaller() override; - private: base::FilePath GetInstallDirectory(); bool InstallHelper(const base::DictionaryValue& manifest, const base::FilePath& unpack_path, const base::FilePath& install_path); void StartRegistration(ComponentUpdateService* cus); void FinishRegistration(ComponentUpdateService* cus); + void ComponentReady(scoped_ptr<base::DictionaryValue> manifest); base::Version current_version_; std::string current_fingerprint_; |