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 #ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_ |
| 5 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_ |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h" |
| 10 |
| 11 namespace resource_coordinator { |
| 12 |
| 13 // This is a native struct rather than a mojom struct as we eventually want |
| 14 // to annotate base::TaskRunner with CUs for cost attribution purses and |
| 15 // would like to move it to base/ as easily as possible at that point. |
| 16 struct CoordinationUnitID { |
| 17 CoordinationUnitID(); |
| 18 CoordinationUnitID(const CoordinationUnitType& type, |
| 19 const std::string& new_id); |
| 20 |
| 21 bool operator==(const CoordinationUnitID& b) const { |
| 22 return id == b.id && type == b.type; |
| 23 } |
| 24 |
| 25 int64_t id; |
| 26 CoordinationUnitType type; |
| 27 }; |
| 28 |
| 29 } // resource_coordinator |
| 30 |
| 31 namespace std { |
| 32 |
| 33 template <> |
| 34 struct hash<resource_coordinator::CoordinationUnitID> { |
| 35 uint64_t operator()( |
| 36 const resource_coordinator::CoordinationUnitID& id) const { |
| 37 return ((static_cast<uint64_t>(id.type)) << 32) | id.id; |
| 38 } |
| 39 }; |
| 40 |
| 41 } // namespace std |
| 42 |
| 43 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_ |
OLD | NEW |