OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef SYNC_API_CONFLICT_RESOLUTION_H_ | 5 #ifndef SYNC_API_CONFLICT_RESOLUTION_H_ |
6 #define SYNC_API_CONFLICT_RESOLUTION_H_ | 6 #define SYNC_API_CONFLICT_RESOLUTION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "sync/api/entity_data.h" | 10 #include "sync/api/entity_data.h" |
11 | 11 |
12 namespace syncer_v2 { | 12 namespace syncer_v2 { |
13 | 13 |
14 // A simple class to represent the resolution of a data conflict. We either: | 14 // A simple class to represent the resolution of a data conflict. We either: |
15 // 1) Use the local client data and update the server. | 15 // 1) Use the local client data and update the server. |
16 // 2) Use the remote server data and update the client. | 16 // 2) Use the remote server data and update the client. |
17 // 3) Use newly created data and update both. | 17 // 3) Use newly created data and update both. |
18 class SYNC_EXPORT ConflictResolution { | 18 class SYNC_EXPORT ConflictResolution { |
19 public: | 19 public: |
20 // This enum is used in histograms.xml and entries shouldn't be renumbered or | 20 // This enum is used in histograms.xml and entries shouldn't be renumbered or |
21 // removed. New entries must be added at the end, before TYPE_SIZE. | 21 // removed. New entries must be added at the end, before TYPE_SIZE. |
22 enum Type { | 22 enum Type { |
23 CHANGES_MATCH, // Exists for logging purposes. | 23 CHANGES_MATCH, // Exists for logging purposes. |
24 USE_LOCAL, | 24 USE_LOCAL, |
25 USE_REMOTE, | 25 USE_REMOTE, |
26 USE_NEW, | 26 USE_NEW, |
| 27 IGNORE_LOCAL_ENCRYPTION, // Exists for logging purposes. |
| 28 IGNORE_REMOTE_ENCRYPTION, // Exists for logging purposes. |
27 TYPE_SIZE, | 29 TYPE_SIZE, |
28 }; | 30 }; |
29 | 31 |
30 // Convenience functions for brevity. | 32 // Convenience functions for brevity. |
31 static ConflictResolution UseLocal(); | 33 static ConflictResolution UseLocal(); |
32 static ConflictResolution UseRemote(); | 34 static ConflictResolution UseRemote(); |
33 static ConflictResolution UseNew(std::unique_ptr<EntityData> data); | 35 static ConflictResolution UseNew(std::unique_ptr<EntityData> data); |
34 | 36 |
35 // Move constructor since we can't copy a unique_ptr. | 37 // Move constructor since we can't copy a unique_ptr. |
36 ConflictResolution(ConflictResolution&& other); | 38 ConflictResolution(ConflictResolution&& other); |
37 ~ConflictResolution(); | 39 ~ConflictResolution(); |
38 | 40 |
39 Type type() const { return type_; } | 41 Type type() const { return type_; } |
40 | 42 |
41 // Get the data for USE_NEW, or nullptr. Can only be called once. | 43 // Get the data for USE_NEW, or nullptr. Can only be called once. |
42 std::unique_ptr<EntityData> ExtractData(); | 44 std::unique_ptr<EntityData> ExtractData(); |
43 | 45 |
44 private: | 46 private: |
45 ConflictResolution(Type type, std::unique_ptr<EntityData> data); | 47 ConflictResolution(Type type, std::unique_ptr<EntityData> data); |
46 | 48 |
47 const Type type_; | 49 const Type type_; |
48 std::unique_ptr<EntityData> data_; | 50 std::unique_ptr<EntityData> data_; |
49 | 51 |
50 DISALLOW_COPY_AND_ASSIGN(ConflictResolution); | 52 DISALLOW_COPY_AND_ASSIGN(ConflictResolution); |
51 }; | 53 }; |
52 | 54 |
53 } // namespace syncer_v2 | 55 } // namespace syncer_v2 |
54 | 56 |
55 #endif // SYNC_API_CONFLICT_RESOLUTION_H_ | 57 #endif // SYNC_API_CONFLICT_RESOLUTION_H_ |
OLD | NEW |