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

Side by Side Diff: sync/syncable/entry.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/directory.cc ('k') | sync/syncable/entry_kernel.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.h" 5 #include "sync/syncable/entry.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "base/json/string_escape.h"
10 #include "base/strings/string_util.h"
11 #include "sync/syncable/directory.h" 9 #include "sync/syncable/directory.h"
12 #include "sync/syncable/syncable_base_transaction.h" 10 #include "sync/syncable/syncable_base_transaction.h"
13 #include "sync/syncable/syncable_columns.h"
14
15 using std::string;
16 11
17 namespace syncer { 12 namespace syncer {
18 namespace syncable { 13 namespace syncable {
19 14
20 Entry::Entry(BaseTransaction* trans, GetById, const Id& id) 15 Entry::Entry(BaseTransaction* trans, GetById, const Id& id)
21 : basetrans_(trans) { 16 : basetrans_(trans) {
22 kernel_ = trans->directory()->GetEntryById(id); 17 kernel_ = trans->directory()->GetEntryById(id);
23 } 18 }
24 19
25 Entry::Entry(BaseTransaction* trans, GetByClientTag, const string& tag) 20 Entry::Entry(BaseTransaction* trans, GetByClientTag, const std::string& tag)
26 : basetrans_(trans) { 21 : basetrans_(trans) {
27 kernel_ = trans->directory()->GetEntryByClientTag(tag); 22 kernel_ = trans->directory()->GetEntryByClientTag(tag);
28 } 23 }
29 24
30 Entry::Entry(BaseTransaction* trans, GetTypeRoot, ModelType type) 25 Entry::Entry(BaseTransaction* trans, GetTypeRoot, ModelType type)
31 : basetrans_(trans) { 26 : basetrans_(trans) {
32 const std::string& tag = ModelTypeToRootTag(type); 27 const std::string& tag = ModelTypeToRootTag(type);
33 kernel_ = trans->directory()->GetEntryByServerTag(tag); 28 kernel_ = trans->directory()->GetEntryByServerTag(tag);
34 } 29 }
35 30
36 Entry::Entry(BaseTransaction* trans, GetByHandle, int64 metahandle) 31 Entry::Entry(BaseTransaction* trans, GetByHandle, int64 metahandle)
37 : basetrans_(trans) { 32 : basetrans_(trans) {
38 kernel_ = trans->directory()->GetEntryByHandle(metahandle); 33 kernel_ = trans->directory()->GetEntryByHandle(metahandle);
39 } 34 }
40 35
41 Entry::Entry(BaseTransaction* trans, GetByServerTag, const string& tag) 36 Entry::Entry(BaseTransaction* trans, GetByServerTag, const std::string& tag)
42 : basetrans_(trans) { 37 : basetrans_(trans) {
43 kernel_ = trans->directory()->GetEntryByServerTag(tag); 38 kernel_ = trans->directory()->GetEntryByServerTag(tag);
44 } 39 }
45 40
46 Directory* Entry::dir() const { 41 Directory* Entry::dir() const {
47 return basetrans_->directory(); 42 return basetrans_->directory();
48 } 43 }
49 44
50 base::DictionaryValue* Entry::ToValue(Cryptographer* cryptographer) const { 45 base::DictionaryValue* Entry::ToValue(Cryptographer* cryptographer) const {
51 base::DictionaryValue* entry_info = new base::DictionaryValue(); 46 base::DictionaryValue* entry_info = new base::DictionaryValue();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 123
129 bool Entry::ShouldMaintainPosition() const { 124 bool Entry::ShouldMaintainPosition() const {
130 return kernel_->ShouldMaintainPosition(); 125 return kernel_->ShouldMaintainPosition();
131 } 126 }
132 127
133 bool Entry::ShouldMaintainHierarchy() const { 128 bool Entry::ShouldMaintainHierarchy() const {
134 return kernel_->ShouldMaintainHierarchy(); 129 return kernel_->ShouldMaintainHierarchy();
135 } 130 }
136 131
137 std::ostream& operator<<(std::ostream& os, const Entry& entry) { 132 std::ostream& operator<<(std::ostream& os, const Entry& entry) {
138 int i; 133 os << *(entry.kernel_);
139 EntryKernel* const kernel = entry.kernel_;
140 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
141 os << g_metas_columns[i].name << ": "
142 << kernel->ref(static_cast<Int64Field>(i)) << ", ";
143 }
144 for ( ; i < TIME_FIELDS_END; ++i) {
145 os << g_metas_columns[i].name << ": "
146 << GetTimeDebugString(kernel->ref(static_cast<TimeField>(i))) << ", ";
147 }
148 for ( ; i < ID_FIELDS_END; ++i) {
149 os << g_metas_columns[i].name << ": "
150 << kernel->ref(static_cast<IdField>(i)) << ", ";
151 }
152 os << "Flags: ";
153 for ( ; i < BIT_FIELDS_END; ++i) {
154 if (kernel->ref(static_cast<BitField>(i)))
155 os << g_metas_columns[i].name << ", ";
156 }
157 for ( ; i < STRING_FIELDS_END; ++i) {
158 const std::string& field = kernel->ref(static_cast<StringField>(i));
159 os << g_metas_columns[i].name << ": " << field << ", ";
160 }
161 for ( ; i < PROTO_FIELDS_END; ++i) {
162 std::string escaped_str = base::EscapeBytesAsInvalidJSONString(
163 kernel->ref(static_cast<ProtoField>(i)).SerializeAsString(),
164 false);
165 os << g_metas_columns[i].name << ": " << escaped_str << ", ";
166 }
167 for ( ; i < UNIQUE_POSITION_FIELDS_END; ++i) {
168 os << g_metas_columns[i].name << ": "
169 << kernel->ref(static_cast<UniquePositionField>(i)).ToDebugString()
170 << ", ";
171 }
172 for ( ; i < ATTACHMENT_METADATA_FIELDS_END; ++i) {
173 std::string escaped_str = base::EscapeBytesAsInvalidJSONString(
174 kernel->ref(static_cast<AttachmentMetadataField>(i))
175 .SerializeAsString(),
176 false);
177 os << g_metas_columns[i].name << ": " << escaped_str << ", ";
178 }
179 os << "TempFlags: ";
180 for ( ; i < BIT_TEMPS_END; ++i) {
181 if (kernel->ref(static_cast<BitTemp>(i)))
182 os << "#" << i - BIT_TEMPS_BEGIN << ", ";
183 }
184 return os; 134 return os;
185 } 135 }
186 136
187 } // namespace syncable 137 } // namespace syncable
188 } // namespace syncer 138 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/entry_kernel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698