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

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

Issue 2942403002: [GRC] Coordination Unit Graph Observer (Closed)
Patch Set: Rebase 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 coordination unit graph maintained by GRC.
20 //
21 // Observers are instantiated when the resource_coordinator service
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 class CoordinationUnitGraphObserver {
34 public:
35 CoordinationUnitGraphObserver();
36 virtual ~CoordinationUnitGraphObserver();
37
38 // Determines whether or not the observer should be registered with, and
39 // invoked for, the |coordination_unit|.
40 virtual bool ShouldObserve(const CoordinationUnitImpl* coordination_unit) = 0;
41
42 // Called whenever a CoordinationUnit is created.
43 virtual void OnCoordinationUnitCreated(
44 const CoordinationUnitImpl* coordination_unit) {}
45
46 // Called whenever a new parent-child relationship occurs where the
47 // |coordination_unit| is the parent of |child_coordination_unit|
48 virtual void OnChildAdded(
49 const CoordinationUnitImpl* coordination_unit,
50 const CoordinationUnitImpl* child_coordination_unit) {}
51
52 // Called whenever a new parent-child relationship occurs where the
53 // |coordination_unit| is the child of |parent_coordination_unit|.
54 virtual void OnParentAdded(
55 const CoordinationUnitImpl* coordination_unit,
56 const CoordinationUnitImpl* parent_coordination_unit) {}
57
58 // Called whenever a |property| within the |coordination_unit|'s
59 // internal property store has changed.
60 virtual void OnPropertyChanged(const CoordinationUnitImpl* coordination_unit,
61 mojom::PropertyType property) {}
62
63 // Called whenever parent-child relationship ends where the
64 // |coordination_unit| was the parent and the |child_coordination_unit|.
65 virtual void OnChildRemoved(
66 const CoordinationUnitImpl* coordination_unit,
67 const CoordinationUnitImpl* child_coordination_unit) {}
68
69 // Called whenever parent-child relationship ends where the
70 // |coordination_unit| was the child and the |child_coordination_unit|.
71 virtual void OnParentRemoved(
72 const CoordinationUnitImpl* coordination_unit,
73 const CoordinationUnitImpl* parent_coordination_unit) {}
74
75 // Called when the |coordination_unit| is about to be destroyed.
76 virtual void OnCoordinationUnitWillBeDestroyed(
77 const CoordinationUnitImpl* coordination_unit) {}
78
79 private:
80 DISALLOW_COPY_AND_ASSIGN(CoordinationUnitGraphObserver);
81 };
82
83 } // namespace resource_coordinator
84
85 #endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRA PH_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698