| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/sync/engine_impl/get_commit_ids.h" | 5 #include "components/sync/engine_impl/get_commit_ids.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "components/sync/base/cryptographer.h" | 10 #include "components/sync/base/cryptographer.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // New clients (following the resolution of crbug.com/125381) should not | 143 // New clients (following the resolution of crbug.com/125381) should not |
| 144 // create such items. Old clients may have left some in the database | 144 // create such items. Old clients may have left some in the database |
| 145 // (crbug.com/132905), but we should now be cleaning them on startup. | 145 // (crbug.com/132905), but we should now be cleaning them on startup. |
| 146 NOTREACHED() << "Found deleted and unsynced local item: " << entry; | 146 NOTREACHED() << "Found deleted and unsynced local item: " << entry; |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Extra validity checks. | 150 // Extra validity checks. |
| 151 syncable::Id id = entry.GetId(); | 151 syncable::Id id = entry.GetId(); |
| 152 if (id == entry.GetParentId()) { | 152 if (id == entry.GetParentId()) { |
| 153 CHECK(id.IsRoot()) << "Non-root item is self parenting." << entry; | 153 // Non-root item is self parenting.|entry|. |
| 154 CHECK(id.IsRoot()); |
| 154 // If the root becomes unsynced it can cause us problems. | 155 // If the root becomes unsynced it can cause us problems. |
| 155 NOTREACHED() << "Root item became unsynced " << entry; | 156 NOTREACHED() << "Root item became unsynced " << entry; |
| 156 return false; | 157 return false; |
| 157 } | 158 } |
| 158 | 159 |
| 159 if (entry.IsRoot()) { | 160 if (entry.IsRoot()) { |
| 160 NOTREACHED() << "Permanent item became unsynced " << entry; | 161 NOTREACHED() << "Permanent item became unsynced " << entry; |
| 161 return false; | 162 return false; |
| 162 } | 163 } |
| 163 | 164 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 184 const std::vector<int64_t>& deleted_conflicted_items, | 185 const std::vector<int64_t>& deleted_conflicted_items, |
| 185 std::set<int64_t>* ready_unsynced_set) { | 186 std::set<int64_t>* ready_unsynced_set) { |
| 186 for (auto iter = deleted_conflicted_items.begin(); | 187 for (auto iter = deleted_conflicted_items.begin(); |
| 187 iter != deleted_conflicted_items.end(); ++iter) { | 188 iter != deleted_conflicted_items.end(); ++iter) { |
| 188 syncable::Entry item(trans, syncable::GET_BY_HANDLE, *iter); | 189 syncable::Entry item(trans, syncable::GET_BY_HANDLE, *iter); |
| 189 syncable::Id parent_id = item.GetParentId(); | 190 syncable::Id parent_id = item.GetParentId(); |
| 190 DCHECK(!parent_id.IsNull()); | 191 DCHECK(!parent_id.IsNull()); |
| 191 | 192 |
| 192 while (!parent_id.IsRoot()) { | 193 while (!parent_id.IsRoot()) { |
| 193 syncable::Entry parent(trans, syncable::GET_BY_ID, parent_id); | 194 syncable::Entry parent(trans, syncable::GET_BY_ID, parent_id); |
| 194 CHECK(parent.good()) << "Bad user-only parent in item path."; | 195 // Bad user-only parent in item path. |
| 196 CHECK(parent.good()); |
| 195 int64_t handle = parent.GetMetahandle(); | 197 int64_t handle = parent.GetMetahandle(); |
| 196 | 198 |
| 197 if (!parent.GetIsDel()) | 199 if (!parent.GetIsDel()) |
| 198 break; | 200 break; |
| 199 | 201 |
| 200 auto ready_iter = ready_unsynced_set->find(handle); | 202 auto ready_iter = ready_unsynced_set->find(handle); |
| 201 if (ready_iter == ready_unsynced_set->end()) | 203 if (ready_iter == ready_unsynced_set->end()) |
| 202 break; | 204 break; |
| 203 | 205 |
| 204 // Remove this entry from |ready_unsynced_set|. | 206 // Remove this entry from |ready_unsynced_set|. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 const std::set<int64_t>& ready_unsynced_set, | 361 const std::set<int64_t>& ready_unsynced_set, |
| 360 const syncable::Entry& item, | 362 const syncable::Entry& item, |
| 361 syncable::Directory::Metahandles* result) const { | 363 syncable::Directory::Metahandles* result) const { |
| 362 DCHECK(SupportsHierarchy(item)); | 364 DCHECK(SupportsHierarchy(item)); |
| 363 syncable::Directory::Metahandles dependencies; | 365 syncable::Directory::Metahandles dependencies; |
| 364 syncable::Id parent_id = item.GetParentId(); | 366 syncable::Id parent_id = item.GetParentId(); |
| 365 | 367 |
| 366 // Climb the tree adding entries leaf -> root. | 368 // Climb the tree adding entries leaf -> root. |
| 367 while (!parent_id.ServerKnows()) { | 369 while (!parent_id.ServerKnows()) { |
| 368 syncable::Entry parent(trans_, syncable::GET_BY_ID, parent_id); | 370 syncable::Entry parent(trans_, syncable::GET_BY_ID, parent_id); |
| 369 CHECK(parent.good()) << "Bad user-only parent in item path."; | 371 // Bad user-only parent in item path. |
| 372 CHECK(parent.good()); |
| 370 int64_t handle = parent.GetMetahandle(); | 373 int64_t handle = parent.GetMetahandle(); |
| 371 if (HaveItem(handle)) { | 374 if (HaveItem(handle)) { |
| 372 // We've already added this parent (and therefore all of its parents). | 375 // We've already added this parent (and therefore all of its parents). |
| 373 // We can return early. | 376 // We can return early. |
| 374 break; | 377 break; |
| 375 } | 378 } |
| 376 | 379 |
| 377 if (!TryAddItem(ready_unsynced_set, parent, &dependencies)) { | 380 if (!TryAddItem(ready_unsynced_set, parent, &dependencies)) { |
| 378 // The parent isn't in |ready_unsynced_set|. | 381 // The parent isn't in |ready_unsynced_set|. |
| 379 break; | 382 break; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // Add moves and creates, and prepend their uncommitted parents. | 570 // Add moves and creates, and prepend their uncommitted parents. |
| 568 traversal.AddCreatesAndMoves(ready_unsynced_set); | 571 traversal.AddCreatesAndMoves(ready_unsynced_set); |
| 569 | 572 |
| 570 // Add all deletes. | 573 // Add all deletes. |
| 571 traversal.AddDeletes(ready_unsynced_set); | 574 traversal.AddDeletes(ready_unsynced_set); |
| 572 } | 575 } |
| 573 | 576 |
| 574 } // namespace | 577 } // namespace |
| 575 | 578 |
| 576 } // namespace syncer | 579 } // namespace syncer |
| OLD | NEW |