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

Unified Diff: components/sync/base/hash_util.cc

Issue 2502253003: [Sync] Move GenerateSyncableHash to base. (Closed)
Patch Set: Keep full syncable/ DEP. Created 4 years, 1 month 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
« no previous file with comments | « components/sync/base/hash_util.h ('k') | components/sync/base/hash_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/base/hash_util.cc
diff --git a/components/sync/base/hash_util.cc b/components/sync/base/hash_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..58924ff3b44f235b77883412fe66efa40812e47f
--- /dev/null
+++ b/components/sync/base/hash_util.cc
@@ -0,0 +1,35 @@
+// Copyright 2016 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 "components/sync/base/hash_util.h"
+
+#include "base/base64.h"
+#include "base/sha1.h"
+#include "components/sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+std::string GenerateSyncableHash(ModelType model_type,
+ const std::string& client_tag) {
+ // Blank PB with just the field in it has termination symbol,
+ // handy for delimiter.
+ sync_pb::EntitySpecifics serialized_type;
+ AddDefaultFieldValue(model_type, &serialized_type);
+ std::string hash_input;
+ serialized_type.AppendToString(&hash_input);
+ hash_input.append(client_tag);
+
+ std::string encode_output;
+ base::Base64Encode(base::SHA1HashString(hash_input), &encode_output);
+ return encode_output;
+}
+
+std::string GenerateSyncableBookmarkHash(
+ const std::string& originator_cache_guid,
+ const std::string& originator_client_item_id) {
+ return GenerateSyncableHash(
+ BOOKMARKS, originator_cache_guid + originator_client_item_id);
+}
+
+} // namespace syncer
« no previous file with comments | « components/sync/base/hash_util.h ('k') | components/sync/base/hash_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698