| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <iomanip> | 10 #include <iomanip> |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 class FullScanFilter : public IdFilter { | 1167 class FullScanFilter : public IdFilter { |
| 1168 public: | 1168 public: |
| 1169 virtual bool ShouldConsider(const Id& id) const { | 1169 virtual bool ShouldConsider(const Id& id) const { |
| 1170 return true; | 1170 return true; |
| 1171 } | 1171 } |
| 1172 }; | 1172 }; |
| 1173 | 1173 |
| 1174 class SomeIdsFilter : public IdFilter { | 1174 class SomeIdsFilter : public IdFilter { |
| 1175 public: | 1175 public: |
| 1176 virtual bool ShouldConsider(const Id& id) const { | 1176 virtual bool ShouldConsider(const Id& id) const { |
| 1177 return binary_search(ids_.begin(), ids_.end(), id); | 1177 return std::binary_search(ids_.begin(), ids_.end(), id); |
| 1178 } | 1178 } |
| 1179 std::vector<Id> ids_; | 1179 std::vector<Id> ids_; |
| 1180 }; | 1180 }; |
| 1181 | 1181 |
| 1182 bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, | 1182 bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, |
| 1183 const EntryKernelMutationMap& mutations) { | 1183 const EntryKernelMutationMap& mutations) { |
| 1184 MetahandleSet handles; | 1184 MetahandleSet handles; |
| 1185 SomeIdsFilter filter; | 1185 SomeIdsFilter filter; |
| 1186 filter.ids_.reserve(mutations.size()); | 1186 filter.ids_.reserve(mutations.size()); |
| 1187 for (EntryKernelMutationMap::const_iterator it = mutations.begin(), | 1187 for (EntryKernelMutationMap::const_iterator it = mutations.begin(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1208 return false; | 1208 return false; |
| 1209 } else { | 1209 } else { |
| 1210 SomeIdsFilter filter; | 1210 SomeIdsFilter filter; |
| 1211 MetahandleSet::iterator i; | 1211 MetahandleSet::iterator i; |
| 1212 for (i = handles.begin() ; i != handles.end() ; ++i) { | 1212 for (i = handles.begin() ; i != handles.end() ; ++i) { |
| 1213 Entry e(trans, GET_BY_HANDLE, *i); | 1213 Entry e(trans, GET_BY_HANDLE, *i); |
| 1214 if (!SyncAssert(e.good(), FROM_HERE, "Entry is bad", trans)) | 1214 if (!SyncAssert(e.good(), FROM_HERE, "Entry is bad", trans)) |
| 1215 return false; | 1215 return false; |
| 1216 filter.ids_.push_back(e.Get(ID)); | 1216 filter.ids_.push_back(e.Get(ID)); |
| 1217 } | 1217 } |
| 1218 sort(filter.ids_.begin(), filter.ids_.end()); | 1218 std::sort(filter.ids_.begin(), filter.ids_.end()); |
| 1219 if (!CheckTreeInvariants(trans, handles, filter)) | 1219 if (!CheckTreeInvariants(trans, handles, filter)) |
| 1220 return false; | 1220 return false; |
| 1221 } | 1221 } |
| 1222 return true; | 1222 return true; |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, | 1225 bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, |
| 1226 const MetahandleSet& handles, | 1226 const MetahandleSet& handles, |
| 1227 const IdFilter& idfilter) { | 1227 const IdFilter& idfilter) { |
| 1228 const int64 max_ms = kInvariantCheckMaxMs; | 1228 const int64 max_ms = kInvariantCheckMaxMs; |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2377 if (entry->ref(NEXT_ID).IsRoot() || | 2377 if (entry->ref(NEXT_ID).IsRoot() || |
| 2378 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) { | 2378 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) { |
| 2379 return entry; | 2379 return entry; |
| 2380 } | 2380 } |
| 2381 } | 2381 } |
| 2382 // There were no children in the linked list. | 2382 // There were no children in the linked list. |
| 2383 return NULL; | 2383 return NULL; |
| 2384 } | 2384 } |
| 2385 | 2385 |
| 2386 } // namespace syncable | 2386 } // namespace syncable |
| OLD | NEW |