Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 // not received any further non-specifics-only or decryptable updates. | 108 // not received any further non-specifics-only or decryptable updates. |
| 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. Another exception is |
|
Nicolas Zea
2016/02/11 23:41:50
nit: may as well put this into its own e) bullet
asargent_no_longer_on_chrome
2016/02/18 00:53:45
Done.
| |
| 119 if (!entry.GetServerIsDel()) { | 119 // the case of extensions and apps, where we want uninstalls to win over |
| 120 // local modifications to avoid "back from the dead" reinstalls. | |
| 121 ModelType type = entry.GetModelType(); | |
| 122 if (!entry.GetServerIsDel() || (type == EXTENSIONS || type == APPS)) { | |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 CONFLICT_RESOLUTION_SIZE); | 197 CONFLICT_RESOLUTION_SIZE); |
| 195 } else if (base_server_specifics_match) { | 198 } else if (base_server_specifics_match) { |
| 196 DVLOG(1) << "Resolving simple conflict, ignoring server encryption " | 199 DVLOG(1) << "Resolving simple conflict, ignoring server encryption " |
| 197 << " changes for: " << entry; | 200 << " changes for: " << entry; |
| 198 status->increment_num_server_overwrites(); | 201 status->increment_num_server_overwrites(); |
| 199 counters->num_server_overwrites++; | 202 counters->num_server_overwrites++; |
| 200 conflict_util::OverwriteServerChanges(&entry); | 203 conflict_util::OverwriteServerChanges(&entry); |
| 201 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", | 204 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", |
| 202 IGNORE_ENCRYPTION, | 205 IGNORE_ENCRYPTION, |
| 203 CONFLICT_RESOLUTION_SIZE); | 206 CONFLICT_RESOLUTION_SIZE); |
| 204 } else if (entry_deleted || !name_matches || !parent_matches) { | 207 } else if (entry_deleted || !name_matches || !parent_matches) { |
|
Nicolas Zea
2016/02/11 23:41:50
Have you manually tested that this works? I think
asargent_no_longer_on_chrome
2016/02/18 00:53:45
I have manually tested that the patch works for th
| |
| 205 // NOTE: The update application logic assumes that conflict resolution | 208 // NOTE: The update application logic assumes that conflict resolution |
| 206 // will never result in changes to the local hierarchy. The entry_deleted | 209 // will never result in changes to the local hierarchy. The entry_deleted |
| 207 // and !parent_matches cases here are critical to maintaining that | 210 // and !parent_matches cases here are critical to maintaining that |
| 208 // assumption. | 211 // assumption. |
| 209 conflict_util::OverwriteServerChanges(&entry); | 212 conflict_util::OverwriteServerChanges(&entry); |
| 210 status->increment_num_server_overwrites(); | 213 status->increment_num_server_overwrites(); |
| 211 counters->num_server_overwrites++; | 214 counters->num_server_overwrites++; |
| 212 DVLOG(1) << "Resolving simple conflict, overwriting server changes " | 215 DVLOG(1) << "Resolving simple conflict, overwriting server changes " |
| 213 << "for: " << entry; | 216 << "for: " << entry; |
| 214 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", | 217 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| OLD | NEW |