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

Side by Side Diff: services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h

Issue 2942403002: [GRC] Coordination Unit Graph Observer (Closed)
Patch Set: Rename API function calls Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRAPH_ OBSERVER_H_
6 #define SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRAPH_ OBSERVER_H_
7
8 #include <memory>
9 #include <unordered_map>
10
11 #include "base/macros.h"
12 #include "services/resource_coordinator/coordination_unit/coordination_unit_impl .h"
13 #include "services/resource_coordinator/public/cpp/coordination_unit_id.h"
14 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h"
15 #include "services/resource_coordinator/public/interfaces/coordination_unit.mojo m.h"
16
17 namespace resource_coordinator {
18
19 // An observer API for the CoordinationUnitGraph maintained by GRC.
Zhen Wang 2017/06/19 22:54:24 nit: CoordinationUnitGraph is not a real class. So
matthalp 2017/06/20 19:02:50 Done.
20 //
21 // Observers are instantiated when the resource_coordinator serivce
oystein (OOO til 10th of July) 2017/06/20 18:39:23 nit: s/serivce/service/
matthalp 2017/06/20 19:02:51 Done.
22 // is created and are destroyed when the resource_coordinator service
23 // is destroyed. Therefore observers are guaranteed to be alive before
24 // any coordination unit is created and will be alive after any
25 // coordination unit is destroyed. Additionally, any
26 // Coordination Unit reachable within a callback will always be
27 // initialized and valid.
28 //
29 // To create and install a new observer:
30 // (1) derive from this class
31 // (2) register in CoordinationUnitManager::RegisterObserver
32 // inside of CoordinationUnitManager::CoordinationUnitManager
33 //
Zhen Wang 2017/06/19 22:54:24 This document needs to be updated because the life
matthalp 2017/06/20 19:02:51 The observer lifetime behavior has returned to bei
34 class CoordinationUnitGraphObserver {
35 public:
36 CoordinationUnitGraphObserver();
Zhen Wang 2017/06/19 22:54:24 It is probably better to also have some comments f
matthalp 2017/06/20 19:02:51 Filtering has been removed for now -- this no long
37 // The CoordinationUnitGraphObserver will only call
Zhen Wang 2017/06/19 22:54:24 s/CoordinationUnitGraphObserver/CoordinationUnitMa
matthalp 2017/06/20 19:02:50 Filtering has been removed for now -- this no long
38 // CoordinationUnitGraphObserver::CoordinationUnitCreated when the
39 // CoordinationUnit's CoordinationUnitID.type matches filter.
40 explicit CoordinationUnitGraphObserver(CoordinationUnitType filter);
41 virtual ~CoordinationUnitGraphObserver();
42
43 // Determines whether or not OnCoordinationUnitCreated should be
44 // invoked on the newly created CoordinationUnit.
Zhen Wang 2017/06/19 22:54:24 Nit: This comment is too specific to OnCoordinatio
matthalp 2017/06/20 19:02:51 Filtering has been removed for now -- this no long
45 bool ShouldObserve(CoordinationUnitImpl* coordination_unit);
lpy 2017/06/19 23:21:38 defer the functionality to CUGraphObserver itself
matthalp 2017/06/20 19:02:51 Done.
46
47 // Called whenever any new CoordinationUnit of interest is created
48 // (i.e. ShouldObserve evaluates to true).
49 virtual void OnCoordinationUnitCreatedEvent(
lpy 2017/06/19 23:21:38 OnCoordinationUnitCreated
matthalp 2017/06/20 19:02:51 Done. Event has been removed from On*Event.
50 CoordinationUnitImpl* coordination_unit) {}
51
52 // Called whenever a new parent-child relationship occurs where the
53 // |coordination_unit| is the parent and the |child_coordination_unit|
54 // type matches the CoordinationUnitType filter that the observer
55 // was registered with (e.g. CoordinationUnit::ObserveAddChildEvent).
56 virtual void OnChildAddedEvent(
Zhen Wang 2017/06/19 22:54:24 I think we can remove "Event" in the API to be con
lpy 2017/06/19 23:21:38 OnChildAdded
matthalp 2017/06/20 19:02:51 Done.
57 const CoordinationUnitImpl* coordination_unit,
58 const CoordinationUnitImpl* child_coordination_unit) {}
59
60 // Called whenever a new parent-child relationship occurs where the
61 // |coordination_unit| is the child and the |parent_coordination_unit|
62 // type matches the CoordinationUnitType filter that the observer
63 // was registered with (e.g. CoordinationUnit::ObserveAddParentEvent).
64 virtual void OnParentAddedEvent(
lpy 2017/06/19 23:21:38 OnParentAdded.
matthalp 2017/06/20 19:02:51 Done.
65 const CoordinationUnitImpl* coordination_unit,
66 const CoordinationUnitImpl* parent_coordination_unit) {}
67
68 // Called whenever a |property| within the |coordination_unit|'s internal
69 // property store changes and the |property| type matches the
70 // mojom::Property filter that the observer was registered with
71 // (e.g. CoordinationUnit::ObservePropertyChangedEvent).
72 virtual void OnPropertyChangedEvent(
lpy 2017/06/19 23:21:38 OnPropertyChanged Will it be useful to also pass
matthalp 2017/06/20 19:02:51 If it is determined to be useful for someone we ca
73 const CoordinationUnitImpl* coordination_unit,
74 mojom::PropertyType property) {}
75
76 // Called whenever parent-child relationship ends where the
77 // |coordination_unit| was the parent and the |child_coordination_unit|
78 // type matches the CoordinationUnitType filter that the observer
79 // was registered with (e.g. CoordinationUnit::ObserveAddChildEvent).
80 virtual void OnChildRemovedEvent(
lpy 2017/06/19 23:21:38 OnChildRemoved
matthalp 2017/06/20 19:02:50 Done.
81 const CoordinationUnitImpl* coordination_unit,
82 const CoordinationUnitImpl* child_coordination_unit) {}
83
84 // Called whenever parent-child relationship ends where the
85 // |coordination_unit| was the child and the |child_coordination_unit|
86 // type matches the CoordinationUnitType filter that the observer
87 // was registered with (e.g. CoordinationUnit::ObserveRemoveParentEvent).
88 virtual void OnParentRemovedEvent(
lpy 2017/06/19 23:21:38 OnParentRemoved
matthalp 2017/06/20 19:02:51 Done.
89 const CoordinationUnitImpl* coordination_unit,
90 const CoordinationUnitImpl* parent_coordination_unit) {}
91
92 // Called when the |coordination_unit| is about to be destroyed.
93 virtual void OnWillBeDestroyedEvent(
lpy 2017/06/19 23:21:38 OnWillBeDestroyed
matthalp 2017/06/20 19:02:51 Done.
94 const CoordinationUnitImpl* coordination_unit) {}
95
96 protected:
97 CoordinationUnitType filter_;
Zhen Wang 2017/06/19 22:54:24 Why does this need to be protected? I did a quick
matthalp 2017/06/20 19:02:51 Filter has been removed -- this is no longer appli
98
99 private:
100 DISALLOW_COPY_AND_ASSIGN(CoordinationUnitGraphObserver);
101 };
102
103 } // namespace resource_coordinator
104
105 #endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRA PH_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698