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

Unified Diff: sync/syncable/syncable_util.cc

Issue 11571092: sync: Move unique_client_tag hashing code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo some changes and move a test to syncable_util_unittest Created 8 years 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 | « sync/syncable/syncable_util.h ('k') | sync/syncable/syncable_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « sync/syncable/syncable_util.h ('k') | sync/syncable/syncable_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698