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

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

Issue 1258863007: [Sync] Add more info for invalid position check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move enum back to entry_kernel Created 5 years, 4 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') | no next file » | 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/json/string_escape.h"
7 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
8 #include "sync/protocol/proto_value_conversions.h" 9 #include "sync/protocol/proto_value_conversions.h"
10 #include "sync/syncable/syncable_columns.h"
9 #include "sync/syncable/syncable_enum_conversions.h" 11 #include "sync/syncable/syncable_enum_conversions.h"
10 #include "sync/util/cryptographer.h" 12 #include "sync/util/cryptographer.h"
11 13
12 namespace syncer { 14 namespace syncer {
13 namespace syncable { 15 namespace syncable {
14 16
15 EntryKernel::EntryKernel() : dirty_(false) { 17 EntryKernel::EntryKernel() : dirty_(false) {
16 // Everything else should already be default-initialized. 18 // Everything else should already be default-initialized.
17 for (int i = 0; i < INT64_FIELDS_COUNT; ++i) { 19 for (int i = 0; i < INT64_FIELDS_COUNT; ++i) {
18 int64_fields[i] = 0; 20 int64_fields[i] = 0;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 231 }
230 232
231 base::DictionaryValue* EntryKernelMutationToValue( 233 base::DictionaryValue* EntryKernelMutationToValue(
232 const EntryKernelMutation& mutation) { 234 const EntryKernelMutation& mutation) {
233 base::DictionaryValue* dict = new base::DictionaryValue(); 235 base::DictionaryValue* dict = new base::DictionaryValue();
234 dict->Set("original", mutation.original.ToValue(NULL)); 236 dict->Set("original", mutation.original.ToValue(NULL));
235 dict->Set("mutated", mutation.mutated.ToValue(NULL)); 237 dict->Set("mutated", mutation.mutated.ToValue(NULL));
236 return dict; 238 return dict;
237 } 239 }
238 240
241 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel) {
242 int i;
243 EntryKernel* const kernel = const_cast<EntryKernel*>(&entry_kernel);
244 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
245 os << g_metas_columns[i].name << ": "
246 << kernel->ref(static_cast<Int64Field>(i)) << ", ";
247 }
248 for (; i < TIME_FIELDS_END; ++i) {
249 os << g_metas_columns[i].name << ": "
250 << GetTimeDebugString(kernel->ref(static_cast<TimeField>(i))) << ", ";
251 }
252 for (; i < ID_FIELDS_END; ++i) {
253 os << g_metas_columns[i].name << ": "
254 << kernel->ref(static_cast<IdField>(i)) << ", ";
255 }
256 os << "Flags: ";
257 for (; i < BIT_FIELDS_END; ++i) {
258 if (kernel->ref(static_cast<BitField>(i)))
259 os << g_metas_columns[i].name << ", ";
260 }
261 for (; i < STRING_FIELDS_END; ++i) {
262 const std::string& field = kernel->ref(static_cast<StringField>(i));
263 os << g_metas_columns[i].name << ": " << field << ", ";
264 }
265 for (; i < PROTO_FIELDS_END; ++i) {
266 std::string escaped_str = base::EscapeBytesAsInvalidJSONString(
267 kernel->ref(static_cast<ProtoField>(i)).SerializeAsString(), false);
268 os << g_metas_columns[i].name << ": " << escaped_str << ", ";
269 }
270 for (; i < UNIQUE_POSITION_FIELDS_END; ++i) {
271 os << g_metas_columns[i].name << ": "
272 << kernel->ref(static_cast<UniquePositionField>(i)).ToDebugString()
273 << ", ";
274 }
275 for (; i < ATTACHMENT_METADATA_FIELDS_END; ++i) {
276 std::string escaped_str = base::EscapeBytesAsInvalidJSONString(
277 kernel->ref(static_cast<AttachmentMetadataField>(i))
278 .SerializeAsString(),
279 false);
280 os << g_metas_columns[i].name << ": " << escaped_str << ", ";
281 }
282 os << "TempFlags: ";
283 for (; i < BIT_TEMPS_END; ++i) {
284 if (kernel->ref(static_cast<BitTemp>(i)))
285 os << "#" << i - BIT_TEMPS_BEGIN << ", ";
286 }
287 return os;
288 }
289
239 } // namespace syncer 290 } // namespace syncer
240 } // namespace syncable 291 } // namespace syncable
OLDNEW
« no previous file with comments | « sync/syncable/entry_kernel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698