| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/internal_api/public/base_node.h" | 5 #include "sync/internal_api/public/base_node.h" |
| 6 | 6 |
| 7 #include <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool BaseNode::HasChildren() const { | 172 bool BaseNode::HasChildren() const { |
| 173 syncable::Directory* dir = GetTransaction()->GetDirectory(); | 173 syncable::Directory* dir = GetTransaction()->GetDirectory(); |
| 174 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans(); | 174 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans(); |
| 175 return dir->HasChildren(trans, GetEntry()->GetId()); | 175 return dir->HasChildren(trans, GetEntry()->GetId()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 int64 BaseNode::GetPredecessorId() const { | 178 int64 BaseNode::GetPredecessorId() const { |
| 179 syncable::Id id_string = GetEntry()->GetPredecessorId(); | 179 syncable::Id id_string = GetEntry()->GetPredecessorId(); |
| 180 if (id_string.IsRoot()) | 180 if (id_string.IsNull()) |
| 181 return kInvalidId; | 181 return kInvalidId; |
| 182 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); | 182 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); |
| 183 } | 183 } |
| 184 | 184 |
| 185 int64 BaseNode::GetSuccessorId() const { | 185 int64 BaseNode::GetSuccessorId() const { |
| 186 syncable::Id id_string = GetEntry()->GetSuccessorId(); | 186 syncable::Id id_string = GetEntry()->GetSuccessorId(); |
| 187 if (id_string.IsRoot()) | 187 if (id_string.IsNull()) |
| 188 return kInvalidId; | 188 return kInvalidId; |
| 189 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); | 189 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); |
| 190 } | 190 } |
| 191 | 191 |
| 192 int64 BaseNode::GetFirstChildId() const { | 192 int64 BaseNode::GetFirstChildId() const { |
| 193 syncable::Id id_string = GetEntry()->GetFirstChildId(); | 193 syncable::Id id_string = GetEntry()->GetFirstChildId(); |
| 194 if (id_string.IsRoot()) | 194 if (id_string.IsNull()) |
| 195 return kInvalidId; | 195 return kInvalidId; |
| 196 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); | 196 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void BaseNode::GetChildIds(std::vector<int64>* result) const { | 199 void BaseNode::GetChildIds(std::vector<int64>* result) const { |
| 200 GetEntry()->GetChildHandles(result); | 200 GetEntry()->GetChildHandles(result); |
| 201 } | 201 } |
| 202 | 202 |
| 203 int BaseNode::GetTotalNodeCount() const { | 203 int BaseNode::GetTotalNodeCount() const { |
| 204 return GetEntry()->GetTotalNodeCount(); | 204 return GetEntry()->GetTotalNodeCount(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 const sync_pb::EntitySpecifics& specifics) { | 304 const sync_pb::EntitySpecifics& specifics) { |
| 305 ModelType type = GetModelTypeFromSpecifics(specifics); | 305 ModelType type = GetModelTypeFromSpecifics(specifics); |
| 306 DCHECK_NE(UNSPECIFIED, type); | 306 DCHECK_NE(UNSPECIFIED, type); |
| 307 if (GetModelType() != UNSPECIFIED) { | 307 if (GetModelType() != UNSPECIFIED) { |
| 308 DCHECK_EQ(GetModelType(), type); | 308 DCHECK_EQ(GetModelType(), type); |
| 309 } | 309 } |
| 310 unencrypted_data_.CopyFrom(specifics); | 310 unencrypted_data_.CopyFrom(specifics); |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace syncer | 313 } // namespace syncer |
| OLD | NEW |