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

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

Issue 386030: Relieve SyncerSession,SyncCycleState, SyncProcessState, SyncerSession, Syncer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
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
11 #include <list> 11 #include <set>
12 #include <vector>
13 12
14 #include "base/basictypes.h" 13 #include "base/basictypes.h"
15 #include "chrome/browser/sync/engine/conflict_resolution_view.h"
16 #include "chrome/browser/sync/engine/syncer_session.h"
17 #include "chrome/browser/sync/engine/syncer_status.h"
18 #include "chrome/browser/sync/engine/syncer_types.h" 14 #include "chrome/browser/sync/engine/syncer_types.h"
19 #include "chrome/browser/sync/util/event_sys.h" 15 #include "chrome/browser/sync/util/event_sys.h"
20 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST 16 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST
21 17
22 namespace syncable { 18 namespace syncable {
23 class BaseTransaction; 19 class BaseTransaction;
24 class Id; 20 class Id;
25 class MutableEntry; 21 class MutableEntry;
26 class ScopedDirLookup; 22 class ScopedDirLookup;
27 class WriteTransaction; 23 class WriteTransaction;
28 } // namespace syncable 24 } // namespace syncable
29 25
30 namespace browser_sync { 26 namespace browser_sync {
27 namespace sessions {
28 class StatusController;
29 }
31 30
32 class ConflictResolver { 31 class ConflictResolver {
33 friend class SyncerTest; 32 friend class SyncerTest;
34 FRIEND_TEST(SyncerTest, ConflictResolverMergeOverwritesLocalEntry); 33 FRIEND_TEST(SyncerTest, ConflictResolverMergeOverwritesLocalEntry);
35 public: 34 public:
36 ConflictResolver(); 35 ConflictResolver();
37 ~ConflictResolver(); 36 ~ConflictResolver();
38 // Called by the syncer at the end of a update/commit cycle. 37 // 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. 38 // Returns true if the syncer should try to apply its updates again.
40 bool ResolveConflicts(const syncable::ScopedDirLookup& dir, 39 bool ResolveConflicts(const syncable::ScopedDirLookup& dir,
41 ConflictResolutionView* view, 40 sessions::StatusController* status);
42 SyncerSession* session);
43 41
44 private: 42 private:
45 // We keep a map to record how often we've seen each conflict set. We use this 43 // We keep a map to record how often we've seen each conflict set. We use this
46 // to screen out false positives caused by transient server or client states, 44 // to screen out false positives caused by transient server or client states,
47 // and to allow us to try to make smaller changes to fix situations before 45 // and to allow us to try to make smaller changes to fix situations before
48 // moving onto more drastic solutions. 46 // moving onto more drastic solutions.
49 typedef std::string ConflictSetCountMapKey; 47 typedef std::string ConflictSetCountMapKey;
50 typedef std::map<ConflictSetCountMapKey, int> ConflictSetCountMap; 48 typedef std::map<ConflictSetCountMapKey, int> ConflictSetCountMap;
51 typedef std::map<syncable::Id, int> SimpleConflictCountMap; 49 typedef std::map<syncable::Id, int> SimpleConflictCountMap;
52 50
53 enum ProcessSimpleConflictResult { 51 enum ProcessSimpleConflictResult {
54 NO_SYNC_PROGRESS, // No changes to advance syncing made. 52 NO_SYNC_PROGRESS, // No changes to advance syncing made.
55 SYNC_PROGRESS, // Progress made. 53 SYNC_PROGRESS, // Progress made.
56 }; 54 };
57 55
58 // Get a key for the given set. NOTE: May reorder set contents. The key is 56 // Get a key for the given set. NOTE: May reorder set contents. The key is
59 // currently not very efficient, but will ease debugging. 57 // currently not very efficient, but will ease debugging.
60 ConflictSetCountMapKey GetSetKey(ConflictSet* conflict_set); 58 ConflictSetCountMapKey GetSetKey(ConflictSet* conflict_set);
61 59
62 void IgnoreLocalChanges(syncable::MutableEntry* entry); 60 void IgnoreLocalChanges(syncable::MutableEntry* entry);
63 void OverwriteServerChanges(syncable::WriteTransaction* trans, 61 void OverwriteServerChanges(syncable::WriteTransaction* trans,
64 syncable::MutableEntry* entry); 62 syncable::MutableEntry* entry);
65 63
66 ProcessSimpleConflictResult ProcessSimpleConflict( 64 ProcessSimpleConflictResult ProcessSimpleConflict(
67 syncable::WriteTransaction* trans, 65 syncable::WriteTransaction* trans,
68 syncable::Id id, 66 const syncable::Id& id);
69 SyncerSession* session);
70 67
71 bool ResolveSimpleConflicts(const syncable::ScopedDirLookup& dir, 68 bool ResolveSimpleConflicts(const syncable::ScopedDirLookup& dir,
72 ConflictResolutionView* view, 69 sessions::StatusController* status);
73 SyncerSession* session);
74 70
75 bool ProcessConflictSet(syncable::WriteTransaction* trans, 71 bool ProcessConflictSet(syncable::WriteTransaction* trans,
76 ConflictSet* conflict_set, 72 ConflictSet* conflict_set,
77 int conflict_count, 73 int conflict_count);
78 SyncerSession* session);
79 74
80 // Returns true if we're stuck. 75 // Returns true if we're stuck.
81 template <typename InputIt> 76 template <typename InputIt>
82 bool LogAndSignalIfConflictStuck(syncable::BaseTransaction* trans, 77 bool LogAndSignalIfConflictStuck(syncable::BaseTransaction* trans,
83 int attempt_count, 78 int attempt_count,
84 InputIt start, InputIt end, 79 InputIt start, InputIt end,
85 ConflictResolutionView* view); 80 sessions::StatusController* status);
86 81
87 ConflictSetCountMap conflict_set_count_map_; 82 ConflictSetCountMap conflict_set_count_map_;
88 SimpleConflictCountMap simple_conflict_count_map_; 83 SimpleConflictCountMap simple_conflict_count_map_;
89 84
90 // Contains the ids of uncommitted items that are children of entries merged 85 // Contains the ids of uncommitted items that are children of entries merged
91 // in the previous cycle. This is used to speed up the merge resolution of 86 // in the previous cycle. This is used to speed up the merge resolution of
92 // deep trees. Used to happen in store refresh. 87 // deep trees. Used to happen in store refresh.
93 // TODO(chron): Can we get rid of this optimization? 88 // TODO(chron): Can we get rid of this optimization?
94 std::set<syncable::Id> children_of_merged_dirs_; 89 std::set<syncable::Id> children_of_merged_dirs_;
95 90
96 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); 91 DISALLOW_COPY_AND_ASSIGN(ConflictResolver);
97 }; 92 };
98 93
99 } // namespace browser_sync 94 } // namespace browser_sync
100 95
101 #endif // CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ 96 #endif // CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/conflict_resolution_view.cc ('k') | chrome/browser/sync/engine/conflict_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698