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