OLD | NEW |
---|---|
(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/public/cpp/coordination_unit_id.h" | |
13 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h" | |
14 #include "services/resource_coordinator/public/interfaces/coordination_unit.mojo m.h" | |
15 | |
16 namespace resource_coordinator { | |
17 | |
18 class CoordinationUnitImpl; | |
19 | |
20 // An observer API for the CoordinationUnitManager within GRC | |
21 // | |
22 // To create a new observer: | |
23 // (1) derive from this class | |
24 // (2) register in CoordinationUnitManager::RegisterObserver | |
25 // inside of CoordinationUnitManager::CoordinationUnitManager | |
26 // in coordination_unit_manager.cc | |
27 class CoordinationUnitGraphObserver { | |
zhenw
2017/06/13 18:38:41
Do observers outlive all CUs?
The real question i
matthalp
2017/06/13 20:57:10
(1) All observers will outlive any CU created wit
Zhen Wang
2017/06/14 00:33:03
OK. As long as observers outlive any CU, it is fin
| |
28 public: | |
29 CoordinationUnitGraphObserver(); | |
30 // The CoordinationUnitmanagerObserver will only call | |
31 // CoordinationUnitGraphObserver::CoordinationUnitCreated when the | |
32 // CoordinationUnit's CoordinationUnitID.type matches filter. | |
33 explicit CoordinationUnitGraphObserver(CoordinationUnitType filter); | |
zhenw
2017/06/13 18:38:41
I am not entirely sure the reason of using filters
matthalp
2017/06/13 20:57:10
The main intention for filtering was for code heal
Zhen Wang
2017/06/14 00:33:03
OK. Let's keep filtering.
| |
34 virtual ~CoordinationUnitGraphObserver(); | |
35 | |
36 CoordinationUnitType filter() const { return filter_; } | |
37 | |
38 // Called whenever any new CoordinationUnit of any type is created. Note that | |
39 // this will be called after any specialized *CoordinationUnitCreated (e.g. | |
40 // FrameCoordinationUnitCreation, etc.) is called. | |
41 virtual void CoordinationUnitCreated( | |
42 CoordinationUnitImpl* coordination_unit) {} | |
43 | |
44 private: | |
45 CoordinationUnitType filter_; | |
46 | |
47 DISALLOW_COPY_AND_ASSIGN(CoordinationUnitGraphObserver); | |
48 }; | |
49 | |
50 } // namespace resource_coordinator | |
51 | |
52 #endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRA PH_OBSERVER_H_ | |
OLD | NEW |