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

Unified Diff: sync/engine/conflict_resolver.cc

Issue 393083004: Update Commit and GetUpdatesResponse messages to include attachment ids. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update SyncManagerImpl to detect attachment metadata changes. Created 6 years, 5 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 | « sync/engine/commit_util.cc ('k') | sync/engine/directory_commit_contribution_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/conflict_resolver.cc
diff --git a/sync/engine/conflict_resolver.cc b/sync/engine/conflict_resolver.cc
index 163062032e6e03dc9f7e76238076a88a5bd000bc..f914403a276fd585bfde873fa45c194213af53f1 100644
--- a/sync/engine/conflict_resolver.cc
+++ b/sync/engine/conflict_resolver.cc
@@ -30,6 +30,39 @@ using syncable::Id;
using syncable::MutableEntry;
using syncable::WriteTransaction;
+namespace {
+
+// Returns true iff the set of attachment ids contained in attachment_metadata
+// matches the set of ids contained in server_attachment_metadata.
+bool AttachmentMetadataMatches(const MutableEntry& entity) {
+ const sync_pb::AttachmentMetadata& local = entity.GetAttachmentMetadata();
+ const sync_pb::AttachmentMetadata& server =
+ entity.GetServerAttachmentMetadata();
+ if (local.record_size() != server.record_size()) {
+ return false;
+ }
+
+ // The order of records in local and server may be different so use a std::set
+ // to determine if they are equivalent.
+ std::set<std::string> local_ids;
+ for (int i = 0; i < local.record_size(); ++i) {
+ const sync_pb::AttachmentMetadataRecord& record = local.record(i);
+ DCHECK(record.is_on_server());
+ local_ids.insert(record.id().SerializeAsString());
+ }
+ for (int i = 0; i < server.record_size(); ++i) {
+ const sync_pb::AttachmentMetadataRecord& record = server.record(i);
+ DCHECK(record.is_on_server());
+ if (local_ids.find(record.id().SerializeAsString()) == local_ids.end()) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+} // namespace
+
ConflictResolver::ConflictResolver() {
}
@@ -148,8 +181,9 @@ void ConflictResolver::ProcessSimpleConflict(WriteTransaction* trans,
base_server_specifics_match = true;
}
+ bool attachment_metadata_matches = AttachmentMetadataMatches(entry);
if (!entry_deleted && name_matches && parent_matches && specifics_match &&
- position_matches) {
+ position_matches && attachment_metadata_matches) {
DVLOG(1) << "Resolving simple conflict, everything matches, ignoring "
<< "changes for: " << entry;
conflict_util::IgnoreConflict(&entry);
« no previous file with comments | « sync/engine/commit_util.cc ('k') | sync/engine/directory_commit_contribution_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698