Chromium Code Reviews| 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..c40ceee6cbdc172a544f500c282b7f4ddd183d78 |
| --- /dev/null |
| +++ b/services/resource_coordinator/public/cpp/coordination_unit_id.h |
| @@ -0,0 +1,39 @@ |
| +// 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; |
| + } |
| + |
| + int32_t id; |
| + CoordinationUnitType type; |
|
nasko
2017/04/21 00:17:32
This is in different order than CoordinationUnitID
|
| +}; |
| + |
| +} // resource_coordinator |
| + |
| +namespace std { |
| + |
| +template <> |
| +struct hash<resource_coordinator::CoordinationUnitID> { |
| + uint64_t operator()( |
| + const resource_coordinator::CoordinationUnitID& id) const { |
| + return ((static_cast<uint64_t>(id.type)) << 32) | id.id; |
| + } |
| +}; |
| + |
| +} // namespace std |
| + |
| +#endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_ |