| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/get_commit_ids_command.h" | 5 #include "sync/engine/get_commit_ids_command.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 if (commit_set_->HaveCommitItem(item_handle)) { | 241 if (commit_set_->HaveCommitItem(item_handle)) { |
| 242 // We've already added this item to the commit set, and so must have | 242 // We've already added this item to the commit set, and so must have |
| 243 // already added the predecessors as well. | 243 // already added the predecessors as well. |
| 244 return true; | 244 return true; |
| 245 } | 245 } |
| 246 if (!AddItem(ready_unsynced_set, item, result)) | 246 if (!AddItem(ready_unsynced_set, item, result)) |
| 247 return false; // Item is in conflict. | 247 return false; // Item is in conflict. |
| 248 if (item.Get(syncable::IS_DEL)) | 248 if (item.Get(syncable::IS_DEL)) |
| 249 return true; // Deleted items have no predecessors. | 249 return true; // Deleted items have no predecessors. |
| 250 | 250 |
| 251 syncable::Id prev_id = item.Get(syncable::PREV_ID); | 251 syncable::Id prev_id = item.GetPredecessorId(); |
| 252 while (!prev_id.IsRoot()) { | 252 while (!prev_id.IsRoot()) { |
| 253 syncable::Entry prev(trans, syncable::GET_BY_ID, prev_id); | 253 syncable::Entry prev(trans, syncable::GET_BY_ID, prev_id); |
| 254 CHECK(prev.good()) << "Bad id when walking predecessors."; | 254 CHECK(prev.good()) << "Bad id when walking predecessors."; |
| 255 if (!prev.Get(syncable::IS_UNSYNCED)) | 255 if (!prev.Get(syncable::IS_UNSYNCED)) |
| 256 break; | 256 break; |
| 257 int64 handle = prev.Get(syncable::META_HANDLE); | 257 int64 handle = prev.Get(syncable::META_HANDLE); |
| 258 if (commit_set_->HaveCommitItem(handle)) { | 258 if (commit_set_->HaveCommitItem(handle)) { |
| 259 // We've already added this item to the commit set, and so must have | 259 // We've already added this item to the commit set, and so must have |
| 260 // already added the predecessors as well. | 260 // already added the predecessors as well. |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| 263 if (!AddItem(ready_unsynced_set, prev, result)) | 263 if (!AddItem(ready_unsynced_set, prev, result)) |
| 264 return false; // Item is in conflict. | 264 return false; // Item is in conflict. |
| 265 prev_id = prev.Get(syncable::PREV_ID); | 265 prev_id = prev.GetPredecessorId(); |
| 266 } | 266 } |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| 269 | 269 |
| 270 bool GetCommitIdsCommand::AddPredecessorsThenItem( | 270 bool GetCommitIdsCommand::AddPredecessorsThenItem( |
| 271 syncable::BaseTransaction* trans, | 271 syncable::BaseTransaction* trans, |
| 272 const ModelSafeRoutingInfo& routes, | 272 const ModelSafeRoutingInfo& routes, |
| 273 const std::set<int64>& ready_unsynced_set, | 273 const std::set<int64>& ready_unsynced_set, |
| 274 const syncable::Entry& item, | 274 const syncable::Entry& item, |
| 275 OrderedCommitSet* result) const { | 275 OrderedCommitSet* result) const { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // delete trees. | 428 // delete trees. |
| 429 | 429 |
| 430 // Add moves and creates, and prepend their uncommitted parents. | 430 // Add moves and creates, and prepend their uncommitted parents. |
| 431 AddCreatesAndMoves(write_transaction, routes, ready_unsynced_set); | 431 AddCreatesAndMoves(write_transaction, routes, ready_unsynced_set); |
| 432 | 432 |
| 433 // Add all deletes. | 433 // Add all deletes. |
| 434 AddDeletes(write_transaction, ready_unsynced_set); | 434 AddDeletes(write_transaction, ready_unsynced_set); |
| 435 } | 435 } |
| 436 | 436 |
| 437 } // namespace syncer | 437 } // namespace syncer |
| OLD | NEW |