summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorchron@google.com <chron@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 23:43:05 +0000
committerchron@google.com <chron@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 23:43:05 +0000
commitea4929e2226a1a83becb9ea6e4b3fb0c29b11c0e (patch)
treefa61c0c05cebe5a2b7f0180b8674ca9cacc19b8e /chrome
parentbce55e2762118f3dc567afdd3a7af137899f783a (diff)
downloadchromium_src-ea4929e2226a1a83becb9ea6e4b3fb0c29b11c0e.zip
chromium_src-ea4929e2226a1a83becb9ea6e4b3fb0c29b11c0e.tar.gz
chromium_src-ea4929e2226a1a83becb9ea6e4b3fb0c29b11c0e.tar.bz2
Use syncable hashes that are base64.
Review URL: http://codereview.chromium.org/660209 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-xchrome/browser/sync/engine/syncapi.cc6
-rwxr-xr-xchrome/browser/sync/engine/syncapi_unittest.cc39
2 files changed, 19 insertions, 26 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index 7539e2b..6be8c11 100755
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -29,6 +29,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/base64.h"
#include "base/lock.h"
#include "base/platform_thread.h"
#include "base/scoped_ptr.h"
@@ -399,7 +400,10 @@ std::string BaseNode::GenerateSyncableHash(
std::string hash_input;
serialized_type.AppendToString(&hash_input);
hash_input.append(client_tag);
- return HexEncode(hash_input.data(), hash_input.length());
+
+ std::string encode_output;
+ CHECK(base::Base64Encode(base::SHA1HashString(hash_input), &encode_output));
+ return encode_output;
}
int64 BaseNode::GetParentId() const {
diff --git a/chrome/browser/sync/engine/syncapi_unittest.cc b/chrome/browser/sync/engine/syncapi_unittest.cc
index f92d4a3..b89e0de 100755
--- a/chrome/browser/sync/engine/syncapi_unittest.cc
+++ b/chrome/browser/sync/engine/syncapi_unittest.cc
@@ -8,7 +8,6 @@
#include "base/scoped_ptr.h"
#include "base/scoped_temp_dir.h"
-#include "base/string_util.h"
#include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
@@ -79,30 +78,20 @@ TEST_F(SyncApiTest, BasicTagWrite) {
}
}
-namespace {
-std::string HashToHex(const std::string& hash) {
- return HexEncode(hash.data(), hash.length());
-}
-} // namespace
-
-// TODO(chron): Finalize the hash format. Renable test. http://crbug.com/36827
-TEST_F(SyncApiTest, DISABLED_GenerateSyncableHash) {
-/*
- EXPECT_EQ("3B2697579984CEB3D2E306E8826B4ABD17DE9002",
- HashToHex(BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, "tag1")));
- EXPECT_EQ("88D150B511506FE219727D642942446430E42ECE",
- HashToHex(
- BaseNode::GenerateSyncableHash(syncable::PREFERENCES, "tag1")));
- EXPECT_EQ("80ED5C3D941768CEF7B073AF480FAD282285B39F",
- HashToHex(BaseNode::GenerateSyncableHash(syncable::AUTOFILL, "tag1")));
- EXPECT_EQ("0347982075CCD7F8D5C0A0C3A75D94A76D0890A6",
- HashToHex(BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, "tag2")));
- EXPECT_EQ("5D8C6417B6E14B8788B52B45822388014DB7B302",
- HashToHex(
- BaseNode::GenerateSyncableHash(syncable::PREFERENCES, "tag2")));
- EXPECT_EQ("185896CE8E4D1A18CB94DF8EC827E1CB6F032534",
- HashToHex(BaseNode::GenerateSyncableHash(syncable::AUTOFILL, "tag2")));
-*/
+TEST_F(SyncApiTest, GenerateSyncableHash) {
+ EXPECT_EQ("OyaXV5mEzrPS4wbogmtKvRfekAI=",
+ BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, "tag1"));
+ EXPECT_EQ("iNFQtRFQb+IZcn1kKUJEZDDkLs4=",
+ BaseNode::GenerateSyncableHash(syncable::PREFERENCES, "tag1"));
+ EXPECT_EQ("gO1cPZQXaM73sHOvSA+tKCKFs58=",
+ BaseNode::GenerateSyncableHash(syncable::AUTOFILL, "tag1"));
+
+ EXPECT_EQ("A0eYIHXM1/jVwKDDp12Up20IkKY=",
+ BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, "tag2"));
+ EXPECT_EQ("XYxkF7bhS4eItStFgiOIAU23swI=",
+ BaseNode::GenerateSyncableHash(syncable::PREFERENCES, "tag2"));
+ EXPECT_EQ("GFiWzo5NGhjLlN+OyCfhy28DJTQ=",
+ BaseNode::GenerateSyncableHash(syncable::AUTOFILL, "tag2"));
}
TEST_F(SyncApiTest, ModelTypesSiloed) {