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

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

Issue 2798713002: Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Review fixes Created 3 years, 8 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/coordination_unit_id.h
diff --git a/services/resource_coordinator/public/cpp/coordination_unit_id.h b/services/resource_coordinator/public/cpp/coordination_unit_id.h
new file mode 100644
index 0000000000000000000000000000000000000000..f25c4d866aa73aa1b596f21f88618876bde29da7
--- /dev/null
+++ b/services/resource_coordinator/public/cpp/coordination_unit_id.h
@@ -0,0 +1,37 @@
+// 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_ID_H_
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_
+
+#include <string>
+
+#include "services/resource_coordinator/public/cpp/coordination_unit_types.h"
+
+namespace resource_coordinator {
+
+struct CoordinationUnitID {
+ CoordinationUnitID();
+ CoordinationUnitID(const CoordinationUnitType& type, const std::string& id);
+
+ bool operator==(const CoordinationUnitID& b) const {
+ return id == b.id && type == b.type;
+ }
+
+ uint64_t operator()(const CoordinationUnitID& id) const;
Primiano Tucci (use gerrit) 2017/04/11 18:04:51 this one doesn't seem to be defined in the .cc fil
oystein (OOO til 10th of July) 2017/04/12 19:15:31 Yep, done.
+
+ int32_t id;
+ CoordinationUnitType type;
+};
+
+} // resource_coordinator
+
+template <>
+struct std::hash<resource_coordinator::CoordinationUnitID> {
+ uint64_t operator()(
+ const resource_coordinator::CoordinationUnitID& id) const {
+ return ((static_cast<uint64_t>(id.type)) << 32) | id.id;
+ }
+};
+
+#endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_

Powered by Google App Engine
This is Rietveld 408576698