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

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: Use data var. 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..563316525529440af9c2d36b6088d2ab83a1d474 100644
--- a/sync/internal_api/shared_model_type_processor.cc
+++ b/sync/internal_api/shared_model_type_processor.cc
@@ -243,8 +243,11 @@ void SharedModelTypeProcessor::Put(const std::string& tag,
entity = CreateEntity(tag, *data);
}
- // TODO(stanisc): crbug.com/561829: Avoid committing a change if there is no
- // actual change.
+ if (entity->MatchesSpecificsHash(data->specifics)) {
skym 2016/03/28 22:35:38 Should we even bother making this check if entity
maxbogue 2016/03/29 00:32:09 Guess not. Done.
+ // Ignore changes that don't actually change anything.
+ return;
+ }
+
entity->MakeLocalChange(std::move(data));
metadata_change_list->UpdateMetadata(tag, entity->metadata());
@@ -373,16 +376,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);

Powered by Google App Engine
This is Rietveld 408576698