| 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
|
|
|