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

Unified Diff: chrome/browser/component_updater/pnacl/pnacl_updater_observer.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: review 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_updater_observer.cc
diff --git a/chrome/browser/component_updater/pnacl/pnacl_updater_observer.cc b/chrome/browser/component_updater/pnacl/pnacl_updater_observer.cc
index 2a3a6fa891914eb5e626177235f414a1f71fce20..e845a6236910fed2cdfa3c41915e6ebf0bb853be 100644
--- a/chrome/browser/component_updater/pnacl/pnacl_updater_observer.cc
+++ b/chrome/browser/component_updater/pnacl/pnacl_updater_observer.cc
@@ -9,23 +9,48 @@
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
-PnaclUpdaterObserver::PnaclUpdaterObserver(
- PnaclComponentInstaller* installer) : pnacl_installer_(installer) {
- registrar_.Add(this,
- chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING,
- content::NotificationService::AllSources());
+PnaclUpdaterObserver::PnaclUpdaterObserver(PnaclComponentInstaller* installer)
+ : pnacl_installer_(installer) {}
+
+PnaclUpdaterObserver::~PnaclUpdaterObserver() {}
+
+void PnaclUpdaterObserver::EnsureObserving() {
+ if (registrar_.IsEmpty()) {
+ registrar_.Add(this,
+ chrome::NOTIFICATION_COMPONENT_UPDATE_READY,
+ content::NotificationService::AllSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING,
+ content::NotificationService::AllSources());
+ }
}
-PnaclUpdaterObserver::~PnaclUpdaterObserver() { }
+void PnaclUpdaterObserver::StopObserving() {
+ registrar_.RemoveAll();
+}
void PnaclUpdaterObserver::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
+
+ if (type == chrome::NOTIFICATION_COMPONENT_UPDATE_READY) {
+ // If the component updater says there is an UPDATE_READY w/ source
+ // being the PNaCl ID, then installation is handed off to the PNaCl
+ // installer and we can stop observing.
+ if (ComponentUpdateService::IsUpdateNotificationForComponent(
+ source, pnacl_installer_->GetCrxComponent())) {
+ StopObserving();
+ }
+ return;
+ }
+
if (type == chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING) {
- // If the component updater sleeps before a NotifyInstallSuccess,
- // then requests for installs were likely skipped, or an error occurred.
+ // If the component updater sleeps before an UPDATE_READY for this
+ // component, then requests for installs were likely skipped,
+ // or an error occurred.
cpu_(ooo_6.6-7.5) 2013/07/03 18:04:53 or you are up to date..
jvoung (off chromium) 2013/07/03 22:51:51 Done.
pnacl_installer_->NotifyInstallError();
+ StopObserving();
return;
}
}

Powered by Google App Engine
This is Rietveld 408576698