summaryrefslogtreecommitdiffstats
path: root/sync/syncable/syncable_util.cc
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 20:54:28 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 20:54:28 +0000
commitb2bf91a172507d673a22b5922bb213fca2581844 (patch)
tree9a19ff77dae266373fb77dc3a70087fddbb072cf /sync/syncable/syncable_util.cc
parent859566a3a787d5450141368b2c704ed98c2c2e5b (diff)
downloadchromium_src-b2bf91a172507d673a22b5922bb213fca2581844.zip
chromium_src-b2bf91a172507d673a22b5922bb213fca2581844.tar.gz
chromium_src-b2bf91a172507d673a22b5922bb213fca2581844.tar.bz2
sync: Move unique_client_tag hashing code
This is one of many changes that will lead up to the introduction of the bookmark UniquePosition algorithm. We eventually want to use the hashing code to create a unique tag for bookmarks. This tag will be initialized at bookmark creation time in MutableEntry. This patch moves the hashing code out of BaseNode and into syncable_util so it can be accessed from the syncable layer. BUG=145412,126505 Review URL: https://chromiumcodereview.appspot.com/11571092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174449 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/syncable/syncable_util.cc')
-rw-r--r--sync/syncable/syncable_util.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/sync/syncable/syncable_util.cc b/sync/syncable/syncable_util.cc
index 36d08d0..0597109 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