Index: sync/syncable/syncable_util.cc |
diff --git a/sync/syncable/syncable_util.cc b/sync/syncable/syncable_util.cc |
index 36d08d0146f6d6c175edb2732a93e4d4ede80a8e..0597109d41b62426c822fd40fce51904d35b69b3 100644 |
--- a/sync/syncable/syncable_util.cc |
+++ b/sync/syncable/syncable_util.cc |
@@ -4,8 +4,10 @@ |
#include "sync/syncable/syncable_util.h" |
+#include "base/base64.h" |
#include "base/location.h" |
#include "base/logging.h" |
+#include "base/sha1.h" |
#include "sync/syncable/directory.h" |
#include "sync/syncable/entry.h" |
#include "sync/syncable/mutable_entry.h" |
@@ -102,5 +104,20 @@ bool SyncAssert(bool condition, |
return true; |
} |
+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; |
+ CHECK(base::Base64Encode(base::SHA1HashString(hash_input), &encode_output)); |
+ return encode_output; |
+} |
+ |
} // namespace syncable |
} // namespace syncer |