OLD | NEW |
| (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 // A class that watches the syncer and attempts to resolve any conflicts that | |
6 // occur. | |
7 | |
8 #ifndef CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ | |
9 #define CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ | |
10 #pragma once | |
11 | |
12 #include <map> | |
13 #include <set> | |
14 #include <string> | |
15 | |
16 #include "base/basictypes.h" | |
17 #include "base/gtest_prod_util.h" | |
18 #include "chrome/browser/sync/engine/syncer_types.h" | |
19 | |
20 namespace syncable { | |
21 class BaseTransaction; | |
22 class Id; | |
23 class MutableEntry; | |
24 class WriteTransaction; | |
25 } // namespace syncable | |
26 | |
27 namespace browser_sync { | |
28 | |
29 class Cryptographer; | |
30 | |
31 namespace sessions { | |
32 class ConflictProgress; | |
33 class StatusController; | |
34 } // namespace sessions | |
35 | |
36 class ConflictResolver { | |
37 friend class SyncerTest; | |
38 FRIEND_TEST_ALL_PREFIXES(SyncerTest, | |
39 ConflictResolverMergeOverwritesLocalEntry); | |
40 public: | |
41 // Enumeration of different conflict resolutions. Used for histogramming. | |
42 enum SimpleConflictResolutions { | |
43 OVERWRITE_LOCAL, // Resolved by overwriting local changes. | |
44 OVERWRITE_SERVER, // Resolved by overwriting server changes. | |
45 UNDELETE, // Resolved by undeleting local item. | |
46 IGNORE_ENCRYPTION, // Resolved by ignoring an encryption-only server | |
47 // change. | |
48 NIGORI_MERGE, // Resolved by merging nigori nodes. | |
49 CHANGES_MATCH, // Resolved by ignoring both local and server | |
50 // changes because they matched. | |
51 CONFLICT_RESOLUTION_SIZE, | |
52 }; | |
53 | |
54 ConflictResolver(); | |
55 ~ConflictResolver(); | |
56 // Called by the syncer at the end of a update/commit cycle. | |
57 // Returns true if the syncer should try to apply its updates again. | |
58 bool ResolveConflicts(syncable::WriteTransaction* trans, | |
59 const Cryptographer* cryptographer, | |
60 const sessions::ConflictProgress& progress, | |
61 sessions::StatusController* status); | |
62 | |
63 private: | |
64 enum ProcessSimpleConflictResult { | |
65 NO_SYNC_PROGRESS, // No changes to advance syncing made. | |
66 SYNC_PROGRESS, // Progress made. | |
67 }; | |
68 | |
69 void IgnoreLocalChanges(syncable::MutableEntry* entry); | |
70 void OverwriteServerChanges(syncable::WriteTransaction* trans, | |
71 syncable::MutableEntry* entry); | |
72 | |
73 ProcessSimpleConflictResult ProcessSimpleConflict( | |
74 syncable::WriteTransaction* trans, | |
75 const syncable::Id& id, | |
76 const Cryptographer* cryptographer, | |
77 sessions::StatusController* status); | |
78 | |
79 bool ResolveSimpleConflicts(syncable::WriteTransaction* trans, | |
80 const Cryptographer* cryptographer, | |
81 const sessions::ConflictProgress& progress, | |
82 sessions::StatusController* status); | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); | |
85 }; | |
86 | |
87 } // namespace browser_sync | |
88 | |
89 #endif // CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ | |
OLD | NEW |