Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Unified Diff: components/sync/test/engine/mock_model_type_processor.cc

Issue 2611123005: [Sync] ModelTypeWorker should delete tracker for entity deleted on the server (Closed)
Patch Set: Address comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/test/engine/mock_model_type_processor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/test/engine/mock_model_type_processor.cc
diff --git a/components/sync/test/engine/mock_model_type_processor.cc b/components/sync/test/engine/mock_model_type_processor.cc
index 878497ef30335b4b599d34160e3daeca2e15fa3d..1e88c1944bf49590b4616de04f078411a06917b1 100644
--- a/components/sync/test/engine/mock_model_type_processor.cc
+++ b/components/sync/test/engine/mock_model_type_processor.cc
@@ -118,6 +118,8 @@ CommitRequestData MockModelTypeProcessor::DeleteRequest(
request_data.sequence_number = GetNextSequenceNumber(tag_hash);
request_data.base_version = base_version;
+ pending_deleted_hashes_.insert(tag_hash);
+
return request_data;
}
@@ -195,11 +197,22 @@ void MockModelTypeProcessor::OnCommitCompletedImpl(
type_states_received_on_commit_.push_back(type_state);
for (CommitResponseDataList::const_iterator it = response_list.begin();
it != response_list.end(); ++it) {
- commit_response_items_.insert(std::make_pair(it->client_tag_hash, *it));
-
- // Server wins. Set the model's base version.
- SetBaseVersion(it->client_tag_hash, it->response_version);
- SetServerAssignedId(it->client_tag_hash, it->id);
+ const std::string tag_hash = it->client_tag_hash;
+ commit_response_items_.insert(std::make_pair(tag_hash, *it));
+
+ if (pending_deleted_hashes_.find(tag_hash) !=
+ pending_deleted_hashes_.end()) {
+ // Delete request was committed on the server. Erase information we track
+ // about the entity.
+ sequence_numbers_.erase(tag_hash);
+ base_versions_.erase(tag_hash);
+ assigned_ids_.erase(tag_hash);
+ pending_deleted_hashes_.erase(tag_hash);
+ } else {
+ // Server wins. Set the model's base version.
+ SetBaseVersion(tag_hash, it->response_version);
+ SetServerAssignedId(tag_hash, it->id);
+ }
}
}
« no previous file with comments | « components/sync/test/engine/mock_model_type_processor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698