Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: services/resource_coordinator/public/cpp/resource_coordinator_interface.h

Issue 2798713002: Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Buildfix after rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/resource_coordinator/public/cpp/resource_coordinator_interface.h
diff --git a/services/resource_coordinator/public/cpp/resource_coordinator_interface.h b/services/resource_coordinator/public/cpp/resource_coordinator_interface.h
new file mode 100644
index 0000000000000000000000000000000000000000..95d6748c76cd7d9566f104d35fc002bfe3ce9845
--- /dev/null
+++ b/services/resource_coordinator/public/cpp/resource_coordinator_interface.h
@@ -0,0 +1,56 @@
+// 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_PUBLIC_CPP_RESOURCE_COORDINATOR_INTERFACE_H_
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_INTERFACE_H_
+
+#include <stdint.h>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "services/resource_coordinator/public/interfaces/coordination_unit.mojom.h"
+
+namespace service_manager {
+class Connector;
+}
+
+namespace resource_coordinator {
+
+using EventType = mojom::EventType;
+
+class ResourceCoordinatorInterface {
+ public:
+ ResourceCoordinatorInterface(service_manager::Connector* connector,
+ const CoordinationUnitType& type);
+ ResourceCoordinatorInterface(service_manager::Connector* connector,
+ const CoordinationUnitType& type,
+ const std::string& id);
+ ~ResourceCoordinatorInterface();
+
+ const mojom::CoordinationUnitPtr& service() const { return service_; }
+
+ void SendEvent(const mojom::EventType& event_type);
+ void AddChild(const ResourceCoordinatorInterface& child);
+
+ private:
+ void ConnectToService(service_manager::Connector* connector,
+ const CoordinationUnitType& type,
+ const std::string& id);
+ void AddChildByID(const CoordinationUnitID& child_id);
+
+ mojom::CoordinationUnitPtr service_;
+
+ base::ThreadChecker thread_checker_;
+
+ // The WeakPtrFactory should come last so the weak ptrs are invalidated
+ // before the rest of the member variables.
+ base::WeakPtrFactory<ResourceCoordinatorInterface> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourceCoordinatorInterface);
+};
+
+} // namespace resource_coordinator
+
+#endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_INTERFACE_H_

Powered by Google App Engine
This is Rietveld 408576698