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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: services/resource_coordinator/public/cpp/coordination_unit_id.cc
diff --git a/services/resource_coordinator/public/cpp/coordination_unit_id.cc b/services/resource_coordinator/public/cpp/coordination_unit_id.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f72057da12dd60b45fcc5ff659a43c6e79c6e4df
--- /dev/null
+++ b/services/resource_coordinator/public/cpp/coordination_unit_id.cc
@@ -0,0 +1,30 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/resource_coordinator/public/cpp/coordination_unit_id.h"
+
+#include <limits>
+
+#include "base/logging.h"
+#include "third_party/smhasher/src/MurmurHash2.h"
+
+namespace resource_coordinator {
+
+// The seed to use when taking the murmur2 hash of the id.
+const uint64_t kMurmur2HashSeed = 0;
+
+CoordinationUnitID::CoordinationUnitID()
+ : id(0), type(CoordinationUnitType::INVALID_TYPE) {}
+
+CoordinationUnitID::CoordinationUnitID(const CoordinationUnitType& type,
+ const std::string& new_id)
+ : type(type) {
+ DCHECK_GE(
+ 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.
+ new_id.size());
+ id = MurmurHash2(&new_id.front(), static_cast<int>(new_id.size()),
+ kMurmur2HashSeed);
+}
+
+} // resource_coordinator

Powered by Google App Engine
This is Rietveld 408576698