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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 "components/sync/base/hash_util.h"
6
7 #include "base/base64.h"
8 #include "base/sha1.h"
9 #include "components/sync/protocol/sync.pb.h"
10
11 namespace syncer {
12
13 std::string GenerateSyncableHash(ModelType model_type,
14 const std::string& client_tag) {
15 // Blank PB with just the field in it has termination symbol,
16 // handy for delimiter.
17 sync_pb::EntitySpecifics serialized_type;
18 AddDefaultFieldValue(model_type, &serialized_type);
19 std::string hash_input;
20 serialized_type.AppendToString(&hash_input);
21 hash_input.append(client_tag);
22
23 std::string encode_output;
24 base::Base64Encode(base::SHA1HashString(hash_input), &encode_output);
25 return encode_output;
26 }
27
28 std::string GenerateSyncableBookmarkHash(
29 const std::string& originator_cache_guid,
30 const std::string& originator_client_item_id) {
31 return GenerateSyncableHash(
32 BOOKMARKS, originator_cache_guid + originator_client_item_id);
33 }
34
35 } // namespace syncer
OLDNEW
« 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