Chromium Code Reviews| Index: chrome/browser/component_updater/pnacl/pnacl_component_installer.cc |
| diff --git a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc |
| index c608c35f438f94aa5b097fe8c934bf12e968d003..7ef891ac03dcc1ea48f334c292f7e6118b2af104 100644 |
| --- a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc |
| +++ b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc |
| @@ -191,8 +191,7 @@ bool CheckPnaclComponentManifest(const base::DictionaryValue& manifest, |
| PnaclComponentInstaller::PnaclComponentInstaller() |
| : per_user_(false), |
| updates_disabled_(false), |
| - cus_(NULL), |
| - callback_nums_(0) { |
| + cus_(NULL) { |
| #if defined(OS_CHROMEOS) |
| per_user_ = true; |
| #endif |
| @@ -302,27 +301,14 @@ bool PnaclComponentInstaller::GetInstalledFile( |
| void PnaclComponentInstaller::AddInstallCallback( |
| const InstallCallback& cb) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - int num = ++callback_nums_; |
| - install_callbacks_.push_back(std::make_pair(cb, num)); |
| -} |
| - |
| -void PnaclComponentInstaller::CancelCallback(int num) { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - for (std::list<std::pair<InstallCallback, int> >::iterator |
| - i = install_callbacks_.begin(), |
| - e = install_callbacks_.end(); i != e; ++i) { |
| - if (i->second == num) { |
| - i->first.Run(false); |
| - install_callbacks_.erase(i); |
| - return; |
| - } |
| - } |
| + updater_observer_->EnsureObserving(); |
| + install_callbacks_.push_back(cb); |
| } |
| void PnaclComponentInstaller::NotifyAllWithResult(bool status) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| while (!install_callbacks_.empty()) { |
| - install_callbacks_.front().first.Run(status); |
| + install_callbacks_.front().Run(status); |
| install_callbacks_.pop_front(); |
| } |
| } |
| @@ -347,17 +333,23 @@ void PnaclComponentInstaller::NotifyInstallSuccess() { |
| } |
| } |
| +CrxComponent PnaclComponentInstaller::GetCrxComponent() const { |
|
Sorin Jianu
2013/07/03 23:10:04
In this case, I suggest dropping the const declara
jvoung (off chromium)
2013/07/04 01:11:04
Done.
|
| + CrxComponent pnacl_component; |
| + pnacl_component.version = current_version(); |
| + pnacl_component.name = "pnacl"; |
| + pnacl_component.installer = const_cast<PnaclComponentInstaller*>(this); |
| + SetPnaclHash(&pnacl_component); |
| + |
| + return pnacl_component; |
| +} |
| + |
| namespace { |
| void FinishPnaclUpdateRegistration(const Version& current_version, |
| PnaclComponentInstaller* pci) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - CrxComponent pnacl_component; |
| - pnacl_component.version = current_version; |
| - pnacl_component.name = "pnacl"; |
| - pnacl_component.installer = pci; |
| pci->set_current_version(current_version); |
| - SetPnaclHash(&pnacl_component); |
| + const CrxComponent pnacl_component = pci->GetCrxComponent(); |
| ComponentUpdateService::Status status = |
| pci->cus()->RegisterComponent(pnacl_component); |
| @@ -468,13 +460,8 @@ void RequestFirstInstall(ComponentUpdateService* cus, |
| PnaclComponentInstaller* pci, |
| const base::Callback<void(bool)>& installed) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - Version null_version(kNullVersion); |
| - CrxComponent pnacl_component; |
| - pci->set_current_version(null_version); |
| - pnacl_component.version = null_version; |
| - pnacl_component.name = "pnacl"; |
| - pnacl_component.installer = pci; |
| - SetPnaclHash(&pnacl_component); |
| + pci->set_current_version(Version(kNullVersion)); |
| + const CrxComponent pnacl_component = pci->GetCrxComponent(); |
| ComponentUpdateService::Status status = cus->CheckForUpdateSoon( |
| pnacl_component); |
| if (status != ComponentUpdateService::kOk) { |