| Index: sync/internal_api/base_node.cc
|
| diff --git a/sync/internal_api/base_node.cc b/sync/internal_api/base_node.cc
|
| index 19de5728203d4c662538abd59654867d01710f2e..9ee5111172a0cb403fb8fa51bed935ee6008c740 100644
|
| --- a/sync/internal_api/base_node.cc
|
| +++ b/sync/internal_api/base_node.cc
|
| @@ -6,8 +6,6 @@
|
|
|
| #include <stack>
|
|
|
| -#include "base/base64.h"
|
| -#include "base/sha1.h"
|
| #include "base/string_number_conversions.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "base/values.h"
|
| @@ -65,21 +63,6 @@ BaseNode::BaseNode() : password_data_(new sync_pb::PasswordSpecificsData) {}
|
|
|
| BaseNode::~BaseNode() {}
|
|
|
| -std::string BaseNode::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;
|
| -}
|
| -
|
| bool BaseNode::DecryptIfNecessary() {
|
| if (!GetEntry()->Get(syncable::UNIQUE_SERVER_TAG).empty())
|
| return true; // Ignore unique folders.
|
| @@ -212,34 +195,27 @@ bool BaseNode::HasChildren() const {
|
| }
|
|
|
| int64 BaseNode::GetPredecessorId() const {
|
| - syncable::Id id_string = GetEntry()->Get(syncable::PREV_ID);
|
| + syncable::Id id_string = GetEntry()->GetPredecessorId();
|
| if (id_string.IsRoot())
|
| return kInvalidId;
|
| return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
|
| }
|
|
|
| int64 BaseNode::GetSuccessorId() const {
|
| - syncable::Id id_string = GetEntry()->Get(syncable::NEXT_ID);
|
| + syncable::Id id_string = GetEntry()->GetSuccessorId();
|
| if (id_string.IsRoot())
|
| return kInvalidId;
|
| return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
|
| }
|
|
|
| int64 BaseNode::GetFirstChildId() const {
|
| - syncable::Directory* dir = GetTransaction()->GetDirectory();
|
| - syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans();
|
| - syncable::Id id_string;
|
| - // TODO(akalin): Propagate up the error further (see
|
| - // http://crbug.com/100907).
|
| - CHECK(dir->GetFirstChildId(trans,
|
| - GetEntry()->Get(syncable::ID), &id_string));
|
| + syncable::Id id_string = GetEntry()->GetFirstChildId();
|
| if (id_string.IsRoot())
|
| return kInvalidId;
|
| return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
|
| }
|
|
|
| int BaseNode::GetTotalNodeCount() const {
|
| - syncable::Directory* dir = GetTransaction()->GetDirectory();
|
| syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans();
|
|
|
| int count = 1; // Start with one to include the node itself.
|
| @@ -256,12 +232,14 @@ int BaseNode::GetTotalNodeCount() const {
|
| if (!entry.good())
|
| continue;
|
| syncable::Id id = entry.Get(syncable::ID);
|
| - syncable::Id child_id;
|
| - if (dir->GetFirstChildId(trans, id, &child_id) && !child_id.IsRoot())
|
| - stack.push(IdToMetahandle(trans, child_id));
|
| - syncable::Id successor_id = entry.Get(syncable::NEXT_ID);
|
| + syncable::Id successor_id = entry.GetSuccessorId();
|
| if (!successor_id.IsRoot())
|
| stack.push(IdToMetahandle(trans, successor_id));
|
| + if (!entry.Get(syncable::IS_DIR))
|
| + continue;
|
| + syncable::Id child_id = entry.GetFirstChildId();
|
| + if (!child_id.IsRoot())
|
| + stack.push(IdToMetahandle(trans, child_id));
|
| }
|
| return count;
|
| }
|
| @@ -285,12 +263,6 @@ DictionaryValue* BaseNode::GetDetailsAsValue() const {
|
| // it here.
|
| node_info->SetString("externalId",
|
| base::Int64ToString(GetExternalId()));
|
| - node_info->SetString("predecessorId",
|
| - base::Int64ToString(GetPredecessorId()));
|
| - node_info->SetString("successorId",
|
| - base::Int64ToString(GetSuccessorId()));
|
| - node_info->SetString("firstChildId",
|
| - base::Int64ToString(GetFirstChildId()));
|
| node_info->Set("entry",
|
| GetEntry()->ToValue(GetTransaction()->GetCryptographer()));
|
| return node_info;
|
|
|