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 "sync/engine/get_commit_ids.h" | 5 #include "sync/engine/get_commit_ids.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 if (HaveItem(item_handle)) { | 342 if (HaveItem(item_handle)) { |
343 // We've already added this item to the commit set, and so must have | 343 // We've already added this item to the commit set, and so must have |
344 // already added the predecessors as well. | 344 // already added the predecessors as well. |
345 return; | 345 return; |
346 } | 346 } |
347 TryAddItem(ready_unsynced_set, item, result); | 347 TryAddItem(ready_unsynced_set, item, result); |
348 if (item.GetIsDel()) | 348 if (item.GetIsDel()) |
349 return; // Deleted items have no predecessors. | 349 return; // Deleted items have no predecessors. |
350 | 350 |
351 syncable::Id prev_id = item.GetPredecessorId(); | 351 syncable::Id prev_id = item.GetPredecessorId(); |
352 while (!prev_id.IsRoot()) { | 352 while (!prev_id.IsNull()) { |
353 syncable::Entry prev(trans_, syncable::GET_BY_ID, prev_id); | 353 syncable::Entry prev(trans_, syncable::GET_BY_ID, prev_id); |
354 CHECK(prev.good()) << "Bad id when walking predecessors."; | 354 CHECK(prev.good()) << "Bad id when walking predecessors."; |
355 if (!prev.GetIsUnsynced()) { | 355 if (!prev.GetIsUnsynced()) { |
356 // We're interested in "runs" of unsynced items. This item breaks | 356 // We're interested in "runs" of unsynced items. This item breaks |
357 // the streak, so we stop traversing. | 357 // the streak, so we stop traversing. |
358 return; | 358 return; |
359 } | 359 } |
360 int64 handle = prev.GetMetahandle(); | 360 int64 handle = prev.GetMetahandle(); |
361 if (HaveItem(handle)) { | 361 if (HaveItem(handle)) { |
362 // We've already added this item to the commit set, and so must have | 362 // We've already added this item to the commit set, and so must have |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 // Add moves and creates, and prepend their uncommitted parents. | 557 // Add moves and creates, and prepend their uncommitted parents. |
558 traversal.AddCreatesAndMoves(ready_unsynced_set); | 558 traversal.AddCreatesAndMoves(ready_unsynced_set); |
559 | 559 |
560 // Add all deletes. | 560 // Add all deletes. |
561 traversal.AddDeletes(ready_unsynced_set); | 561 traversal.AddDeletes(ready_unsynced_set); |
562 } | 562 } |
563 | 563 |
564 } // namespace | 564 } // namespace |
565 | 565 |
566 } // namespace syncer | 566 } // namespace syncer |
OLD | NEW |