Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: sync/syncable/entry_kernel.cc

Issue 10989063: Changed DB to store node positions as Ordinals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed memory leak error in unittest Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/syncable/entry_kernel.h ('k') | sync/syncable/mutable_entry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 StringValue* TimeToValue(const base::Time& t) { 64 StringValue* TimeToValue(const base::Time& t) {
65 return Value::CreateStringValue(GetTimeDebugString(t)); 65 return Value::CreateStringValue(GetTimeDebugString(t));
66 } 66 }
67 67
68 StringValue* IdToValue(const Id& id) { 68 StringValue* IdToValue(const Id& id) {
69 return id.ToValue(); 69 return id.ToValue();
70 } 70 }
71 71
72 StringValue* OrdinalToValue(const NodeOrdinal& ord) {
73 return Value::CreateStringValue(ord.ToDebugString());
74 }
75
72 } // namespace 76 } // namespace
73 77
74 DictionaryValue* EntryKernel::ToValue() const { 78 DictionaryValue* EntryKernel::ToValue() const {
75 DictionaryValue* kernel_info = new DictionaryValue(); 79 DictionaryValue* kernel_info = new DictionaryValue();
76 kernel_info->SetBoolean("isDirty", is_dirty()); 80 kernel_info->SetBoolean("isDirty", is_dirty());
77 kernel_info->Set("serverModelType", ModelTypeToValue(GetServerModelType())); 81 kernel_info->Set("serverModelType", ModelTypeToValue(GetServerModelType()));
78 82
79 // Int64 fields. 83 // Int64 fields.
80 SetFieldValues(*this, kernel_info, 84 SetFieldValues(*this, kernel_info,
81 &GetMetahandleFieldString, &Int64ToValue, 85 &GetMetahandleFieldString, &Int64ToValue,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 SetFieldValues(*this, kernel_info, 120 SetFieldValues(*this, kernel_info,
117 &GetStringFieldString, string_to_value, 121 &GetStringFieldString, string_to_value,
118 STRING_FIELDS_BEGIN, STRING_FIELDS_END - 1); 122 STRING_FIELDS_BEGIN, STRING_FIELDS_END - 1);
119 } 123 }
120 124
121 // Proto fields. 125 // Proto fields.
122 SetFieldValues(*this, kernel_info, 126 SetFieldValues(*this, kernel_info,
123 &GetProtoFieldString, &EntitySpecificsToValue, 127 &GetProtoFieldString, &EntitySpecificsToValue,
124 PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1); 128 PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1);
125 129
130 // Ordinal fields
131 SetFieldValues(*this, kernel_info,
132 &GetOrdinalFieldString, &OrdinalToValue,
133 ORDINAL_FIELDS_BEGIN, ORDINAL_FIELDS_END - 1);
134
126 // Bit temps. 135 // Bit temps.
127 SetFieldValues(*this, kernel_info, 136 SetFieldValues(*this, kernel_info,
128 &GetBitTempString, &Value::CreateBooleanValue, 137 &GetBitTempString, &Value::CreateBooleanValue,
129 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1); 138 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1);
130 139
131 return kernel_info; 140 return kernel_info;
132 } 141 }
133 142
134 ListValue* EntryKernelMutationMapToValue( 143 ListValue* EntryKernelMutationMapToValue(
135 const EntryKernelMutationMap& mutations) { 144 const EntryKernelMutationMap& mutations) {
136 ListValue* list = new ListValue(); 145 ListValue* list = new ListValue();
137 for (EntryKernelMutationMap::const_iterator it = mutations.begin(); 146 for (EntryKernelMutationMap::const_iterator it = mutations.begin();
138 it != mutations.end(); ++it) { 147 it != mutations.end(); ++it) {
139 list->Append(EntryKernelMutationToValue(it->second)); 148 list->Append(EntryKernelMutationToValue(it->second));
140 } 149 }
141 return list; 150 return list;
142 } 151 }
143 152
144 DictionaryValue* EntryKernelMutationToValue( 153 DictionaryValue* EntryKernelMutationToValue(
145 const EntryKernelMutation& mutation) { 154 const EntryKernelMutation& mutation) {
146 DictionaryValue* dict = new DictionaryValue(); 155 DictionaryValue* dict = new DictionaryValue();
147 dict->Set("original", mutation.original.ToValue()); 156 dict->Set("original", mutation.original.ToValue());
148 dict->Set("mutated", mutation.mutated.ToValue()); 157 dict->Set("mutated", mutation.mutated.ToValue());
149 return dict; 158 return dict;
150 } 159 }
151 160
152 } // namespace syncer 161 } // namespace syncer
153 } // namespace syncable 162 } // namespace syncable
OLDNEW
« no previous file with comments | « sync/syncable/entry_kernel.h ('k') | sync/syncable/mutable_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698