Chromium Code Reviews| 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_IMPL_H _ | |
| 6 #define SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMPL_H _ | |
| 7 | |
| 8 #include <list> | |
| 9 | |
| 10 #include "base/optional.h" | |
| 11 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 12 #include "mojo/public/cpp/bindings/interface_request.h" | |
| 13 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 14 #include "services/resource_coordinator/public/cpp/coordination_unit_id.h" | |
| 15 #include "services/resource_coordinator/public/interfaces/coordination_unit.mojo m.h" | |
| 16 #include "services/resource_coordinator/public/interfaces/coordination_unit_prov ider.mojom.h" | |
| 17 #include "services/service_manager/public/cpp/connection.h" | |
| 18 #include "services/service_manager/public/cpp/service_context_ref.h" | |
| 19 | |
| 20 namespace resource_coordinator { | |
| 21 | |
| 22 class CoordinationUnitImpl : public mojom::CoordinationUnit { | |
| 23 public: | |
| 24 CoordinationUnitImpl( | |
| 25 const CoordinationUnitID& id, | |
| 26 std::unique_ptr<service_manager::ServiceContextRef> service_ref); | |
| 27 ~CoordinationUnitImpl() override; | |
| 28 | |
| 29 // Overridden from mojom::CoordinationUnit: | |
| 30 void SendEvent(mojom::EventPtr event) override; | |
| 31 void GetID(const GetIDCallback& callback) override; | |
| 32 void Duplicate(mojom::CoordinationUnitRequest request) override; | |
| 33 void AddChild(const CoordinationUnitID& child_id) override; | |
| 34 void SetPolicyCallback(mojom::PolicyCallbackPtr callback) override; | |
| 35 | |
| 36 private: | |
| 37 bool AddChild(CoordinationUnitImpl* child); | |
| 38 void RemoveChild(CoordinationUnitImpl* child); | |
| 39 void AddParent(CoordinationUnitImpl* parent); | |
| 40 void RemoveParent(CoordinationUnitImpl* parent); | |
| 41 bool HasParent(CoordinationUnitImpl* unit); | |
| 42 bool HasChild(CoordinationUnitImpl* unit); | |
| 43 | |
| 44 void RecalcPolicy(); | |
| 45 void UnregisterPolicyCallback(); | |
| 46 | |
| 47 enum StateFlags : uint8_t { | |
| 48 TEST_STATE, | |
| 49 TAB_VISIBLE, | |
| 50 AUDIO_PLAYING, | |
| 51 NUM_STATE_FLAGS | |
| 52 }; | |
| 53 bool SelfOrParentHasFlagSet(StateFlags state); | |
| 54 | |
| 55 std::unique_ptr<service_manager::ServiceContextRef> service_ref_; | |
| 56 mojo::BindingSet<mojom::CoordinationUnit> bindings_; | |
| 57 CoordinationUnitID id_; | |
| 58 int64_t id_hash_; | |
|
Primiano Tucci (use gerrit)
2017/04/06 18:09:46
one thing that is not immediatley clear from this
oystein (OOO til 10th of July)
2017/04/10 20:02:59
Removed this, after adding the std::hash(Coordinat
| |
| 59 | |
| 60 std::set<CoordinationUnitImpl*> children_; | |
| 61 std::set<CoordinationUnitImpl*> parents_; | |
| 62 | |
| 63 mojom::PolicyCallbackPtr policy_callback_; | |
| 64 mojom::PolicyPtr current_policy_; | |
| 65 | |
| 66 base::Optional<bool> state_flags_[NUM_STATE_FLAGS]; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(CoordinationUnitImpl); | |
| 69 }; | |
| 70 | |
| 71 } // namespace resource_coordinator | |
| 72 | |
| 73 #endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMP L_H_ | |
| OLD | NEW |