OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMPL_H
_ | 5 #ifndef SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMPL_H
_ |
6 #define SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMPL_H
_ | 6 #define SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMPL_H
_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
| 9 #include <map> |
9 #include <memory> | 10 #include <memory> |
10 #include <set> | 11 #include <set> |
11 #include <unordered_map> | 12 #include <unordered_map> |
12 #include <utility> | 13 #include <utility> |
| 14 #include <vector> |
13 | 15 |
| 16 #include "base/callback.h" |
| 17 #include "base/observer_list.h" |
14 #include "base/optional.h" | 18 #include "base/optional.h" |
15 #include "base/values.h" | 19 #include "base/values.h" |
16 #include "mojo/public/cpp/bindings/binding_set.h" | 20 #include "mojo/public/cpp/bindings/binding_set.h" |
17 #include "mojo/public/cpp/bindings/interface_request.h" | 21 #include "mojo/public/cpp/bindings/interface_request.h" |
18 #include "mojo/public/cpp/bindings/strong_binding.h" | 22 #include "mojo/public/cpp/bindings/strong_binding.h" |
19 #include "services/resource_coordinator/public/cpp/coordination_unit_id.h" | 23 #include "services/resource_coordinator/public/cpp/coordination_unit_id.h" |
| 24 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h" |
20 #include "services/resource_coordinator/public/interfaces/coordination_unit.mojo
m.h" | 25 #include "services/resource_coordinator/public/interfaces/coordination_unit.mojo
m.h" |
21 #include "services/resource_coordinator/public/interfaces/coordination_unit_prov
ider.mojom.h" | 26 #include "services/resource_coordinator/public/interfaces/coordination_unit_prov
ider.mojom.h" |
22 #include "services/service_manager/public/cpp/service_context_ref.h" | 27 #include "services/service_manager/public/cpp/service_context_ref.h" |
23 | 28 |
24 namespace resource_coordinator { | 29 namespace resource_coordinator { |
25 | 30 |
| 31 class CoordinationUnitGraphObserver; |
| 32 |
26 class CoordinationUnitImpl : public mojom::CoordinationUnit { | 33 class CoordinationUnitImpl : public mojom::CoordinationUnit { |
27 public: | 34 public: |
28 CoordinationUnitImpl( | 35 CoordinationUnitImpl( |
29 const CoordinationUnitID& id, | 36 const CoordinationUnitID& id, |
30 std::unique_ptr<service_manager::ServiceContextRef> service_ref); | 37 std::unique_ptr<service_manager::ServiceContextRef> service_ref); |
31 ~CoordinationUnitImpl() override; | 38 ~CoordinationUnitImpl() override; |
32 | 39 |
33 // Overridden from mojom::CoordinationUnit: | 40 // Overridden from mojom::CoordinationUnit: |
34 void SendEvent(mojom::EventPtr event) override; | 41 void SendEvent(mojom::EventPtr event) override; |
35 void GetID(const GetIDCallback& callback) override; | 42 void GetID(const GetIDCallback& callback) override; |
(...skipping 12 matching lines...) Expand all Loading... |
48 return property_store_; | 55 return property_store_; |
49 } | 56 } |
50 | 57 |
51 static const double kCPUUsageMinimumForTesting; | 58 static const double kCPUUsageMinimumForTesting; |
52 static const double kCPUUsageUnmeasuredForTesting; | 59 static const double kCPUUsageUnmeasuredForTesting; |
53 virtual double GetCPUUsageForTesting(); | 60 virtual double GetCPUUsageForTesting(); |
54 | 61 |
55 // Clear property from internal key-value store | 62 // Clear property from internal key-value store |
56 void ClearProperty(mojom::PropertyType property); | 63 void ClearProperty(mojom::PropertyType property); |
57 // Retrieve property from internal key-value store | 64 // Retrieve property from internal key-value store |
58 base::Value GetProperty(mojom::PropertyType property); | 65 base::Value GetProperty(mojom::PropertyType property) const; |
59 // Set property from internal key-value store | 66 // Set property from internal key-value store |
60 void SetProperty(mojom::PropertyType property, base::Value value); | 67 void SetProperty(mojom::PropertyType property, base::Value value); |
61 | 68 |
| 69 void WillBeDestroyed(); |
| 70 void AddObserver(CoordinationUnitGraphObserver* observer); |
| 71 void RemoveObserver(CoordinationUnitGraphObserver* observer); |
| 72 |
62 protected: | 73 protected: |
63 const CoordinationUnitID id_; | 74 const CoordinationUnitID id_; |
64 std::set<CoordinationUnitImpl*> children_; | 75 std::set<CoordinationUnitImpl*> children_; |
65 std::set<CoordinationUnitImpl*> parents_; | 76 std::set<CoordinationUnitImpl*> parents_; |
66 | 77 |
67 private: | 78 private: |
68 bool AddChild(CoordinationUnitImpl* child); | 79 bool AddChild(CoordinationUnitImpl* child); |
69 bool RemoveChild(CoordinationUnitImpl* child); | 80 bool RemoveChild(CoordinationUnitImpl* child); |
70 void AddParent(CoordinationUnitImpl* parent); | 81 void AddParent(CoordinationUnitImpl* parent); |
71 void RemoveParent(CoordinationUnitImpl* parent); | 82 void RemoveParent(CoordinationUnitImpl* parent); |
(...skipping 13 matching lines...) Expand all Loading... |
85 kNumStateFlags | 96 kNumStateFlags |
86 }; | 97 }; |
87 bool SelfOrParentHasFlagSet(StateFlags state); | 98 bool SelfOrParentHasFlagSet(StateFlags state); |
88 | 99 |
89 std::unique_ptr<service_manager::ServiceContextRef> service_ref_; | 100 std::unique_ptr<service_manager::ServiceContextRef> service_ref_; |
90 mojo::BindingSet<mojom::CoordinationUnit> bindings_; | 101 mojo::BindingSet<mojom::CoordinationUnit> bindings_; |
91 | 102 |
92 mojom::CoordinationPolicyCallbackPtr policy_callback_; | 103 mojom::CoordinationPolicyCallbackPtr policy_callback_; |
93 mojom::CoordinationPolicyPtr current_policy_; | 104 mojom::CoordinationPolicyPtr current_policy_; |
94 | 105 |
| 106 base::ObserverList<CoordinationUnitGraphObserver> observers_; |
| 107 |
95 base::Optional<bool> state_flags_[kNumStateFlags]; | 108 base::Optional<bool> state_flags_[kNumStateFlags]; |
96 | 109 |
97 DISALLOW_COPY_AND_ASSIGN(CoordinationUnitImpl); | 110 DISALLOW_COPY_AND_ASSIGN(CoordinationUnitImpl); |
98 }; | 111 }; |
99 | 112 |
100 } // namespace resource_coordinator | 113 } // namespace resource_coordinator |
101 | 114 |
102 #endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMP
L_H_ | 115 #endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMP
L_H_ |
OLD | NEW |