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

Unified Diff: sync/internal_api/processor_entity_tracker.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
« no previous file with comments | « no previous file | sync/internal_api/public/processor_entity_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/processor_entity_tracker.cc
diff --git a/sync/internal_api/processor_entity_tracker.cc b/sync/internal_api/processor_entity_tracker.cc
index 67853791c18af7f7ba1424c0ac11a499d52269a9..faa3d4632b3fc0da30f093e0dcfd8e2f196916d4 100644
--- a/sync/internal_api/processor_entity_tracker.cc
+++ b/sync/internal_api/processor_entity_tracker.cc
@@ -15,6 +15,15 @@
namespace syncer_v2 {
+namespace {
+
+void HashSpecifics(const sync_pb::EntitySpecifics& specifics,
+ std::string* hash) {
+ base::Base64Encode(base::SHA1HashString(specifics.SerializeAsString()), hash);
+}
+
+} // namespace
+
scoped_ptr<ProcessorEntityTracker> ProcessorEntityTracker::CreateNew(
const std::string& client_tag,
const std::string& client_tag_hash,
@@ -66,6 +75,14 @@ bool ProcessorEntityTracker::HasCommitData() const {
return !commit_data_->client_tag_hash.empty();
}
+bool ProcessorEntityTracker::MatchesSpecificsHash(
+ const sync_pb::EntitySpecifics& specifics) const {
+ DCHECK(specifics.ByteSize() > 0);
+ std::string hash;
+ HashSpecifics(specifics, &hash);
+ return hash == metadata_.specifics_hash();
+}
+
bool ProcessorEntityTracker::IsUnsynced() const {
return metadata_.sequence_number() > metadata_.acked_sequence_number();
}
@@ -96,9 +113,6 @@ void ProcessorEntityTracker::ApplyUpdateFromServer(
DCHECK(!metadata_.client_tag_hash().empty());
DCHECK(metadata_.has_sequence_number());
- // TODO(stanisc): crbug/561829: Filter out update if specifics hash hasn't
- // changed.
-
// TODO(stanisc): crbug/521867: Understand and verify the conflict resolution
// logic here.
// There was a conflict and the server just won it.
@@ -203,10 +217,7 @@ void ProcessorEntityTracker::IncrementSequenceNumber() {
void ProcessorEntityTracker::UpdateSpecificsHash(
const sync_pb::EntitySpecifics& specifics) {
if (specifics.ByteSize() > 0) {
- std::string hash_input;
- specifics.AppendToString(&hash_input);
- base::Base64Encode(base::SHA1HashString(hash_input),
- metadata_.mutable_specifics_hash());
+ HashSpecifics(specifics, metadata_.mutable_specifics_hash());
} else {
metadata_.clear_specifics_hash();
}
« no previous file with comments | « no previous file | sync/internal_api/public/processor_entity_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698