| 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/syncable/entry_kernel.h" | 5 #include "sync/syncable/entry_kernel.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "sync/protocol/proto_value_conversions.h" | 8 #include "sync/protocol/proto_value_conversions.h" |
| 9 #include "sync/syncable/syncable_enum_conversions.h" | 9 #include "sync/syncable/syncable_enum_conversions.h" |
| 10 #include "sync/util/cryptographer.h" | 10 #include "sync/util/cryptographer.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 base::StringValue* StringToValue(const std::string& str) { | 124 base::StringValue* StringToValue(const std::string& str) { |
| 125 return new base::StringValue(str); | 125 return new base::StringValue(str); |
| 126 } | 126 } |
| 127 | 127 |
| 128 base::StringValue* UniquePositionToValue(const UniquePosition& pos) { | 128 base::StringValue* UniquePositionToValue(const UniquePosition& pos) { |
| 129 return new base::StringValue(pos.ToDebugString()); | 129 return new base::StringValue(pos.ToDebugString()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 base::StringValue* AttachmentMetadataToValue( |
| 133 const sync_pb::AttachmentMetadata& a) { |
| 134 return new base::StringValue(a.SerializeAsString()); |
| 135 } |
| 136 |
| 132 } // namespace | 137 } // namespace |
| 133 | 138 |
| 134 base::DictionaryValue* EntryKernel::ToValue( | 139 base::DictionaryValue* EntryKernel::ToValue( |
| 135 Cryptographer* cryptographer) const { | 140 Cryptographer* cryptographer) const { |
| 136 base::DictionaryValue* kernel_info = new base::DictionaryValue(); | 141 base::DictionaryValue* kernel_info = new base::DictionaryValue(); |
| 137 kernel_info->SetBoolean("isDirty", is_dirty()); | 142 kernel_info->SetBoolean("isDirty", is_dirty()); |
| 138 kernel_info->Set("serverModelType", ModelTypeToValue(GetServerModelType())); | 143 kernel_info->Set("serverModelType", ModelTypeToValue(GetServerModelType())); |
| 139 | 144 |
| 140 // Int64 fields. | 145 // Int64 fields. |
| 141 SetFieldValues(*this, kernel_info, | 146 SetFieldValues(*this, kernel_info, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 184 |
| 180 // Proto fields. | 185 // Proto fields. |
| 181 SetEncryptableProtoValues(*this, cryptographer, kernel_info, | 186 SetEncryptableProtoValues(*this, cryptographer, kernel_info, |
| 182 PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1); | 187 PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1); |
| 183 | 188 |
| 184 // UniquePosition fields | 189 // UniquePosition fields |
| 185 SetFieldValues(*this, kernel_info, | 190 SetFieldValues(*this, kernel_info, |
| 186 &GetUniquePositionFieldString, &UniquePositionToValue, | 191 &GetUniquePositionFieldString, &UniquePositionToValue, |
| 187 UNIQUE_POSITION_FIELDS_BEGIN, UNIQUE_POSITION_FIELDS_END - 1); | 192 UNIQUE_POSITION_FIELDS_BEGIN, UNIQUE_POSITION_FIELDS_END - 1); |
| 188 | 193 |
| 194 // AttachmentMetadata fields |
| 195 SetFieldValues(*this, |
| 196 kernel_info, |
| 197 &GetAttachmentMetadataFieldString, |
| 198 &AttachmentMetadataToValue, |
| 199 ATTACHMENT_METADATA_FIELDS_BEGIN, |
| 200 ATTACHMENT_METADATA_FIELDS_END - 1); |
| 201 |
| 189 // Bit temps. | 202 // Bit temps. |
| 190 SetFieldValues(*this, kernel_info, | 203 SetFieldValues(*this, kernel_info, |
| 191 &GetBitTempString, &BooleanToValue, | 204 &GetBitTempString, &BooleanToValue, |
| 192 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1); | 205 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1); |
| 193 | 206 |
| 194 return kernel_info; | 207 return kernel_info; |
| 195 } | 208 } |
| 196 | 209 |
| 197 base::ListValue* EntryKernelMutationMapToValue( | 210 base::ListValue* EntryKernelMutationMapToValue( |
| 198 const EntryKernelMutationMap& mutations) { | 211 const EntryKernelMutationMap& mutations) { |
| 199 base::ListValue* list = new base::ListValue(); | 212 base::ListValue* list = new base::ListValue(); |
| 200 for (EntryKernelMutationMap::const_iterator it = mutations.begin(); | 213 for (EntryKernelMutationMap::const_iterator it = mutations.begin(); |
| 201 it != mutations.end(); ++it) { | 214 it != mutations.end(); ++it) { |
| 202 list->Append(EntryKernelMutationToValue(it->second)); | 215 list->Append(EntryKernelMutationToValue(it->second)); |
| 203 } | 216 } |
| 204 return list; | 217 return list; |
| 205 } | 218 } |
| 206 | 219 |
| 207 base::DictionaryValue* EntryKernelMutationToValue( | 220 base::DictionaryValue* EntryKernelMutationToValue( |
| 208 const EntryKernelMutation& mutation) { | 221 const EntryKernelMutation& mutation) { |
| 209 base::DictionaryValue* dict = new base::DictionaryValue(); | 222 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 210 dict->Set("original", mutation.original.ToValue(NULL)); | 223 dict->Set("original", mutation.original.ToValue(NULL)); |
| 211 dict->Set("mutated", mutation.mutated.ToValue(NULL)); | 224 dict->Set("mutated", mutation.mutated.ToValue(NULL)); |
| 212 return dict; | 225 return dict; |
| 213 } | 226 } |
| 214 | 227 |
| 215 } // namespace syncer | 228 } // namespace syncer |
| 216 } // namespace syncable | 229 } // namespace syncable |
| OLD | NEW |