| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A class that watches the syncer and attempts to resolve any conflicts that | 5 // A class that watches the syncer and attempts to resolve any conflicts that |
| 6 // occur. | 6 // occur. |
| 7 | 7 |
| 8 #ifndef SYNC_ENGINE_CONFLICT_RESOLVER_H_ | 8 #ifndef SYNC_ENGINE_CONFLICT_RESOLVER_H_ |
| 9 #define SYNC_ENGINE_CONFLICT_RESOLVER_H_ | 9 #define SYNC_ENGINE_CONFLICT_RESOLVER_H_ |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace syncable { | 21 namespace syncable { |
| 22 class BaseTransaction; | 22 class BaseTransaction; |
| 23 class Id; | 23 class Id; |
| 24 class MutableEntry; | 24 class MutableEntry; |
| 25 class WriteTransaction; | 25 class WriteTransaction; |
| 26 } // namespace syncable | 26 } // namespace syncable |
| 27 | 27 |
| 28 class Cryptographer; | 28 class Cryptographer; |
| 29 | 29 |
| 30 namespace sessions { | 30 namespace sessions { |
| 31 class ConflictProgress; | |
| 32 class StatusController; | 31 class StatusController; |
| 33 } // namespace sessions | 32 } // namespace sessions |
| 34 | 33 |
| 35 class ConflictResolver { | 34 class ConflictResolver { |
| 36 friend class SyncerTest; | 35 friend class SyncerTest; |
| 37 FRIEND_TEST_ALL_PREFIXES(SyncerTest, | 36 FRIEND_TEST_ALL_PREFIXES(SyncerTest, |
| 38 ConflictResolverMergeOverwritesLocalEntry); | 37 ConflictResolverMergeOverwritesLocalEntry); |
| 39 public: | 38 public: |
| 40 // Enumeration of different conflict resolutions. Used for histogramming. | 39 // Enumeration of different conflict resolutions. Used for histogramming. |
| 41 enum SimpleConflictResolutions { | 40 enum SimpleConflictResolutions { |
| 42 OVERWRITE_LOCAL, // Resolved by overwriting local changes. | 41 OVERWRITE_LOCAL, // Resolved by overwriting local changes. |
| 43 OVERWRITE_SERVER, // Resolved by overwriting server changes. | 42 OVERWRITE_SERVER, // Resolved by overwriting server changes. |
| 44 UNDELETE, // Resolved by undeleting local item. | 43 UNDELETE, // Resolved by undeleting local item. |
| 45 IGNORE_ENCRYPTION, // Resolved by ignoring an encryption-only server | 44 IGNORE_ENCRYPTION, // Resolved by ignoring an encryption-only server |
| 46 // change. | 45 // change. |
| 47 NIGORI_MERGE, // Resolved by merging nigori nodes. | 46 NIGORI_MERGE, // Resolved by merging nigori nodes. |
| 48 CHANGES_MATCH, // Resolved by ignoring both local and server | 47 CHANGES_MATCH, // Resolved by ignoring both local and server |
| 49 // changes because they matched. | 48 // changes because they matched. |
| 50 CONFLICT_RESOLUTION_SIZE, | 49 CONFLICT_RESOLUTION_SIZE, |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 ConflictResolver(); | 52 ConflictResolver(); |
| 54 ~ConflictResolver(); | 53 ~ConflictResolver(); |
| 55 // Called by the syncer at the end of a update/commit cycle. | 54 // Called by the syncer at the end of a update/commit cycle. |
| 56 // Returns true if the syncer should try to apply its updates again. | 55 // Returns true if the syncer should try to apply its updates again. |
| 57 bool ResolveConflicts(syncable::WriteTransaction* trans, | 56 bool ResolveConflicts(syncable::WriteTransaction* trans, |
| 58 const Cryptographer* cryptographer, | 57 const Cryptographer* cryptographer, |
| 59 const sessions::ConflictProgress& progress, | 58 const std::set<syncable::Id>& simple_conflict_ids, |
| 60 sessions::StatusController* status); | 59 sessions::StatusController* status); |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 enum ProcessSimpleConflictResult { | 62 enum ProcessSimpleConflictResult { |
| 64 NO_SYNC_PROGRESS, // No changes to advance syncing made. | 63 NO_SYNC_PROGRESS, // No changes to advance syncing made. |
| 65 SYNC_PROGRESS, // Progress made. | 64 SYNC_PROGRESS, // Progress made. |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 ProcessSimpleConflictResult ProcessSimpleConflict( | 67 ProcessSimpleConflictResult ProcessSimpleConflict( |
| 69 syncable::WriteTransaction* trans, | 68 syncable::WriteTransaction* trans, |
| 70 const syncable::Id& id, | 69 const syncable::Id& id, |
| 71 const Cryptographer* cryptographer, | 70 const Cryptographer* cryptographer, |
| 72 sessions::StatusController* status); | 71 sessions::StatusController* status); |
| 73 | 72 |
| 74 bool ResolveSimpleConflicts(syncable::WriteTransaction* trans, | |
| 75 const Cryptographer* cryptographer, | |
| 76 const sessions::ConflictProgress& progress, | |
| 77 sessions::StatusController* status); | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); | 73 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); |
| 80 }; | 74 }; |
| 81 | 75 |
| 82 } // namespace syncer | 76 } // namespace syncer |
| 83 | 77 |
| 84 #endif // SYNC_ENGINE_CONFLICT_RESOLVER_H_ | 78 #endif // SYNC_ENGINE_CONFLICT_RESOLVER_H_ |
| OLD | NEW |