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 <limits> | |
8 | |
9 #include "base/logging.h" | |
10 #include "third_party/smhasher/src/MurmurHash2.h" | |
11 | |
12 namespace resource_coordinator { | |
13 | |
14 // The seed to use when taking the murmur2 hash of the id. | |
15 const uint64_t kMurmur2HashSeed = 0; | |
16 | |
17 CoordinationUnitID::CoordinationUnitID() | |
18 : id(0), type(CoordinationUnitType::INVALID_TYPE) {} | |
19 | |
20 CoordinationUnitID::CoordinationUnitID(const CoordinationUnitType& type, | |
21 const std::string& new_id) | |
22 : type(type) { | |
23 DCHECK_GE( | |
24 static_cast<std::string::size_type>(std::numeric_limits<int>::max()), | |
dcheng
2017/04/18 05:40:46
Maybe:
DCHECK(base::IsValueInRangeForNumericType<
oystein (OOO til 10th of July)
2017/04/18 20:55:33
Done.
| |
25 new_id.size()); | |
26 id = MurmurHash2(&new_id.front(), static_cast<int>(new_id.size()), | |
27 kMurmur2HashSeed); | |
28 } | |
29 | |
30 } // resource_coordinator | |
OLD | NEW |