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

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: 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/processor_entity_tracker.cc
diff --git a/sync/internal_api/processor_entity_tracker.cc b/sync/internal_api/processor_entity_tracker.cc
index 67853791c18af7f7ba1424c0ac11a499d52269a9..acf18c7c42026bbf143f67a257ffa40a42f4e3c0 100644
--- a/sync/internal_api/processor_entity_tracker.cc
+++ b/sync/internal_api/processor_entity_tracker.cc
@@ -15,6 +15,17 @@
namespace syncer_v2 {
+namespace {
+
+void HashSpecifics(const sync_pb::EntitySpecifics& specifics,
+ std::string* hash) {
+ std::string hash_input;
+ specifics.AppendToString(&hash_input);
skym 2016/03/28 22:35:38 Why not use SerializeAsString() inline?
maxbogue 2016/03/29 00:32:09 Because I was just copying from UpdateSpecificsHas
+ base::Base64Encode(base::SHA1HashString(hash_input), hash);
+}
+
+} // namespace
+
scoped_ptr<ProcessorEntityTracker> ProcessorEntityTracker::CreateNew(
const std::string& client_tag,
const std::string& client_tag_hash,
@@ -66,6 +77,17 @@ bool ProcessorEntityTracker::HasCommitData() const {
return !commit_data_->client_tag_hash.empty();
}
+bool ProcessorEntityTracker::MatchesSpecificsHash(
+ const sync_pb::EntitySpecifics& specifics) const {
+ if (specifics.ByteSize() > 0) {
+ std::string hash;
+ HashSpecifics(specifics, &hash);
+ return hash == metadata_.specifics_hash();
+ } else {
+ return !metadata_.has_specifics_hash();
skym 2016/03/28 22:35:38 What's the reason for this special logic? We don't
maxbogue 2016/03/29 00:32:09 Hmm... doesn't seem very important. It should be f
maxbogue 2016/03/29 01:02:05 Update: not below, apparently the logic doesn't re
+ }
+}
+
bool ProcessorEntityTracker::IsUnsynced() const {
return metadata_.sequence_number() > metadata_.acked_sequence_number();
}
@@ -203,10 +225,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') | sync/internal_api/shared_model_type_processor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698