Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / sync / engine / conflict_util.cc
blobfc1e07620467088c9a6b66efea6e0e2c7b513fee
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 namespace conflict_util {
20 // Allow the server's changes to take precedence.
21 // This will take effect during the next ApplyUpdates step.
22 void IgnoreLocalChanges(MutableEntry* entry) {
23 DCHECK(entry->GetIsUnsynced());
24 DCHECK(entry->GetIsUnappliedUpdate());
25 entry->PutIsUnsynced(false);
28 // Overwrite the server with our own value.
29 // We will commit our local data, overwriting the server, at the next
30 // opportunity.
31 void OverwriteServerChanges(MutableEntry* entry) {
32 DCHECK(entry->GetIsUnsynced());
33 DCHECK(entry->GetIsUnappliedUpdate());
34 entry->PutBaseVersion(entry->GetServerVersion());
35 entry->PutIsUnappliedUpdate(false);
38 // Having determined that everything matches, we ignore the non-conflict.
39 void IgnoreConflict(MutableEntry* entry) {
40 // If we didn't also unset IS_UNAPPLIED_UPDATE, then we would lose unsynced
41 // positional data from adjacent entries when the server update gets applied
42 // and the item is re-inserted into the PREV_ID/NEXT_ID linked list. This is
43 // primarily an issue because we commit after applying updates, and is most
44 // commonly seen when positional changes are made while a passphrase is
45 // required (and hence there will be many encryption conflicts).
46 DCHECK(entry->GetIsUnsynced());
47 DCHECK(entry->GetIsUnappliedUpdate());
48 entry->PutBaseVersion(entry->GetServerVersion());
49 entry->PutIsUnappliedUpdate(false);
50 entry->PutIsUnsynced(false);
53 } // namespace conflict_util
54 } // namespace syncer