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

Unified Diff: sync/internal_api/shared_model_type_processor.cc

Issue 1835953002: [Sync] USS: Filter out redundant changes in SMTP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo UpdateSpecificsHash change and add DCHECK. Created 4 years, 9 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
Index: sync/internal_api/shared_model_type_processor.cc
diff --git a/sync/internal_api/shared_model_type_processor.cc b/sync/internal_api/shared_model_type_processor.cc
index c963a3c7a4d8e3471d58b9f8e18390e41eb4ead0..882f37e9fbc038d71c42c4d42a058cd81ecbb3d7 100644
--- a/sync/internal_api/shared_model_type_processor.cc
+++ b/sync/internal_api/shared_model_type_processor.cc
@@ -241,10 +241,11 @@ void SharedModelTypeProcessor::Put(const std::string& tag,
data->creation_time = data->modification_time;
}
entity = CreateEntity(tag, *data);
+ } else if (entity->MatchesSpecificsHash(data->specifics)) {
+ // Ignore changes that don't actually change anything.
+ return;
}
- // TODO(stanisc): crbug.com/561829: Avoid committing a change if there is no
- // actual change.
entity->MakeLocalChange(std::move(data));
metadata_change_list->UpdateMetadata(tag, entity->metadata());
@@ -373,16 +374,16 @@ void SharedModelTypeProcessor::OnUpdateReceived(
entity = CreateEntity(data);
entity_changes.push_back(
EntityChange::CreateAdd(entity->client_tag(), update.entity));
- } else {
- if (data.is_deleted()) {
- entity_changes.push_back(
- EntityChange::CreateDelete(entity->client_tag()));
- } else {
- // TODO(stanisc): crbug.com/561829: Avoid sending an update to the
- // service if there is no actual change.
- entity_changes.push_back(
- EntityChange::CreateUpdate(entity->client_tag(), update.entity));
- }
+ } else if (entity->UpdateIsReflection(update.response_version)) {
+ // Seen this update before; just ignore it.
+ continue;
+ } else if (data.is_deleted()) {
+ entity_changes.push_back(
+ EntityChange::CreateDelete(entity->client_tag()));
+ } else if (!entity->MatchesSpecificsHash(data.specifics)) {
+ // Specifics have changed, so update the service.
+ entity_changes.push_back(
+ EntityChange::CreateUpdate(entity->client_tag(), update.entity));
}
entity->ApplyUpdateFromServer(update);
« no previous file with comments | « sync/internal_api/public/processor_entity_tracker.h ('k') | sync/internal_api/shared_model_type_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698