Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: sync/engine/conflict_util.cc

Issue 10832286: sync: Introduce control data types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add ToFullModelTypeSet() function Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "sync/engine/conflict_util.h"
6
7 #include "sync/syncable/mutable_entry.h"
8
9 namespace syncer {
10
11 using syncable::BASE_VERSION;
12 using syncable::IS_UNAPPLIED_UPDATE;
13 using syncable::IS_UNSYNCED;
14 using syncable::SERVER_VERSION;
15
16 using syncable::MutableEntry;
17
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);
24 }
25
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);
34 }
35
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);
49 }
50
51 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698