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
3 // found in the LICENSE file.
5 #include "sync/engine/conflict_util.h"
7 #include "sync/syncable/mutable_entry.h"
11 using syncable::MutableEntry
;
13 namespace conflict_util
{
15 // Allow the server's changes to take precedence.
16 // This will take effect during the next ApplyUpdates step.
17 void IgnoreLocalChanges(MutableEntry
* entry
) {
18 DCHECK(entry
->GetIsUnsynced());
19 DCHECK(entry
->GetIsUnappliedUpdate());
20 entry
->PutIsUnsynced(false);
23 // Overwrite the server with our own value.
24 // We will commit our local data, overwriting the server, at the next
26 void OverwriteServerChanges(MutableEntry
* entry
) {
27 DCHECK(entry
->GetIsUnsynced());
28 DCHECK(entry
->GetIsUnappliedUpdate());
29 entry
->PutBaseVersion(entry
->GetServerVersion());
30 entry
->PutIsUnappliedUpdate(false);
33 // Having determined that everything matches, we ignore the non-conflict.
34 void IgnoreConflict(MutableEntry
* entry
) {
35 // If we didn't also unset IS_UNAPPLIED_UPDATE, then we would lose unsynced
36 // positional data from adjacent entries when the server update gets applied
37 // and the item is re-inserted into the PREV_ID/NEXT_ID linked list. This is
38 // primarily an issue because we commit after applying updates, and is most
39 // commonly seen when positional changes are made while a passphrase is
40 // required (and hence there will be many encryption conflicts).
41 DCHECK(entry
->GetIsUnsynced());
42 DCHECK(entry
->GetIsUnappliedUpdate());
43 entry
->PutBaseVersion(entry
->GetServerVersion());
44 entry
->PutIsUnappliedUpdate(false);
45 entry
->PutIsUnsynced(false);
48 } // namespace conflict_util