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

Unified Diff: sync/syncable/syncable_util.cc

Issue 11636006: WIP: The Bookmark Position Megapatch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Various updates, including switch suffix to unique_client_tag style 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/test/engine/mock_connection_manager.h » ('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 1bfe6ff960bd98f6c1b97118da692c243d276c17..0c95ea3de89898196eac4a8d77605f3478d9899c 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"
@@ -64,27 +66,13 @@ void ChangeEntryIDAndUpdateChildren(
while (i != children.end()) {
MutableEntry child_entry(trans, GET_BY_HANDLE, *i++);
CHECK(child_entry.good());
- // Use the unchecked setter here to avoid touching the child's NEXT_ID
- // and PREV_ID fields (which Put(PARENT_ID) would normally do to
- // maintain linked-list invariants). In this case, NEXT_ID and PREV_ID
- // among the children will be valid after the loop, since we update all
- // the children at once.
+ // Use the unchecked setter here to avoid touching the child's
+ // UNIQUE_POSITION field. In this case, UNIQUE_POSITION among the
+ // children will be valid after the loop, since we update all the children
+ // at once.
child_entry.PutParentIdPropertyOnly(new_id);
}
}
- // Update Id references on the previous and next nodes in the sibling
- // order. Do this by reinserting into the linked list; the first
- // step in PutPredecessor is to Unlink from the existing order, which
- // will overwrite the stale Id value from the adjacent nodes.
- if (entry->Get(PREV_ID) == entry->Get(NEXT_ID) &&
- entry->Get(PREV_ID) == old_id) {
- // We just need a shallow update to |entry|'s fields since it is already
- // self looped.
- entry->Put(NEXT_ID, new_id);
- entry->Put(PREV_ID, new_id);
- } else {
- entry->PutPredecessor(entry->Get(PREV_ID));
- }
}
// Function to handle runtime failures on syncable code. Rather than crashing,
@@ -102,5 +90,27 @@ 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;
+}
+
+std::string GenerateSyncableBookmarkHash(
+ const std::string originator_cache_guid,
+ const std::string originator_client_item_id) {
+ return syncable::GenerateSyncableHash(
+ BOOKMARKS, originator_cache_guid + originator_client_item_id);
+}
+
} // namespace syncable
} // namespace syncer
« no previous file with comments | « sync/syncable/syncable_util.h ('k') | sync/test/engine/mock_connection_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698