OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 // consider the position to have remained the same for D, and will unset | 150 // consider the position to have remained the same for D, and will unset |
151 // it's UNSYNCED/UNAPPLIED bits. When we evaluate C though, we'll see that | 151 // it's UNSYNCED/UNAPPLIED bits. When we evaluate C though, we'll see that |
152 // the prev id is D locally while the server's prev id is a. C will | 152 // the prev id is D locally while the server's prev id is a. C will |
153 // therefore count as a positional conflict (and the local data will be | 153 // therefore count as a positional conflict (and the local data will be |
154 // overwritten by the server data typically). The final result will be | 154 // overwritten by the server data typically). The final result will be |
155 // aCDbe (the same as the server's view). Even though both C and D were | 155 // aCDbe (the same as the server's view). Even though both C and D were |
156 // modified, only one counted as being in actual conflict and was resolved | 156 // modified, only one counted as being in actual conflict and was resolved |
157 // with local/server wins. | 157 // with local/server wins. |
158 // | 158 // |
159 // In general, when there are chains of positional conflicts, only the first | 159 // In general, when there are chains of positional conflicts, only the first |
160 // item in chain (based on the clients point of view) will have both it's | 160 // item in chain (based on the clients point of view) will have both its |
161 // server prev id and local prev id match. For all the rest the server prev | 161 // server prev id and local prev id match. For all the rest the server prev |
162 // id will be the predecessor of the first item in the chain, and therefore | 162 // id will be the predecessor of the first item in the chain, and therefore |
163 // not match the local prev id. | 163 // not match the local prev id. |
164 // | 164 // |
165 // Similarly, chains of conflicts where the server and client info are the | 165 // Similarly, chains of conflicts where the server and client info are the |
166 // same are supported due to the predecessor->successor ordering. In this | 166 // same are supported due to the predecessor->successor ordering. In this |
167 // case, from the first item onward, we unset the UNSYNCED/UNAPPLIED bits as | 167 // case, from the first item onward, we unset the UNSYNCED/UNAPPLIED bits as |
168 // we decide that nothing changed. The subsequent item's server prev id will | 168 // we decide that nothing changed. The subsequent item's server prev id will |
169 // accurately match the local prev id because the predecessor is no longer | 169 // accurately match the local prev id because the predecessor is no longer |
170 // UNSYNCED/UNAPPLIED. | 170 // UNSYNCED/UNAPPLIED. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 if (cryptographer->is_ready()) { | 239 if (cryptographer->is_ready()) { |
240 cryptographer->GetKeys(server_nigori->mutable_encrypted()); | 240 cryptographer->GetKeys(server_nigori->mutable_encrypted()); |
241 } | 241 } |
242 // TODO(zea): Find a better way of doing this. As it stands, we have to | 242 // TODO(zea): Find a better way of doing this. As it stands, we have to |
243 // update this code whenever we add a new non-cryptographer related field | 243 // update this code whenever we add a new non-cryptographer related field |
244 // to the nigori node. | 244 // to the nigori node. |
245 if (entry.Get(syncable::SPECIFICS).nigori().sync_tabs()) { | 245 if (entry.Get(syncable::SPECIFICS).nigori().sync_tabs()) { |
246 server_nigori->set_sync_tabs(true); | 246 server_nigori->set_sync_tabs(true); |
247 } | 247 } |
248 // We deliberately leave the server's device information. This client will | 248 // We deliberately leave the server's device information. This client will |
249 // add it's own device information on restart. | 249 // add its own device information on restart. |
250 entry.Put(syncable::SPECIFICS, specifics); | 250 entry.Put(syncable::SPECIFICS, specifics); |
251 DVLOG(1) << "Resovling simple conflict, merging nigori nodes: " << entry; | 251 DVLOG(1) << "Resovling simple conflict, merging nigori nodes: " << entry; |
ncarter (slow)
2012/03/28 23:37:44
We could fix the spelling of Resovling here.
| |
252 status->increment_num_server_overwrites(); | 252 status->increment_num_server_overwrites(); |
253 OverwriteServerChanges(trans, &entry); | 253 OverwriteServerChanges(trans, &entry); |
254 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", | 254 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", |
255 NIGORI_MERGE, | 255 NIGORI_MERGE, |
256 CONFLICT_RESOLUTION_SIZE); | 256 CONFLICT_RESOLUTION_SIZE); |
257 } else if (!entry_deleted && name_matches && parent_matches && | 257 } else if (!entry_deleted && name_matches && parent_matches && |
258 specifics_match && !needs_reinsertion) { | 258 specifics_match && !needs_reinsertion) { |
259 DVLOG(1) << "Resolving simple conflict, everything matches, ignoring " | 259 DVLOG(1) << "Resolving simple conflict, everything matches, ignoring " |
260 << "changes for: " << entry; | 260 << "changes for: " << entry; |
261 // This unsets both IS_UNSYNCED and IS_UNAPPLIED_UPDATE, and sets the | 261 // This unsets both IS_UNSYNCED and IS_UNAPPLIED_UPDATE, and sets the |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 forward_progress = true; | 395 forward_progress = true; |
396 break; | 396 break; |
397 } | 397 } |
398 processed_items.insert(id); | 398 processed_items.insert(id); |
399 } | 399 } |
400 } | 400 } |
401 return forward_progress; | 401 return forward_progress; |
402 } | 402 } |
403 | 403 |
404 } // namespace browser_sync | 404 } // namespace browser_sync |
OLD | NEW |