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

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

Issue 2798713002: Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Wrap EventType directly in resource_coordinator namespace when using helper Created 3 years, 8 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
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698