Index: services/resource_coordinator/coordination_unit/coordination_unit_impl.h |
diff --git a/services/resource_coordinator/coordination_unit/coordination_unit_impl.h b/services/resource_coordinator/coordination_unit/coordination_unit_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2b51a2eb4da91380226b24409fa4f17b2a96e31a |
--- /dev/null |
+++ b/services/resource_coordinator/coordination_unit/coordination_unit_impl.h |
@@ -0,0 +1,73 @@ |
+// 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_IMPL_H_ |
+#define SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMPL_H_ |
+ |
+#include <list> |
+ |
+#include "base/optional.h" |
+#include "mojo/public/cpp/bindings/binding_set.h" |
+#include "mojo/public/cpp/bindings/interface_request.h" |
+#include "mojo/public/cpp/bindings/strong_binding.h" |
+#include "services/resource_coordinator/public/cpp/coordination_unit_id.h" |
+#include "services/resource_coordinator/public/interfaces/coordination_unit.mojom.h" |
+#include "services/resource_coordinator/public/interfaces/coordination_unit_provider.mojom.h" |
+#include "services/service_manager/public/cpp/connection.h" |
+#include "services/service_manager/public/cpp/service_context_ref.h" |
+ |
+namespace resource_coordinator { |
+ |
+class CoordinationUnitImpl : public mojom::CoordinationUnit { |
+ public: |
+ CoordinationUnitImpl( |
+ const CoordinationUnitID& id, |
+ std::unique_ptr<service_manager::ServiceContextRef> service_ref); |
+ ~CoordinationUnitImpl() override; |
+ |
+ // Overridden from mojom::CoordinationUnit: |
+ void SendEvent(mojom::EventPtr event) override; |
+ void GetID(const GetIDCallback& callback) override; |
+ void Duplicate(mojom::CoordinationUnitRequest request) override; |
+ void AddChild(const CoordinationUnitID& child_id) override; |
+ void SetPolicyCallback(mojom::PolicyCallbackPtr callback) override; |
+ |
+ private: |
+ bool AddChild(CoordinationUnitImpl* child); |
+ void RemoveChild(CoordinationUnitImpl* child); |
+ void AddParent(CoordinationUnitImpl* parent); |
+ void RemoveParent(CoordinationUnitImpl* parent); |
+ bool HasParent(CoordinationUnitImpl* unit); |
+ bool HasChild(CoordinationUnitImpl* unit); |
+ |
+ void RecalcPolicy(); |
+ void UnregisterPolicyCallback(); |
+ |
+ enum StateFlags : uint8_t { |
+ TEST_STATE, |
+ TAB_VISIBLE, |
+ AUDIO_PLAYING, |
+ NUM_STATE_FLAGS |
+ }; |
+ bool SelfOrParentHasFlagSet(StateFlags state); |
+ |
+ std::unique_ptr<service_manager::ServiceContextRef> service_ref_; |
+ mojo::BindingSet<mojom::CoordinationUnit> bindings_; |
+ CoordinationUnitID id_; |
+ 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
|
+ |
+ std::set<CoordinationUnitImpl*> children_; |
+ std::set<CoordinationUnitImpl*> parents_; |
+ |
+ mojom::PolicyCallbackPtr policy_callback_; |
+ mojom::PolicyPtr current_policy_; |
+ |
+ base::Optional<bool> state_flags_[NUM_STATE_FLAGS]; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CoordinationUnitImpl); |
+}; |
+ |
+} // namespace resource_coordinator |
+ |
+#endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_IMPL_H_ |