Chromium Code Reviews| 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 | |
| 5 #include "services/resource_coordinator/public/cpp/coordination_unit_id.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/numerics/safe_conversions.h" | |
| 9 #include "third_party/smhasher/src/MurmurHash2.h" | |
|
nasko
2017/04/21 00:17:32
Doesn't std::hash suffice here?
oystein (OOO til 10th of July)
2017/04/21 17:57:55
I had that originally as well, primiano in #2 sugg
nasko
2017/04/24 22:10:50
Acknowledged.
| |
| 10 | |
| 11 namespace resource_coordinator { | |
| 12 | |
| 13 // The seed to use when taking the murmur2 hash of the id. | |
| 14 const uint64_t kMurmur2HashSeed = 0; | |
| 15 | |
| 16 CoordinationUnitID::CoordinationUnitID() | |
| 17 : id(0), type(CoordinationUnitType::INVALID_TYPE) {} | |
| 18 | |
| 19 CoordinationUnitID::CoordinationUnitID(const CoordinationUnitType& type, | |
| 20 const std::string& new_id) | |
|
nasko
2017/04/21 00:17:32
Let's keep the parameter names in sync between hea
oystein (OOO til 10th of July)
2017/04/21 17:57:55
Done.
| |
| 21 : type(type) { | |
| 22 DCHECK(base::IsValueInRangeForNumericType<int>(new_id.size())); | |
| 23 id = MurmurHash2(&new_id.front(), static_cast<int>(new_id.size()), | |
| 24 kMurmur2HashSeed); | |
| 25 } | |
| 26 | |
| 27 } // resource_coordinator | |
| OLD | NEW |