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

Side by Side Diff: services/resource_coordinator/public/cpp/coordination_unit_id.h

Issue 2892443002: [GRC] Process Coordination Unit support for Global Resource Controller (Closed)
Patch Set: Remove unused headers and use forward declarations 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_ 4 #ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_
5 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_ 5 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h" 9 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h"
10 #include "services/resource_coordinator/public/cpp/resource_coordinator_export.h " 10 #include "services/resource_coordinator/public/cpp/resource_coordinator_export.h "
11 11
12 namespace resource_coordinator { 12 namespace resource_coordinator {
13 13
14 // This is a native struct rather than a mojom struct as we eventually want 14 // This is a native struct rather than a mojom struct as we eventually want
15 // to annotate base::TaskRunner with CUs for cost attribution purses and 15 // to annotate base::TaskRunner with CUs for cost attribution purses and
16 // would like to move it to base/ as easily as possible at that point. 16 // would like to move it to base/ as easily as possible at that point.
17 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT CoordinationUnitID { 17 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT CoordinationUnitID {
18 CoordinationUnitID(); 18 CoordinationUnitID();
19 CoordinationUnitID(const CoordinationUnitType& type, 19 CoordinationUnitID(const CoordinationUnitType& type,
20 const std::string& new_id); 20 const std::string& new_id);
21 CoordinationUnitID(const CoordinationUnitType& type, uint64_t new_id);
oystein (OOO til 10th of July) 2017/05/17 23:06:07 Slight yak shave, sorry: Can you make the id type
matthalp 2017/05/18 16:13:46 Done, but with a caveat: The most straight-forwar
oystein (OOO til 10th of July) 2017/05/18 21:24:32 Yep that makes sense to me, including the rename:
21 22
22 bool operator==(const CoordinationUnitID& b) const { 23 bool operator==(const CoordinationUnitID& b) const {
23 return id == b.id && type == b.type; 24 return id == b.id && type == b.type;
24 } 25 }
25 26
26 int64_t id; 27 int64_t id;
27 CoordinationUnitType type; 28 CoordinationUnitType type;
28 }; 29 };
29 30
30 } // resource_coordinator 31 } // resource_coordinator
31 32
32 namespace std { 33 namespace std {
33 34
34 template <> 35 template <>
35 struct hash<resource_coordinator::CoordinationUnitID> { 36 struct hash<resource_coordinator::CoordinationUnitID> {
36 uint64_t operator()( 37 uint64_t operator()(
37 const resource_coordinator::CoordinationUnitID& id) const { 38 const resource_coordinator::CoordinationUnitID& id) const {
38 return ((static_cast<uint64_t>(id.type)) << 32) | id.id; 39 return ((static_cast<uint64_t>(id.type)) << 32) | id.id;
39 } 40 }
40 }; 41 };
41 42
42 } // namespace std 43 } // namespace std
43 44
44 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_ 45 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698