OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 #include "sync/internal_api/public/change_record.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/strings/string_number_conversions.h" | |
10 #include "base/values.h" | |
11 #include "sync/internal_api/public/base_node.h" | |
12 #include "sync/internal_api/public/read_node.h" | |
13 #include "sync/protocol/proto_value_conversions.h" | |
14 | |
15 namespace syncer { | |
16 | |
17 ChangeRecord::ChangeRecord() | |
18 : id(kInvalidId), action(ACTION_ADD) {} | |
19 | |
20 ChangeRecord::ChangeRecord(const ChangeRecord& other) = default; | |
21 | |
22 ChangeRecord::~ChangeRecord() {} | |
23 | |
24 std::unique_ptr<base::DictionaryValue> ChangeRecord::ToValue() const { | |
25 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | |
26 std::string action_str; | |
27 switch (action) { | |
28 case ACTION_ADD: | |
29 action_str = "Add"; | |
30 break; | |
31 case ACTION_DELETE: | |
32 action_str = "Delete"; | |
33 break; | |
34 case ACTION_UPDATE: | |
35 action_str = "Update"; | |
36 break; | |
37 default: | |
38 NOTREACHED(); | |
39 action_str = "Unknown"; | |
40 break; | |
41 } | |
42 value->SetString("action", action_str); | |
43 value->SetString("id", base::Int64ToString(id)); | |
44 if (action == ACTION_DELETE) { | |
45 if (extra.get()) { | |
46 value->Set("extra", extra->ToValue()); | |
47 } | |
48 value->Set("specifics", EntitySpecificsToValue(specifics)); | |
49 } | |
50 return value; | |
51 } | |
52 | |
53 ExtraPasswordChangeRecordData::ExtraPasswordChangeRecordData() {} | |
54 | |
55 ExtraPasswordChangeRecordData::ExtraPasswordChangeRecordData( | |
56 const sync_pb::PasswordSpecificsData& data) | |
57 : unencrypted_(data) { | |
58 } | |
59 | |
60 ExtraPasswordChangeRecordData::~ExtraPasswordChangeRecordData() {} | |
61 | |
62 std::unique_ptr<base::DictionaryValue> ExtraPasswordChangeRecordData::ToValue() | |
63 const { | |
64 return PasswordSpecificsDataToValue(unencrypted_); | |
65 } | |
66 | |
67 const sync_pb::PasswordSpecificsData& | |
68 ExtraPasswordChangeRecordData::unencrypted() const { | |
69 return unencrypted_; | |
70 } | |
71 | |
72 } // namespace syncer | |
OLD | NEW |