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

Side by Side Diff: chrome/browser/sync/engine/conflict_resolver.h

Issue 371029: Remove unique naming. (Closed)
Patch Set: Ready and about to go in! Created 11 years, 1 month 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ 8 #ifndef CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_
9 #define CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ 9 #define CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_
10 10
(...skipping 23 matching lines...) Expand all
34 FRIEND_TEST(SyncerTest, ConflictResolverMergeOverwritesLocalEntry); 34 FRIEND_TEST(SyncerTest, ConflictResolverMergeOverwritesLocalEntry);
35 public: 35 public:
36 ConflictResolver(); 36 ConflictResolver();
37 ~ConflictResolver(); 37 ~ConflictResolver();
38 // Called by the syncer at the end of a update/commit cycle. 38 // Called by the syncer at the end of a update/commit cycle.
39 // Returns true if the syncer should try to apply its updates again. 39 // Returns true if the syncer should try to apply its updates again.
40 bool ResolveConflicts(const syncable::ScopedDirLookup& dir, 40 bool ResolveConflicts(const syncable::ScopedDirLookup& dir,
41 ConflictResolutionView* view, 41 ConflictResolutionView* view,
42 SyncerSession* session); 42 SyncerSession* session);
43 43
44 // Called by ProcessServerClientNameClash. Returns true if it's merged the
45 // items, false otherwise. Does not re-check preconditions covered in
46 // ProcessServerClientNameClash (i.e. it assumes a name clash).
47 bool AttemptItemMerge(syncable::WriteTransaction* trans,
48 syncable::MutableEntry* local_entry,
49 syncable::MutableEntry* server_entry);
50
51 private: 44 private:
52 // We keep a map to record how often we've seen each conflict set. We use this 45 // We keep a map to record how often we've seen each conflict set. We use this
53 // to screen out false positives caused by transient server or client states, 46 // to screen out false positives caused by transient server or client states,
54 // and to allow us to try to make smaller changes to fix situations before 47 // and to allow us to try to make smaller changes to fix situations before
55 // moving onto more drastic solutions. 48 // moving onto more drastic solutions.
56 typedef std::string ConflictSetCountMapKey; 49 typedef std::string ConflictSetCountMapKey;
57 typedef std::map<ConflictSetCountMapKey, int> ConflictSetCountMap; 50 typedef std::map<ConflictSetCountMapKey, int> ConflictSetCountMap;
58 typedef std::map<syncable::Id, int> SimpleConflictCountMap; 51 typedef std::map<syncable::Id, int> SimpleConflictCountMap;
59 52
60 enum ProcessSimpleConflictResult { 53 enum ProcessSimpleConflictResult {
61 NO_SYNC_PROGRESS, // No changes to advance syncing made. 54 NO_SYNC_PROGRESS, // No changes to advance syncing made.
62 SYNC_PROGRESS, // Progress made. 55 SYNC_PROGRESS, // Progress made.
63 }; 56 };
64 57
65 enum ServerClientNameClashReturn {
66 NO_CLASH,
67 SOLUTION_DEFERRED,
68 SOLVED,
69 BOGUS_SET,
70 };
71
72 // Get a key for the given set. NOTE: May reorder set contents. The key is 58 // Get a key for the given set. NOTE: May reorder set contents. The key is
73 // currently not very efficient, but will ease debugging. 59 // currently not very efficient, but will ease debugging.
74 ConflictSetCountMapKey GetSetKey(ConflictSet* conflict_set); 60 ConflictSetCountMapKey GetSetKey(ConflictSet* conflict_set);
75 61
76 void IgnoreLocalChanges(syncable::MutableEntry* entry); 62 void IgnoreLocalChanges(syncable::MutableEntry* entry);
77 void OverwriteServerChanges(syncable::WriteTransaction* trans, 63 void OverwriteServerChanges(syncable::WriteTransaction* trans,
78 syncable::MutableEntry* entry); 64 syncable::MutableEntry* entry);
79 65
80 ProcessSimpleConflictResult ProcessSimpleConflict( 66 ProcessSimpleConflictResult ProcessSimpleConflict(
81 syncable::WriteTransaction* trans, 67 syncable::WriteTransaction* trans,
82 syncable::Id id, 68 syncable::Id id,
83 SyncerSession* session); 69 SyncerSession* session);
84 70
85 bool ResolveSimpleConflicts(const syncable::ScopedDirLookup& dir, 71 bool ResolveSimpleConflicts(const syncable::ScopedDirLookup& dir,
86 ConflictResolutionView* view, 72 ConflictResolutionView* view,
87 SyncerSession* session); 73 SyncerSession* session);
88 74
89 bool ProcessConflictSet(syncable::WriteTransaction* trans, 75 bool ProcessConflictSet(syncable::WriteTransaction* trans,
90 ConflictSet* conflict_set, 76 ConflictSet* conflict_set,
91 int conflict_count, 77 int conflict_count,
92 SyncerSession* session); 78 SyncerSession* session);
93 79
94 // Gives any unsynced entries in the given set new names if possible.
95 bool RenameUnsyncedEntries(syncable::WriteTransaction* trans,
96 ConflictSet* conflict_set);
97
98 ServerClientNameClashReturn ProcessServerClientNameClash(
99 syncable::WriteTransaction* trans,
100 syncable::MutableEntry* locally_named,
101 syncable::MutableEntry* server_named,
102 SyncerSession* session);
103 ServerClientNameClashReturn ProcessNameClashesInSet(
104 syncable::WriteTransaction* trans,
105 ConflictSet* conflict_set,
106 SyncerSession* session);
107
108 // Returns true if we're stuck. 80 // Returns true if we're stuck.
109 template <typename InputIt> 81 template <typename InputIt>
110 bool LogAndSignalIfConflictStuck(syncable::BaseTransaction* trans, 82 bool LogAndSignalIfConflictStuck(syncable::BaseTransaction* trans,
111 int attempt_count, 83 int attempt_count,
112 InputIt start, InputIt end, 84 InputIt start, InputIt end,
113 ConflictResolutionView* view); 85 ConflictResolutionView* view);
114 86
115 ConflictSetCountMap conflict_set_count_map_; 87 ConflictSetCountMap conflict_set_count_map_;
116 SimpleConflictCountMap simple_conflict_count_map_; 88 SimpleConflictCountMap simple_conflict_count_map_;
117 89
118 // Contains the ids of uncommitted items that are children of entries merged 90 // Contains the ids of uncommitted items that are children of entries merged
119 // in the previous cycle. This is used to speed up the merge resolution of 91 // in the previous cycle. This is used to speed up the merge resolution of
120 // deep trees. Used to happen in store refresh. 92 // deep trees. Used to happen in store refresh.
121 // TODO(chron): Can we get rid of this optimization? 93 // TODO(chron): Can we get rid of this optimization?
122 std::set<syncable::Id> children_of_merged_dirs_; 94 std::set<syncable::Id> children_of_merged_dirs_;
123 95
124 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); 96 DISALLOW_COPY_AND_ASSIGN(ConflictResolver);
125 }; 97 };
126 98
127 } // namespace browser_sync 99 } // namespace browser_sync
128 100
129 #endif // CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ 101 #endif // CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/conflict_resolution_view.h ('k') | chrome/browser/sync/engine/conflict_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698