| 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "sync/protocol/theme_specifics.pb.h" | 21 #include "sync/protocol/theme_specifics.pb.h" |
| 22 #include "sync/protocol/typed_url_specifics.pb.h" | 22 #include "sync/protocol/typed_url_specifics.pb.h" |
| 23 #include "sync/syncable/directory.h" | 23 #include "sync/syncable/directory.h" |
| 24 #include "sync/syncable/entry.h" | 24 #include "sync/syncable/entry.h" |
| 25 #include "sync/syncable/syncable_id.h" | 25 #include "sync/syncable/syncable_id.h" |
| 26 #include "sync/util/time.h" | 26 #include "sync/util/time.h" |
| 27 | 27 |
| 28 using syncable::SPECIFICS; | 28 using syncable::SPECIFICS; |
| 29 using sync_pb::AutofillProfileSpecifics; | 29 using sync_pb::AutofillProfileSpecifics; |
| 30 | 30 |
| 31 namespace csync { | 31 namespace syncer { |
| 32 | 32 |
| 33 // Helper function to look up the int64 metahandle of an object given the ID | 33 // Helper function to look up the int64 metahandle of an object given the ID |
| 34 // string. | 34 // string. |
| 35 static int64 IdToMetahandle(syncable::BaseTransaction* trans, | 35 static int64 IdToMetahandle(syncable::BaseTransaction* trans, |
| 36 const syncable::Id& id) { | 36 const syncable::Id& id) { |
| 37 syncable::Entry entry(trans, syncable::GET_BY_ID, id); | 37 syncable::Entry entry(trans, syncable::GET_BY_ID, id); |
| 38 if (!entry.good()) | 38 if (!entry.good()) |
| 39 return kInvalidId; | 39 return kInvalidId; |
| 40 return entry.Get(syncable::META_HANDLE); | 40 return entry.Get(syncable::META_HANDLE); |
| 41 } | 41 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 node_info->SetBoolean("isFolder", GetIsFolder()); | 248 node_info->SetBoolean("isFolder", GetIsFolder()); |
| 249 node_info->SetString("title", GetTitle()); | 249 node_info->SetString("title", GetTitle()); |
| 250 node_info->Set("type", ModelTypeToValue(GetModelType())); | 250 node_info->Set("type", ModelTypeToValue(GetModelType())); |
| 251 return node_info; | 251 return node_info; |
| 252 } | 252 } |
| 253 | 253 |
| 254 DictionaryValue* BaseNode::GetDetailsAsValue() const { | 254 DictionaryValue* BaseNode::GetDetailsAsValue() const { |
| 255 DictionaryValue* node_info = GetSummaryAsValue(); | 255 DictionaryValue* node_info = GetSummaryAsValue(); |
| 256 node_info->SetString( | 256 node_info->SetString( |
| 257 "modificationTime", | 257 "modificationTime", |
| 258 csync::GetTimeDebugString(GetModificationTime())); | 258 syncer::GetTimeDebugString(GetModificationTime())); |
| 259 node_info->SetString("parentId", base::Int64ToString(GetParentId())); | 259 node_info->SetString("parentId", base::Int64ToString(GetParentId())); |
| 260 // Specifics are already in the Entry value, so no need to duplicate | 260 // Specifics are already in the Entry value, so no need to duplicate |
| 261 // it here. | 261 // it here. |
| 262 node_info->SetString("externalId", | 262 node_info->SetString("externalId", |
| 263 base::Int64ToString(GetExternalId())); | 263 base::Int64ToString(GetExternalId())); |
| 264 node_info->SetString("predecessorId", | 264 node_info->SetString("predecessorId", |
| 265 base::Int64ToString(GetPredecessorId())); | 265 base::Int64ToString(GetPredecessorId())); |
| 266 node_info->SetString("successorId", | 266 node_info->SetString("successorId", |
| 267 base::Int64ToString(GetSuccessorId())); | 267 base::Int64ToString(GetSuccessorId())); |
| 268 node_info->SetString("firstChildId", | 268 node_info->SetString("firstChildId", |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 void BaseNode::SetUnencryptedSpecifics( | 345 void BaseNode::SetUnencryptedSpecifics( |
| 346 const sync_pb::EntitySpecifics& specifics) { | 346 const sync_pb::EntitySpecifics& specifics) { |
| 347 syncable::ModelType type = syncable::GetModelTypeFromSpecifics(specifics); | 347 syncable::ModelType type = syncable::GetModelTypeFromSpecifics(specifics); |
| 348 DCHECK_NE(syncable::UNSPECIFIED, type); | 348 DCHECK_NE(syncable::UNSPECIFIED, type); |
| 349 if (GetModelType() != syncable::UNSPECIFIED) { | 349 if (GetModelType() != syncable::UNSPECIFIED) { |
| 350 DCHECK_EQ(GetModelType(), type); | 350 DCHECK_EQ(GetModelType(), type); |
| 351 } | 351 } |
| 352 unencrypted_data_.CopyFrom(specifics); | 352 unencrypted_data_.CopyFrom(specifics); |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace csync | 355 } // namespace syncer |
| OLD | NEW |