Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1292)

Unified Diff: chrome/browser/component_updater/pnacl/pnacl_component_installer.cc

Issue 18006003: Consistently use notifications from component updater w/ on-demand PNaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup test a bit Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 adfde80ae1f9b33bd9b8d89bc98253813505231b..562011be42aef6ea4eacc790a87fa2df67505ad3 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() {
+ CrxComponent pnacl_component;
+ pnacl_component.version = current_version();
+ pnacl_component.name = "pnacl";
+ pnacl_component.installer = 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);
+ 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));
+ CrxComponent pnacl_component = pci->GetCrxComponent();
ComponentUpdateService::Status status = cus->CheckForUpdateSoon(
pnacl_component);
if (status != ComponentUpdateService::kOk) {

Powered by Google App Engine
This is Rietveld 408576698