Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: chrome/browser/sync/internal_api/change_record.cc

Issue 7918001: [Sync] Move ChangeRecord into its own file (change_record.{h,cc}) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "chrome/browser/sync/internal_api/change_record.h"
6
7 #include "base/string_number_conversions.h"
8 #include "base/values.h"
9 #include "chrome/browser/sync/internal_api/base_node.h"
10 #include "chrome/browser/sync/internal_api/read_node.h"
11 #include "chrome/browser/sync/protocol/proto_value_conversions.h"
12
13 namespace sync_api {
14
15 ChangeRecord::ChangeRecord()
16 : id(kInvalidId), action(ACTION_ADD) {}
17
18 ChangeRecord::~ChangeRecord() {}
19
20 DictionaryValue* ChangeRecord::ToValue(const BaseTransaction* trans) const {
21 DictionaryValue* value = new DictionaryValue();
22 std::string action_str;
23 switch (action) {
24 case ACTION_ADD:
25 action_str = "Add";
26 break;
27 case ACTION_DELETE:
28 action_str = "Delete";
29 break;
30 case ACTION_UPDATE:
31 action_str = "Update";
32 break;
33 default:
34 NOTREACHED();
35 action_str = "Unknown";
36 break;
37 }
38 value->SetString("action", action_str);
39 Value* node_value = NULL;
40 if (action == ACTION_DELETE) {
41 DictionaryValue* node_dict = new DictionaryValue();
42 node_dict->SetString("id", base::Int64ToString(id));
43 node_dict->Set("specifics",
44 browser_sync::EntitySpecificsToValue(specifics));
45 if (extra.get()) {
46 node_dict->Set("extra", extra->ToValue());
47 }
48 node_value = node_dict;
49 } else {
50 ReadNode node(trans);
51 if (node.InitByIdLookup(id)) {
52 node_value = node.GetDetailsAsValue();
53 }
54 }
55 if (!node_value) {
56 NOTREACHED();
57 node_value = Value::CreateNullValue();
58 }
59 value->Set("node", node_value);
60 return value;
61 }
62
63 ExtraPasswordChangeRecordData::ExtraPasswordChangeRecordData() {}
64
65 ExtraPasswordChangeRecordData::ExtraPasswordChangeRecordData(
66 const sync_pb::PasswordSpecificsData& data)
67 : unencrypted_(data) {
68 }
69
70 ExtraPasswordChangeRecordData::~ExtraPasswordChangeRecordData() {}
71
72 DictionaryValue* ExtraPasswordChangeRecordData::ToValue() const {
73 return browser_sync::PasswordSpecificsDataToValue(unencrypted_);
74 }
75
76 const sync_pb::PasswordSpecificsData&
77 ExtraPasswordChangeRecordData::unencrypted() const {
78 return unencrypted_;
79 }
80
81 } // namespace sync_api
82
OLDNEW
« no previous file with comments | « chrome/browser/sync/internal_api/change_record.h ('k') | chrome/browser/sync/internal_api/change_reorder_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698