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