| 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 SYNC_ENGINE_CONFLICT_RESOLVER_H_ | |
| 9 #define SYNC_ENGINE_CONFLICT_RESOLVER_H_ | |
| 10 | |
| 11 #include <set> | |
| 12 | |
| 13 #include "base/gtest_prod_util.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "sync/engine/syncer_types.h" | |
| 16 | |
| 17 namespace syncer { | |
| 18 | |
| 19 namespace syncable { | |
| 20 class Id; | |
| 21 class WriteTransaction; | |
| 22 } // namespace syncable | |
| 23 | |
| 24 class Cryptographer; | |
| 25 struct UpdateCounters; | |
| 26 | |
| 27 namespace sessions { | |
| 28 class StatusController; | |
| 29 } // namespace sessions | |
| 30 | |
| 31 class ConflictResolver { | |
| 32 public: | |
| 33 // Enumeration of different conflict resolutions. Used for histogramming. | |
| 34 enum SimpleConflictResolutions { | |
| 35 OVERWRITE_LOCAL, // Resolved by overwriting local changes. | |
| 36 OVERWRITE_SERVER, // Resolved by overwriting server changes. | |
| 37 UNDELETE, // Resolved by undeleting local item. | |
| 38 IGNORE_ENCRYPTION, // Resolved by ignoring an encryption-only server | |
| 39 // change. | |
| 40 NIGORI_MERGE, // Resolved by merging nigori nodes. | |
| 41 CHANGES_MATCH, // Resolved by ignoring both local and server | |
| 42 // changes because they matched. | |
| 43 CONFLICT_RESOLUTION_SIZE, | |
| 44 }; | |
| 45 | |
| 46 ConflictResolver(); | |
| 47 ~ConflictResolver(); | |
| 48 // Called by the syncer at the end of a update/commit cycle. | |
| 49 // Returns true if the syncer should try to apply its updates again. | |
| 50 void ResolveConflicts(syncable::WriteTransaction* trans, | |
| 51 const Cryptographer* cryptographer, | |
| 52 const std::set<syncable::Id>& simple_conflict_ids, | |
| 53 sessions::StatusController* status, | |
| 54 UpdateCounters* counters); | |
| 55 | |
| 56 private: | |
| 57 friend class SyncerTest; | |
| 58 FRIEND_TEST_ALL_PREFIXES(SyncerTest, | |
| 59 ConflictResolverMergeOverwritesLocalEntry); | |
| 60 | |
| 61 void ProcessSimpleConflict( | |
| 62 syncable::WriteTransaction* trans, | |
| 63 const syncable::Id& id, | |
| 64 const Cryptographer* cryptographer, | |
| 65 sessions::StatusController* status, | |
| 66 UpdateCounters* counters); | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); | |
| 69 }; | |
| 70 | |
| 71 } // namespace syncer | |
| 72 | |
| 73 #endif // SYNC_ENGINE_CONFLICT_RESOLVER_H_ | |
| OLD | NEW |