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