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