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 #include "components/sync/api/conflict_resolution.h" | 5 #include "components/sync/api/conflict_resolution.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 namespace syncer { | 9 namespace syncer { |
8 | 10 |
9 // static | 11 // static |
10 ConflictResolution ConflictResolution::UseLocal() { | 12 ConflictResolution ConflictResolution::UseLocal() { |
11 return ConflictResolution(USE_LOCAL, nullptr); | 13 return ConflictResolution(USE_LOCAL, nullptr); |
12 } | 14 } |
13 | 15 |
14 // static | 16 // static |
15 ConflictResolution ConflictResolution::UseRemote() { | 17 ConflictResolution ConflictResolution::UseRemote() { |
16 return ConflictResolution(USE_REMOTE, nullptr); | 18 return ConflictResolution(USE_REMOTE, nullptr); |
17 } | 19 } |
18 | 20 |
19 // static | 21 // static |
20 ConflictResolution ConflictResolution::UseNew( | 22 ConflictResolution ConflictResolution::UseNew( |
21 std::unique_ptr<EntityData> data) { | 23 std::unique_ptr<EntityData> data) { |
22 DCHECK(data); | 24 DCHECK(data); |
23 return ConflictResolution(USE_NEW, std::move(data)); | 25 return ConflictResolution(USE_NEW, std::move(data)); |
24 } | 26 } |
25 | 27 |
26 ConflictResolution::ConflictResolution(ConflictResolution&& other) | 28 ConflictResolution::ConflictResolution(ConflictResolution&& other) |
27 : ConflictResolution(other.type(), other.ExtractData()) {} | 29 : ConflictResolution(other.type(), other.ExtractData()) {} |
28 | 30 |
29 ConflictResolution::~ConflictResolution() {} | 31 ConflictResolution::~ConflictResolution() {} |
30 | 32 |
31 std::unique_ptr<EntityData> ConflictResolution::ExtractData() { | 33 std::unique_ptr<EntityData> ConflictResolution::ExtractData() { |
32 // Has data if and only if type is USE_NEW. | 34 // Has data if and only if type is USE_NEW. |
33 DCHECK((type_ == USE_NEW) == !!data_); | 35 DCHECK((type_ == USE_NEW) == !!data_); |
34 return std::move(data_); | 36 return std::move(data_); |
35 }; | 37 } |
36 | 38 |
37 ConflictResolution::ConflictResolution(Type type, | 39 ConflictResolution::ConflictResolution(Type type, |
38 std::unique_ptr<EntityData> data) | 40 std::unique_ptr<EntityData> data) |
39 : type_(type), data_(std::move(data)) {} | 41 : type_(type), data_(std::move(data)) {} |
40 | 42 |
41 } // namespace syncer | 43 } // namespace syncer |
OLD | NEW |