| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_SYNC_API_CONFLICT_RESOLUTION_H_ | |
| 6 #define COMPONENTS_SYNC_API_CONFLICT_RESOLUTION_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "components/sync/api/entity_data.h" | |
| 11 | |
| 12 namespace syncer { | |
| 13 | |
| 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. | |
| 16 // 2) Use the remote server data and update the client. | |
| 17 // 3) Use newly created data and update both. | |
| 18 class ConflictResolution { | |
| 19 public: | |
| 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. | |
| 22 enum Type { | |
| 23 CHANGES_MATCH, // Exists for logging purposes. | |
| 24 USE_LOCAL, | |
| 25 USE_REMOTE, | |
| 26 USE_NEW, | |
| 27 IGNORE_LOCAL_ENCRYPTION, // Exists for logging purposes. | |
| 28 IGNORE_REMOTE_ENCRYPTION, // Exists for logging purposes. | |
| 29 TYPE_SIZE, | |
| 30 }; | |
| 31 | |
| 32 // Convenience functions for brevity. | |
| 33 static ConflictResolution UseLocal(); | |
| 34 static ConflictResolution UseRemote(); | |
| 35 static ConflictResolution UseNew(std::unique_ptr<EntityData> data); | |
| 36 | |
| 37 // Move constructor since we can't copy a unique_ptr. | |
| 38 ConflictResolution(ConflictResolution&& other); | |
| 39 ~ConflictResolution(); | |
| 40 | |
| 41 Type type() const { return type_; } | |
| 42 | |
| 43 // Get the data for USE_NEW, or nullptr. Can only be called once. | |
| 44 std::unique_ptr<EntityData> ExtractData(); | |
| 45 | |
| 46 private: | |
| 47 ConflictResolution(Type type, std::unique_ptr<EntityData> data); | |
| 48 | |
| 49 const Type type_; | |
| 50 std::unique_ptr<EntityData> data_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(ConflictResolution); | |
| 53 }; | |
| 54 | |
| 55 } // namespace syncer | |
| 56 | |
| 57 #endif // COMPONENTS_SYNC_API_CONFLICT_RESOLUTION_H_ | |
| OLD | NEW |