Index: services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h |
diff --git a/services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h b/services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h |
index 58e839619d1544abdb87560ac491d5e6cdafbd24..39826537af66bc090b741f990627b6305a8d7193 100644 |
--- a/services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h |
+++ b/services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h |
@@ -16,9 +16,9 @@ |
namespace resource_coordinator { |
-// An observer API for the CoordinationUnitGraph maintained by GRC. |
+// An observer API for the coordination unit graph maintained by GRC. |
// |
-// Observers are instantiated when the resource_coordinator serivce |
+// Observers are instantiated when the resource_coordinator service |
// is created and are destroyed when the resource_coordinator service |
// is destroyed. Therefore observers are guaranteed to be alive before |
// any coordination unit is created and will be alive after any |
@@ -30,72 +30,52 @@ namespace resource_coordinator { |
// (1) derive from this class |
// (2) register in CoordinationUnitManager::RegisterObserver |
// inside of CoordinationUnitManager::CoordinationUnitManager |
-// |
class CoordinationUnitGraphObserver { |
public: |
CoordinationUnitGraphObserver(); |
- // The CoordinationUnitGraphObserver will only call |
- // CoordinationUnitGraphObserver::CoordinationUnitCreated when the |
- // CoordinationUnit's CoordinationUnitID.type matches filter. |
- explicit CoordinationUnitGraphObserver(CoordinationUnitType filter); |
virtual ~CoordinationUnitGraphObserver(); |
- // Determines whether or not OnCoordinationUnitCreated should be |
- // invoked on the newly created CoordinationUnit. |
- bool ShouldObserve(CoordinationUnitImpl* coordination_unit); |
+ // Determines whether or not the observer should be registered and |
+ // invoked for the |coordination_unit|. |
+ virtual bool ShouldObserve(const CoordinationUnitImpl* coordination_unit) = 0; |
- // Called whenever any new CoordinationUnit of interest is created |
- // (i.e. ShouldObserve evaluates to true). |
- virtual void OnCoordinationUnitCreatedEvent( |
- CoordinationUnitImpl* coordination_unit) {} |
+ // Called whenever a CoordinationUnit is created. |
+ virtual void OnCoordinationUnitCreated( |
+ const CoordinationUnitImpl* coordination_unit) {} |
// Called whenever a new parent-child relationship occurs where the |
- // |coordination_unit| is the parent and the |child_coordination_unit| |
- // type matches the CoordinationUnitType filter that the observer |
- // was registered with (e.g. CoordinationUnit::ObserveAddChildEvent). |
- virtual void OnChildAddedEvent( |
+ // |coordination_unit| is the parent of |child_coordination_unit| |
+ virtual void OnChildAdded( |
const CoordinationUnitImpl* coordination_unit, |
const CoordinationUnitImpl* child_coordination_unit) {} |
// Called whenever a new parent-child relationship occurs where the |
- // |coordination_unit| is the child and the |parent_coordination_unit| |
- // type matches the CoordinationUnitType filter that the observer |
- // was registered with (e.g. CoordinationUnit::ObserveAddParentEvent). |
- virtual void OnParentAddedEvent( |
+ // |coordination_unit| is the child of |parent_coordination_unit|. |
+ virtual void OnParentAdded( |
const CoordinationUnitImpl* coordination_unit, |
const CoordinationUnitImpl* parent_coordination_unit) {} |
- // Called whenever a |property| within the |coordination_unit|'s internal |
- // property store changes and the |property| type matches the |
- // mojom::Property filter that the observer was registered with |
- // (e.g. CoordinationUnit::ObservePropertyChangedEvent). |
- virtual void OnPropertyChangedEvent( |
- const CoordinationUnitImpl* coordination_unit, |
- mojom::PropertyType property) {} |
+ // Called whenever a |property| within the |coordination_unit|'s |
+ // internal property store has changed. |
+ virtual void OnPropertyChanged(const CoordinationUnitImpl* coordination_unit, |
+ mojom::PropertyType property) {} |
// Called whenever parent-child relationship ends where the |
- // |coordination_unit| was the parent and the |child_coordination_unit| |
- // type matches the CoordinationUnitType filter that the observer |
- // was registered with (e.g. CoordinationUnit::ObserveAddChildEvent). |
- virtual void OnChildRemovedEvent( |
+ // |coordination_unit| was the parent and the |child_coordination_unit|. |
+ virtual void OnChildRemoved( |
const CoordinationUnitImpl* coordination_unit, |
const CoordinationUnitImpl* child_coordination_unit) {} |
// Called whenever parent-child relationship ends where the |
- // |coordination_unit| was the child and the |child_coordination_unit| |
- // type matches the CoordinationUnitType filter that the observer |
- // was registered with (e.g. CoordinationUnit::ObserveRemoveParentEvent). |
- virtual void OnParentRemovedEvent( |
+ // |coordination_unit| was the child and the |child_coordination_unit|. |
+ virtual void OnParentRemoved( |
const CoordinationUnitImpl* coordination_unit, |
const CoordinationUnitImpl* parent_coordination_unit) {} |
// Called when the |coordination_unit| is about to be destroyed. |
- virtual void OnWillBeDestroyedEvent( |
+ virtual void OnCoordinationUnitWillBeDestroyed( |
const CoordinationUnitImpl* coordination_unit) {} |
- protected: |
- CoordinationUnitType filter_; |
- |
private: |
DISALLOW_COPY_AND_ASSIGN(CoordinationUnitGraphObserver); |
}; |