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

Side by Side Diff: sync/engine/conflict_resolver.cc

Issue 1664643003: Change sync conflict resolution for extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit test changes, added integration test Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/engine/conflict_resolver.h" 5 #include "sync/engine/conflict_resolver.h"
6 6
7 #include <list> 7 #include <list>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // d) If the server_specifics match specifics, server_specifics are 109 // d) If the server_specifics match specifics, server_specifics are
110 // encrypted with the default key, and all other visible properties match, 110 // encrypted with the default key, and all other visible properties match,
111 // then we can safely ignore the local changes as redundant. 111 // then we can safely ignore the local changes as redundant.
112 // e) Otherwise if the base_server_specifics match the server_specifics, no 112 // e) Otherwise if the base_server_specifics match the server_specifics, no
113 // functional change must have been made server-side (else 113 // functional change must have been made server-side (else
114 // base_server_specifics would have been cleared), and we can therefore 114 // base_server_specifics would have been cleared), and we can therefore
115 // safely ignore the server changes as redundant. 115 // safely ignore the server changes as redundant.
116 // f) Otherwise, it's in general safer to ignore local changes, with the 116 // f) Otherwise, it's in general safer to ignore local changes, with the
117 // exception of deletion conflicts (choose to undelete) and conflicts 117 // exception of deletion conflicts (choose to undelete) and conflicts
118 // where the non_unique_name or parent don't match. 118 // where the non_unique_name or parent don't match.
119 if (!entry.GetServerIsDel()) { 119 // e) Except for the case of extensions and apps, where we want uninstalls to
120 // win over local modifications to avoid "back from the dead" reinstalls.
121 ModelType type = entry.GetModelType();
122 if (!entry.GetServerIsDel() || (type == EXTENSIONS || type == APPS)) {
Nicolas Zea 2016/02/18 19:28:55 The more I think about it, the more I think it wou
120 // TODO(nick): The current logic is arbitrary; instead, it ought to be made 123 // TODO(nick): The current logic is arbitrary; instead, it ought to be made
121 // consistent with the ModelAssociator behavior for a datatype. It would 124 // consistent with the ModelAssociator behavior for a datatype. It would
122 // be nice if we could route this back to ModelAssociator code to pick one 125 // be nice if we could route this back to ModelAssociator code to pick one
123 // of three options: CLIENT, SERVER, or MERGE. Some datatypes (autofill) 126 // of three options: CLIENT, SERVER, or MERGE. Some datatypes (autofill)
124 // are easily mergeable. 127 // are easily mergeable.
125 // See http://crbug.com/77339. 128 // See http://crbug.com/77339.
126 bool name_matches = entry.GetNonUniqueName() == 129 bool name_matches = entry.GetNonUniqueName() ==
127 entry.GetServerNonUniqueName(); 130 entry.GetServerNonUniqueName();
128 // The parent is implicit type root folder or the parent ID matches. 131 // The parent is implicit type root folder or the parent ID matches.
129 bool parent_matches = entry.GetServerParentId().IsNull() || 132 bool parent_matches = entry.GetServerParentId().IsNull() ||
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 Directory::Metahandles children; 235 Directory::Metahandles children;
233 trans->directory()->GetChildHandlesById(trans, 236 trans->directory()->GetChildHandlesById(trans,
234 entry.GetId(), 237 entry.GetId(),
235 &children); 238 &children);
236 // If a server deleted folder has local contents it should be a hierarchy 239 // If a server deleted folder has local contents it should be a hierarchy
237 // conflict. Hierarchy conflicts should not be processed by this 240 // conflict. Hierarchy conflicts should not be processed by this
238 // function. 241 // function.
239 DCHECK(children.empty()); 242 DCHECK(children.empty());
240 } 243 }
241 244
242 // The entry is deleted on the server but still exists locally. 245 // The entry is deleted on the server but still exists locally.
Nicolas Zea 2016/02/18 19:28:55 Basically, this is where I would add a new conditi
Nicolas Zea 2016/02/18 19:30:31 Actually this logic should probably happen before
asargent_no_longer_on_chrome 2016/02/19 23:59:52 That seems to work great. Done.
243 // We undelete it by overwriting the server's tombstone with the local 246 // We undelete it by overwriting the server's tombstone with the local
244 // data. 247 // data.
245 conflict_util::OverwriteServerChanges(&entry); 248 conflict_util::OverwriteServerChanges(&entry);
246 status->increment_num_server_overwrites(); 249 status->increment_num_server_overwrites();
247 counters->num_server_overwrites++; 250 counters->num_server_overwrites++;
248 DVLOG(1) << "Resolving simple conflict, undeleting server entry: " 251 DVLOG(1) << "Resolving simple conflict, undeleting server entry: "
249 << entry; 252 << entry;
250 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", 253 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict",
251 UNDELETE, 254 UNDELETE,
252 CONFLICT_RESOLUTION_SIZE); 255 CONFLICT_RESOLUTION_SIZE);
(...skipping 18 matching lines...) Expand all
271 GetModelTypeFromSpecifics(conflicting_node.GetSpecifics()))) { 274 GetModelTypeFromSpecifics(conflicting_node.GetSpecifics()))) {
272 continue; 275 continue;
273 } 276 }
274 277
275 ProcessSimpleConflict(trans, *it, cryptographer, status, counters); 278 ProcessSimpleConflict(trans, *it, cryptographer, status, counters);
276 } 279 }
277 return; 280 return;
278 } 281 }
279 282
280 } // namespace syncer 283 } // namespace syncer
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/single_client_extensions_sync_test.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698