| 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/string_number_conversions.h" | 7 #include "base/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 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Helper functions for SetFieldValues(). | 57 // Helper functions for SetFieldValues(). |
| 58 | 58 |
| 59 StringValue* Int64ToValue(int64 i) { | 59 StringValue* Int64ToValue(int64 i) { |
| 60 return Value::CreateStringValue(base::Int64ToString(i)); | 60 return Value::CreateStringValue(base::Int64ToString(i)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 StringValue* TimeToValue(const base::Time& t) { | 63 StringValue* TimeToValue(const base::Time& t) { |
| 64 return Value::CreateStringValue(csync::GetTimeDebugString(t)); | 64 return Value::CreateStringValue(syncer::GetTimeDebugString(t)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 StringValue* IdToValue(const Id& id) { | 67 StringValue* IdToValue(const Id& id) { |
| 68 return id.ToValue(); | 68 return id.ToValue(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace | 71 } // namespace |
| 72 | 72 |
| 73 DictionaryValue* EntryKernel::ToValue() const { | 73 DictionaryValue* EntryKernel::ToValue() const { |
| 74 DictionaryValue* kernel_info = new DictionaryValue(); | 74 DictionaryValue* kernel_info = new DictionaryValue(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // Pick out the function overload we want. | 112 // Pick out the function overload we want. |
| 113 StringValue* (*string_to_value)(const std::string&) = | 113 StringValue* (*string_to_value)(const std::string&) = |
| 114 &Value::CreateStringValue; | 114 &Value::CreateStringValue; |
| 115 SetFieldValues(*this, kernel_info, | 115 SetFieldValues(*this, kernel_info, |
| 116 &GetStringFieldString, string_to_value, | 116 &GetStringFieldString, string_to_value, |
| 117 STRING_FIELDS_BEGIN, STRING_FIELDS_END - 1); | 117 STRING_FIELDS_BEGIN, STRING_FIELDS_END - 1); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Proto fields. | 120 // Proto fields. |
| 121 SetFieldValues(*this, kernel_info, | 121 SetFieldValues(*this, kernel_info, |
| 122 &GetProtoFieldString, &csync::EntitySpecificsToValue, | 122 &GetProtoFieldString, &syncer::EntitySpecificsToValue, |
| 123 PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1); | 123 PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1); |
| 124 | 124 |
| 125 // Bit temps. | 125 // Bit temps. |
| 126 SetFieldValues(*this, kernel_info, | 126 SetFieldValues(*this, kernel_info, |
| 127 &GetBitTempString, &Value::CreateBooleanValue, | 127 &GetBitTempString, &Value::CreateBooleanValue, |
| 128 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1); | 128 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1); |
| 129 | 129 |
| 130 return kernel_info; | 130 return kernel_info; |
| 131 } | 131 } |
| 132 | 132 |
| 133 ListValue* EntryKernelMutationMapToValue( | 133 ListValue* EntryKernelMutationMapToValue( |
| 134 const EntryKernelMutationMap& mutations) { | 134 const EntryKernelMutationMap& mutations) { |
| 135 ListValue* list = new ListValue(); | 135 ListValue* list = new ListValue(); |
| 136 for (EntryKernelMutationMap::const_iterator it = mutations.begin(); | 136 for (EntryKernelMutationMap::const_iterator it = mutations.begin(); |
| 137 it != mutations.end(); ++it) { | 137 it != mutations.end(); ++it) { |
| 138 list->Append(EntryKernelMutationToValue(it->second)); | 138 list->Append(EntryKernelMutationToValue(it->second)); |
| 139 } | 139 } |
| 140 return list; | 140 return list; |
| 141 } | 141 } |
| 142 | 142 |
| 143 DictionaryValue* EntryKernelMutationToValue( | 143 DictionaryValue* EntryKernelMutationToValue( |
| 144 const EntryKernelMutation& mutation) { | 144 const EntryKernelMutation& mutation) { |
| 145 DictionaryValue* dict = new DictionaryValue(); | 145 DictionaryValue* dict = new DictionaryValue(); |
| 146 dict->Set("original", mutation.original.ToValue()); | 146 dict->Set("original", mutation.original.ToValue()); |
| 147 dict->Set("mutated", mutation.mutated.ToValue()); | 147 dict->Set("mutated", mutation.mutated.ToValue()); |
| 148 return dict; | 148 return dict; |
| 149 } | 149 } |
| 150 | 150 |
| 151 } | 151 } |
| OLD | NEW |