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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2a88a0a33cc744b037fe3053f48a176df0f3affa |
--- /dev/null |
+++ b/services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h |
@@ -0,0 +1,52 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRAPH_OBSERVER_H_ |
+#define SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRAPH_OBSERVER_H_ |
+ |
+#include <memory> |
+#include <unordered_map> |
+ |
+#include "base/macros.h" |
+#include "services/resource_coordinator/public/cpp/coordination_unit_id.h" |
+#include "services/resource_coordinator/public/cpp/coordination_unit_types.h" |
+#include "services/resource_coordinator/public/interfaces/coordination_unit.mojom.h" |
+ |
+namespace resource_coordinator { |
+ |
+class CoordinationUnitImpl; |
+ |
+// An observer API for the CoordinationUnitManager within GRC |
+// |
+// To create a new observer: |
+// (1) derive from this class |
+// (2) register in CoordinationUnitManager::RegisterObserver |
+// inside of CoordinationUnitManager::CoordinationUnitManager |
+// in coordination_unit_manager.cc |
+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
|
+ public: |
+ CoordinationUnitGraphObserver(); |
+ // The CoordinationUnitmanagerObserver will only call |
+ // CoordinationUnitGraphObserver::CoordinationUnitCreated when the |
+ // CoordinationUnit's CoordinationUnitID.type matches filter. |
+ 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.
|
+ virtual ~CoordinationUnitGraphObserver(); |
+ |
+ CoordinationUnitType filter() const { return filter_; } |
+ |
+ // Called whenever any new CoordinationUnit of any type is created. Note that |
+ // this will be called after any specialized *CoordinationUnitCreated (e.g. |
+ // FrameCoordinationUnitCreation, etc.) is called. |
+ virtual void CoordinationUnitCreated( |
+ CoordinationUnitImpl* coordination_unit) {} |
+ |
+ private: |
+ CoordinationUnitType filter_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CoordinationUnitGraphObserver); |
+}; |
+ |
+} // namespace resource_coordinator |
+ |
+#endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRAPH_OBSERVER_H_ |