| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "chrome/browser/sync/engine/syncer_types.h" | 18 #include "chrome/browser/sync/engine/syncer_types.h" |
| 19 | 19 |
| 20 namespace syncable { | 20 namespace syncable { |
| 21 class BaseTransaction; | 21 class BaseTransaction; |
| 22 class Id; | 22 class Id; |
| 23 class MutableEntry; | 23 class MutableEntry; |
| 24 class ScopedDirLookup; | 24 class ScopedDirLookup; |
| 25 class WriteTransaction; | 25 class WriteTransaction; |
| 26 } // namespace syncable | 26 } // namespace syncable |
| 27 | 27 |
| 28 namespace browser_sync { | 28 namespace browser_sync { |
| 29 | 29 |
| 30 class Cryptographer; |
| 31 |
| 30 namespace sessions { | 32 namespace sessions { |
| 31 class ConflictProgress; | 33 class ConflictProgress; |
| 32 class StatusController; | 34 class StatusController; |
| 33 } // namespace sessions | 35 } // namespace sessions |
| 34 | 36 |
| 35 class ConflictResolver { | 37 class ConflictResolver { |
| 36 friend class SyncerTest; | 38 friend class SyncerTest; |
| 37 FRIEND_TEST_ALL_PREFIXES(SyncerTest, | 39 FRIEND_TEST_ALL_PREFIXES(SyncerTest, |
| 38 ConflictResolverMergeOverwritesLocalEntry); | 40 ConflictResolverMergeOverwritesLocalEntry); |
| 39 public: | 41 public: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 // currently not very efficient, but will ease debugging. | 65 // currently not very efficient, but will ease debugging. |
| 64 ConflictSetCountMapKey GetSetKey(ConflictSet* conflict_set); | 66 ConflictSetCountMapKey GetSetKey(ConflictSet* conflict_set); |
| 65 | 67 |
| 66 void IgnoreLocalChanges(syncable::MutableEntry* entry); | 68 void IgnoreLocalChanges(syncable::MutableEntry* entry); |
| 67 void OverwriteServerChanges(syncable::WriteTransaction* trans, | 69 void OverwriteServerChanges(syncable::WriteTransaction* trans, |
| 68 syncable::MutableEntry* entry); | 70 syncable::MutableEntry* entry); |
| 69 | 71 |
| 70 ProcessSimpleConflictResult ProcessSimpleConflict( | 72 ProcessSimpleConflictResult ProcessSimpleConflict( |
| 71 syncable::WriteTransaction* trans, | 73 syncable::WriteTransaction* trans, |
| 72 const syncable::Id& id, | 74 const syncable::Id& id, |
| 75 const Cryptographer* cryptographer, |
| 73 sessions::StatusController* status); | 76 sessions::StatusController* status); |
| 74 | 77 |
| 75 bool ResolveSimpleConflicts(const syncable::ScopedDirLookup& dir, | 78 bool ResolveSimpleConflicts(const syncable::ScopedDirLookup& dir, |
| 76 const sessions::ConflictProgress& progress, | 79 const sessions::ConflictProgress& progress, |
| 77 sessions::StatusController* status); | 80 sessions::StatusController* status); |
| 78 | 81 |
| 79 bool ProcessConflictSet(syncable::WriteTransaction* trans, | 82 bool ProcessConflictSet(syncable::WriteTransaction* trans, |
| 80 ConflictSet* conflict_set, | 83 ConflictSet* conflict_set, |
| 81 int conflict_count); | 84 int conflict_count); |
| 82 | 85 |
| 83 // Returns true if we're stuck. | 86 // Returns true if we're stuck. |
| 84 template <typename InputIt> | 87 template <typename InputIt> |
| 85 bool LogAndSignalIfConflictStuck(syncable::BaseTransaction* trans, | 88 bool LogAndSignalIfConflictStuck(syncable::BaseTransaction* trans, |
| 86 int attempt_count, | 89 int attempt_count, |
| 87 InputIt start, InputIt end, | 90 InputIt start, InputIt end, |
| 88 sessions::StatusController* status); | 91 sessions::StatusController* status); |
| 89 | 92 |
| 90 ConflictSetCountMap conflict_set_count_map_; | 93 ConflictSetCountMap conflict_set_count_map_; |
| 91 SimpleConflictCountMap simple_conflict_count_map_; | 94 SimpleConflictCountMap simple_conflict_count_map_; |
| 92 | 95 |
| 93 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); | 96 DISALLOW_COPY_AND_ASSIGN(ConflictResolver); |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 } // namespace browser_sync | 99 } // namespace browser_sync |
| 97 | 100 |
| 98 #endif // CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ | 101 #endif // CHROME_BROWSER_SYNC_ENGINE_CONFLICT_RESOLVER_H_ |
| OLD | NEW |