Index: services/resource_coordinator/coordination_unit/coordination_unit_impl.cc |
diff --git a/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc b/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc |
index 7fd56636949211c79a1ae042f7971728dae02021..9de59de021b32bf00c40b2e8d8546b8f531e324f 100644 |
--- a/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc |
+++ b/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc |
@@ -162,10 +162,8 @@ bool CoordinationUnitImpl::AddChild(CoordinationUnitImpl* child) { |
children_.count(child) ? false : children_.insert(child).second; |
if (success) { |
- for (auto* observer : |
- on_child_added_event_observer_registry_.GetObserversForFilter( |
- child->id().type)) { |
- observer->OnChildAddedEvent(this, child); |
+ for (auto& observer : observers_) { |
+ observer.OnChildAdded(this, child); |
} |
} |
@@ -196,10 +194,8 @@ bool CoordinationUnitImpl::RemoveChild(CoordinationUnitImpl* child) { |
bool success = children_removed > 0; |
if (success) { |
- for (auto* observer : |
- on_child_removed_event_observer_registry_.GetObserversForFilter( |
- child->id().type)) { |
- observer->OnChildRemovedEvent(this, child); |
+ for (auto& observer : observers_) { |
+ observer.OnChildRemoved(this, child); |
} |
} |
@@ -210,10 +206,8 @@ void CoordinationUnitImpl::AddParent(CoordinationUnitImpl* parent) { |
DCHECK_EQ(0u, parents_.count(parent)); |
parents_.insert(parent); |
- for (auto* observer : |
- on_parent_added_event_observer_registry_.GetObserversForFilter( |
- parent->id().type)) { |
- observer->OnParentAddedEvent(this, parent); |
+ for (auto& observer : observers_) { |
+ observer.OnParentAdded(this, parent); |
} |
RecalcCoordinationPolicy(); |
@@ -225,10 +219,8 @@ void CoordinationUnitImpl::RemoveParent(CoordinationUnitImpl* parent) { |
// TODO(matthalp, oysteine) should this go before or |
// after RecalcCoordinationPolicy? |
- for (auto* observer : |
- on_parent_removed_event_observer_registry_.GetObserversForFilter( |
- parent->id().type)) { |
- observer->OnParentRemovedEvent(this, parent); |
+ for (auto& observer : observers_) { |
+ observer.OnParentRemoved(this, parent); |
} |
RecalcCoordinationPolicy(); |
@@ -300,90 +292,19 @@ void CoordinationUnitImpl::SetProperty(mojom::PropertyType property, |
property_store_[property] = value; |
- for (auto* observer : |
- on_property_changed_event_observer_registry_.GetObserversForFilter( |
- property)) { |
- observer->OnPropertyChangedEvent(this, property); |
+ for (auto& observer : observers_) { |
+ observer.OnPropertyChanged(this, property); |
} |
} |
-void CoordinationUnitImpl::WillBeDestroyed() { |
- for (auto* observer : on_will_be_destroyed_event_observer_registry_ |
- .GetObserversWithoutAFilter()) { |
- observer->OnWillBeDestroyedEvent(this); |
- } |
-} |
- |
-void CoordinationUnitImpl::ObserveOnChildAddedEvent( |
- CoordinationUnitGraphObserver* observer, |
- CoordinationUnitType child_filter) { |
- on_child_added_event_observer_registry_.AddObserver(observer, child_filter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnChildAddedEvent( |
- CoordinationUnitGraphObserver* observer) { |
- ObserveOnChildAddedEvent( |
- observer, |
- CoordinationUnitGraphObserverRegistry<CoordinationUnitType>::kNoFilter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnParentAddedEvent( |
- CoordinationUnitGraphObserver* observer, |
- CoordinationUnitType parent_filter) { |
- on_parent_added_event_observer_registry_.AddObserver(observer, parent_filter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnParentAddedEvent( |
- CoordinationUnitGraphObserver* observer) { |
- ObserveOnParentAddedEvent( |
- observer, |
- CoordinationUnitGraphObserverRegistry<CoordinationUnitType>::kNoFilter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnPropertyChangedEvent( |
- CoordinationUnitGraphObserver* observer, |
- mojom::PropertyType property_filter) { |
- on_property_changed_event_observer_registry_.AddObserver(observer, |
- property_filter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnPropertyChangedEvent( |
- CoordinationUnitGraphObserver* observer) { |
- ObserveOnPropertyChangedEvent( |
- observer, |
- CoordinationUnitGraphObserverRegistry<mojom::PropertyType>::kNoFilter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnChildRemovedEvent( |
- CoordinationUnitGraphObserver* observer, |
- CoordinationUnitType child_filter) { |
- on_child_removed_event_observer_registry_.AddObserver(observer, child_filter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnChildRemovedEvent( |
- CoordinationUnitGraphObserver* observer) { |
- ObserveOnChildRemovedEvent( |
- observer, |
- CoordinationUnitGraphObserverRegistry<CoordinationUnitType>::kNoFilter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnParentRemovedEvent( |
- CoordinationUnitGraphObserver* observer, |
- CoordinationUnitType parent_filter) { |
- on_parent_removed_event_observer_registry_.AddObserver(observer, |
- parent_filter); |
-} |
- |
-void CoordinationUnitImpl::ObserveOnParentRemovedEvent( |
+void CoordinationUnitImpl::AddObserver( |
CoordinationUnitGraphObserver* observer) { |
- ObserveOnParentRemovedEvent( |
- observer, |
- CoordinationUnitGraphObserverRegistry<CoordinationUnitType>::kNoFilter); |
+ observers_.AddObserver(observer); |
} |
-void CoordinationUnitImpl::ObserveOnWillBeDestroyedEvent( |
+void CoordinationUnitImpl::RemoveObserver( |
CoordinationUnitGraphObserver* observer) { |
- on_will_be_destroyed_event_observer_registry_.AddObserver(observer); |
+ observers_.RemoveObserver(observer); |
} |
} // namespace resource_coordinator |