OLD | NEW |
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/engine/syncer_util.h" | 5 #include "sync/engine/syncer_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 using syncable::IS_DIR; | 49 using syncable::IS_DIR; |
50 using syncable::IS_UNAPPLIED_UPDATE; | 50 using syncable::IS_UNAPPLIED_UPDATE; |
51 using syncable::IS_UNSYNCED; | 51 using syncable::IS_UNSYNCED; |
52 using syncable::Id; | 52 using syncable::Id; |
53 using syncable::META_HANDLE; | 53 using syncable::META_HANDLE; |
54 using syncable::MTIME; | 54 using syncable::MTIME; |
55 using syncable::MutableEntry; | 55 using syncable::MutableEntry; |
56 using syncable::NON_UNIQUE_NAME; | 56 using syncable::NON_UNIQUE_NAME; |
57 using syncable::BASE_SERVER_SPECIFICS; | 57 using syncable::BASE_SERVER_SPECIFICS; |
58 using syncable::PARENT_ID; | 58 using syncable::PARENT_ID; |
59 using syncable::PREV_ID; | |
60 using syncable::SERVER_CTIME; | 59 using syncable::SERVER_CTIME; |
61 using syncable::SERVER_IS_DEL; | 60 using syncable::SERVER_IS_DEL; |
62 using syncable::SERVER_IS_DIR; | 61 using syncable::SERVER_IS_DIR; |
63 using syncable::SERVER_MTIME; | 62 using syncable::SERVER_MTIME; |
64 using syncable::SERVER_NON_UNIQUE_NAME; | 63 using syncable::SERVER_NON_UNIQUE_NAME; |
65 using syncable::SERVER_PARENT_ID; | 64 using syncable::SERVER_PARENT_ID; |
66 using syncable::SERVER_ORDINAL_IN_PARENT; | 65 using syncable::SERVER_ORDINAL_IN_PARENT; |
67 using syncable::SERVER_SPECIFICS; | 66 using syncable::SERVER_SPECIFICS; |
68 using syncable::SERVER_VERSION; | 67 using syncable::SERVER_VERSION; |
69 using syncable::UNIQUE_CLIENT_TAG; | 68 using syncable::UNIQUE_CLIENT_TAG; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 syncable::IndexedBitField inclusion_filter, | 454 syncable::IndexedBitField inclusion_filter, |
456 syncable::MetahandleSet* inserted_items, | 455 syncable::MetahandleSet* inserted_items, |
457 std::vector<syncable::Id>* commit_ids) { | 456 std::vector<syncable::Id>* commit_ids) { |
458 | 457 |
459 if (!inserted_items->insert(item->Get(META_HANDLE)).second) | 458 if (!inserted_items->insert(item->Get(META_HANDLE)).second) |
460 return false; | 459 return false; |
461 commit_ids->push_back(item->Get(ID)); | 460 commit_ids->push_back(item->Get(ID)); |
462 if (item->Get(IS_DEL)) | 461 if (item->Get(IS_DEL)) |
463 return true; // Deleted items have no predecessors. | 462 return true; // Deleted items have no predecessors. |
464 | 463 |
465 Id prev_id = item->Get(PREV_ID); | 464 Id prev_id = item->GetPredecessorId(); |
466 while (!prev_id.IsRoot()) { | 465 while (!prev_id.IsRoot()) { |
467 Entry prev(trans, GET_BY_ID, prev_id); | 466 Entry prev(trans, GET_BY_ID, prev_id); |
468 CHECK(prev.good()) << "Bad id when walking predecessors."; | 467 CHECK(prev.good()) << "Bad id when walking predecessors."; |
469 if (!prev.Get(inclusion_filter)) | 468 if (!prev.Get(inclusion_filter)) |
470 break; | 469 break; |
471 if (!inserted_items->insert(prev.Get(META_HANDLE)).second) | 470 if (!inserted_items->insert(prev.Get(META_HANDLE)).second) |
472 break; | 471 break; |
473 commit_ids->push_back(prev_id); | 472 commit_ids->push_back(prev_id); |
474 prev_id = prev.Get(PREV_ID); | 473 prev_id = prev.GetPredecessorId(); |
475 } | 474 } |
476 return true; | 475 return true; |
477 } | 476 } |
478 | 477 |
479 void AddPredecessorsThenItem( | 478 void AddPredecessorsThenItem( |
480 syncable::BaseTransaction* trans, | 479 syncable::BaseTransaction* trans, |
481 syncable::Entry* item, | 480 syncable::Entry* item, |
482 syncable::IndexedBitField inclusion_filter, | 481 syncable::IndexedBitField inclusion_filter, |
483 syncable::MetahandleSet* inserted_items, | 482 syncable::MetahandleSet* inserted_items, |
484 std::vector<syncable::Id>* commit_ids) { | 483 std::vector<syncable::Id>* commit_ids) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 if (update.version() < target->Get(SERVER_VERSION)) { | 650 if (update.version() < target->Get(SERVER_VERSION)) { |
652 LOG(WARNING) << "Update older than current server version for " | 651 LOG(WARNING) << "Update older than current server version for " |
653 << *target << " Update:" | 652 << *target << " Update:" |
654 << SyncerProtoUtil::SyncEntityDebugString(update); | 653 << SyncerProtoUtil::SyncEntityDebugString(update); |
655 return VERIFY_SUCCESS; // Expected in new sync protocol. | 654 return VERIFY_SUCCESS; // Expected in new sync protocol. |
656 } | 655 } |
657 return VERIFY_UNDECIDED; | 656 return VERIFY_UNDECIDED; |
658 } | 657 } |
659 | 658 |
660 } // namespace syncer | 659 } // namespace syncer |
OLD | NEW |