| OLD | NEW |
| (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 |
| OLD | NEW |