Chromium Code Reviews| Index: sync/engine/get_commit_ids_command.cc |
| diff --git a/sync/engine/get_commit_ids_command.cc b/sync/engine/get_commit_ids_command.cc |
| index 55d7e232b12941228f9e9108bdae0f58148da53e..5e0eb7f394ef3d15cd4176bd07387ad446dfb7c0 100644 |
| --- a/sync/engine/get_commit_ids_command.cc |
| +++ b/sync/engine/get_commit_ids_command.cc |
| @@ -22,8 +22,14 @@ using sessions::OrderedCommitSet; |
| using sessions::SyncSession; |
| using sessions::StatusController; |
| -GetCommitIdsCommand::GetCommitIdsCommand(int commit_batch_size) |
| - : requested_commit_batch_size_(commit_batch_size) {} |
| +GetCommitIdsCommand::GetCommitIdsCommand( |
| + size_t commit_batch_size, |
| + sessions::OrderedCommitSet* commit_set, |
| + size_t* unsynced_item_count) |
| + : requested_commit_batch_size_(commit_batch_size), |
|
tim (not reviewing)
2012/05/11 18:42:16
indent of : is off.
rlarocque
2012/05/14 23:10:43
Done.
|
| + commit_set_(commit_set), |
| + unsynced_item_count_(unsynced_item_count) { |
| +} |
| GetCommitIdsCommand::~GetCommitIdsCommand() {} |
| @@ -57,21 +63,18 @@ SyncerError GetCommitIdsCommand::ExecuteImpl(SyncSession* session) { |
| all_unsynced_handles, |
| &ready_unsynced_set); |
| + *unsynced_item_count_ = ready_unsynced_set.size(); |
| + |
| BuildCommitIds(session->write_transaction(), |
| session->routing_info(), |
| ready_unsynced_set); |
| - StatusController* status = session->mutable_status_controller(); |
| - syncable::Directory::UnsyncedMetaHandles ready_unsynced_vector( |
| - ready_unsynced_set.begin(), ready_unsynced_set.end()); |
| - status->set_unsynced_handles(ready_unsynced_vector); |
| const vector<syncable::Id>& verified_commit_ids = |
| - ordered_commit_set_->GetAllCommitIds(); |
| + commit_set_->GetAllCommitIds(); |
| for (size_t i = 0; i < verified_commit_ids.size(); i++) |
| DVLOG(1) << "Debug commit batch result:" << verified_commit_ids[i]; |
| - status->set_commit_set(*ordered_commit_set_.get()); |
| return SYNCER_OK; |
| } |
| @@ -188,7 +191,7 @@ bool GetCommitIdsCommand::AddUncommittedParentsAndTheirPredecessors( |
| syncable::Entry parent(trans, syncable::GET_BY_ID, parent_id); |
| CHECK(parent.good()) << "Bad user-only parent in item path."; |
| int64 handle = parent.Get(syncable::META_HANDLE); |
| - if (ordered_commit_set_->HaveCommitItem(handle)) { |
| + if (commit_set_->HaveCommitItem(handle)) { |
| // We've already added this parent (and therefore all of its parents). |
| // We can return early. |
| break; |
| @@ -196,7 +199,7 @@ bool GetCommitIdsCommand::AddUncommittedParentsAndTheirPredecessors( |
| if (!AddItemThenPredecessors(trans, ready_unsynced_set, parent, |
| &item_dependencies)) { |
| // There was a parent/predecessor in conflict. We return without adding |
| - // anything to |ordered_commit_set_|. |
| + // anything to |commit_set|. |
| DVLOG(1) << "Parent or parent's predecessor was in conflict, omitting " |
| << item; |
| return false; |
| @@ -234,7 +237,7 @@ bool GetCommitIdsCommand::AddItemThenPredecessors( |
| const syncable::Entry& item, |
| OrderedCommitSet* result) const { |
| int64 item_handle = item.Get(syncable::META_HANDLE); |
| - if (ordered_commit_set_->HaveCommitItem(item_handle)) { |
| + if (commit_set_->HaveCommitItem(item_handle)) { |
| // We've already added this item to the commit set, and so must have |
| // already added the predecessors as well. |
| return true; |
| @@ -251,7 +254,7 @@ bool GetCommitIdsCommand::AddItemThenPredecessors( |
| if (!prev.Get(syncable::IS_UNSYNCED)) |
| break; |
| int64 handle = prev.Get(syncable::META_HANDLE); |
| - if (ordered_commit_set_->HaveCommitItem(handle)) { |
| + if (commit_set_->HaveCommitItem(handle)) { |
| // We've already added this item to the commit set, and so must have |
| // already added the predecessors as well. |
| return true; |
| @@ -284,7 +287,7 @@ bool GetCommitIdsCommand::AddPredecessorsThenItem( |
| } |
| bool GetCommitIdsCommand::IsCommitBatchFull() const { |
| - return ordered_commit_set_->Size() >= requested_commit_batch_size_; |
| + return commit_set_->Size() >= requested_commit_batch_size_; |
| } |
| void GetCommitIdsCommand::AddCreatesAndMoves( |
| @@ -295,7 +298,7 @@ void GetCommitIdsCommand::AddCreatesAndMoves( |
| for (std::set<int64>::const_iterator iter = ready_unsynced_set.begin(); |
| !IsCommitBatchFull() && iter != ready_unsynced_set.end(); ++iter) { |
| int64 metahandle = *iter; |
| - if (ordered_commit_set_->HaveCommitItem(metahandle)) |
| + if (commit_set_->HaveCommitItem(metahandle)) |
| continue; |
| syncable::Entry entry(write_transaction, |
| @@ -316,14 +319,14 @@ void GetCommitIdsCommand::AddCreatesAndMoves( |
| ready_unsynced_set, |
| entry, |
| &item_dependencies)) { |
| - ordered_commit_set_->Append(item_dependencies); |
| + commit_set_->Append(item_dependencies); |
| } |
| } |
| } |
| // It's possible that we overcommitted while trying to expand dependent |
| // items. If so, truncate the set down to the allowed size. |
| - ordered_commit_set_->Truncate(requested_commit_batch_size_); |
| + commit_set_->Truncate(requested_commit_batch_size_); |
| } |
| void GetCommitIdsCommand::AddDeletes( |
| @@ -334,7 +337,7 @@ void GetCommitIdsCommand::AddDeletes( |
| for (std::set<int64>::const_iterator iter = ready_unsynced_set.begin(); |
| !IsCommitBatchFull() && iter != ready_unsynced_set.end(); ++iter) { |
| int64 metahandle = *iter; |
| - if (ordered_commit_set_->HaveCommitItem(metahandle)) |
| + if (commit_set_->HaveCommitItem(metahandle)) |
| continue; |
| syncable::Entry entry(write_transaction, syncable::GET_BY_HANDLE, |
| @@ -365,7 +368,7 @@ void GetCommitIdsCommand::AddDeletes( |
| DVLOG(1) << "Inserting moved and deleted entry, will be missed by " |
| << "delete roll." << entry.Get(syncable::ID); |
| - ordered_commit_set_->AddCommitItem(metahandle, |
| + commit_set_->AddCommitItem(metahandle, |
| entry.Get(syncable::ID), |
| entry.GetModelType()); |
| } |
| @@ -396,14 +399,14 @@ void GetCommitIdsCommand::AddDeletes( |
| for (std::set<int64>::const_iterator iter = ready_unsynced_set.begin(); |
| !IsCommitBatchFull() && iter != ready_unsynced_set.end(); ++iter) { |
| int64 metahandle = *iter; |
| - if (ordered_commit_set_->HaveCommitItem(metahandle)) |
| + if (commit_set_->HaveCommitItem(metahandle)) |
| continue; |
| syncable::MutableEntry entry(write_transaction, syncable::GET_BY_HANDLE, |
| metahandle); |
| if (entry.Get(syncable::IS_DEL)) { |
| syncable::Id parent_id = entry.Get(syncable::PARENT_ID); |
| if (legal_delete_parents.count(parent_id)) { |
| - ordered_commit_set_->AddCommitItem(metahandle, entry.Get(syncable::ID), |
| + commit_set_->AddCommitItem(metahandle, entry.Get(syncable::ID), |
| entry.GetModelType()); |
| } |
| } |
| @@ -414,7 +417,6 @@ void GetCommitIdsCommand::BuildCommitIds( |
| syncable::WriteTransaction* write_transaction, |
| const ModelSafeRoutingInfo& routes, |
| const std::set<int64>& ready_unsynced_set) { |
| - ordered_commit_set_.reset(new OrderedCommitSet(routes)); |
| // Commits follow these rules: |
| // 1. Moves or creates are preceded by needed folder creates, from |
| // root to leaf. For folders whose contents are ordered, moves |