Fix app list and overflow icon drawing problems
[chromium-blink-merge.git] / sync / engine / conflict_util.cc
blobfbb684e5132467f33b39d99a92cd8d7327f710f6
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"
9 namespace syncer {
11 using syncable::BASE_VERSION;
12 using syncable::IS_UNAPPLIED_UPDATE;
13 using syncable::IS_UNSYNCED;
14 using syncable::SERVER_VERSION;
16 using syncable::MutableEntry;
18 // Allow the server's changes to take precedence.
19 // This will take effect during the next ApplyUpdates step.
20 void IgnoreLocalChanges(MutableEntry* entry) {
21 DCHECK(entry->Get(IS_UNSYNCED));
22 DCHECK(entry->Get(IS_UNAPPLIED_UPDATE));
23 entry->Put(IS_UNSYNCED, false);
26 // Overwrite the server with our own value.
27 // We will commit our local data, overwriting the server, at the next
28 // opportunity.
29 void OverwriteServerChanges(MutableEntry* entry) {
30 DCHECK(entry->Get(IS_UNSYNCED));
31 DCHECK(entry->Get(IS_UNAPPLIED_UPDATE));
32 entry->Put(BASE_VERSION, entry->Get(SERVER_VERSION));
33 entry->Put(IS_UNAPPLIED_UPDATE, false);
36 // Having determined that everything matches, we ignore the non-conflict.
37 void IgnoreConflict(MutableEntry* entry) {
38 // If we didn't also unset IS_UNAPPLIED_UPDATE, then we would lose unsynced
39 // positional data from adjacent entries when the server update gets applied
40 // and the item is re-inserted into the PREV_ID/NEXT_ID linked list. This is
41 // primarily an issue because we commit after applying updates, and is most
42 // commonly seen when positional changes are made while a passphrase is
43 // required (and hence there will be many encryption conflicts).
44 DCHECK(entry->Get(IS_UNSYNCED));
45 DCHECK(entry->Get(IS_UNAPPLIED_UPDATE));
46 entry->Put(BASE_VERSION, entry->Get(SERVER_VERSION));
47 entry->Put(IS_UNAPPLIED_UPDATE, false);
48 entry->Put(IS_UNSYNCED, false);
51 } // namespace syncer