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

Unified Diff: chrome/browser/component_updater/component_updater_service.cc

Issue 20774003: First cut at the component observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/component_updater_service.cc
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
index 1a5bc76dced647b1160a1571213858009da97fc7..f595ba9a6713434fd47b140521571d5eddcc0deb 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -219,7 +219,8 @@ CrxUpdateItem::~CrxUpdateItem() {
}
CrxComponent::CrxComponent()
- : installer(NULL) {
+ : installer(NULL),
+ observer(NULL) {
}
CrxComponent::~CrxComponent() {
@@ -340,6 +341,9 @@ class CrxUpdateService : public ComponentUpdateService {
CrxUpdateItem* FindUpdateItemById(const std::string& id);
+ void NotifyComponentObservers(ComponentObserver::Events event,
+ int extra) const;
+
scoped_ptr<ComponentUpdateService::Configurator> config_;
scoped_ptr<ComponentPatcher> component_patcher_;
@@ -392,6 +396,8 @@ ComponentUpdateService::Status CrxUpdateService::Start() {
if (work_items_.empty())
return kOk;
+ NotifyComponentObservers(ComponentObserver::COMPONENT_UPDATER_STARTED, 0);
+
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED,
content::Source<ComponentUpdateService>(this),
@@ -431,6 +437,8 @@ void CrxUpdateService::ScheduleNextRun(bool step_delay) {
? config_->StepDelay() : config_->NextCheckDelay();
if (!step_delay) {
+ NotifyComponentObservers(ComponentObserver::COMPONENT_UPDATER_SLEEPING, 0);
+
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING,
content::Source<ComponentUpdateService>(this),
@@ -779,6 +787,11 @@ void CrxUpdateService::OnParseUpdateManifestSucceeded(
crx->next_fp = it->package_fingerprint;
++update_pending;
+ if (crx->component.observer) {
+ crx->component.observer->OnEvent(
+ ComponentObserver::COMPONENT_UPDATE_FOUND, 0);
+ }
+
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND,
content::Source<std::string>(&crx->id),
@@ -855,6 +868,11 @@ void CrxUpdateService::OnURLFetchComplete(const net::URLFetcher* source,
url_fetcher_.reset();
+ if (crx->component.observer) {
+ crx->component.observer->OnEvent(
+ ComponentObserver::COMPONENT_UPDATE_READY, 0);
+ }
+
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_COMPONENT_UPDATE_READY,
content::Source<std::string>(&context->id),
@@ -948,6 +966,16 @@ void CrxUpdateService::DoneInstalling(const std::string& component_id,
ScheduleNextRun(false);
}
+void CrxUpdateService::NotifyComponentObservers(
+ ComponentObserver::Events event, int extra) const {
+ for (UpdateItems::const_iterator it = work_items_.begin();
+ it != work_items_.end(); ++it) {
+ ComponentObserver* observer = (*it)->component.observer;
+ if (observer)
+ observer->OnEvent(event, 0);
+ }
+}
+
// The component update factory. Using the component updater as a singleton
// is the job of the browser process.
ComponentUpdateService* ComponentUpdateServiceFactory(

Powered by Google App Engine
This is Rietveld 408576698