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

Side by Side Diff: components/sync/protocol/proto_value_conversions.cc

Issue 2382443006: Sync MDP: implement MemoryDumpProvider
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 // Keep this file in sync with the .proto files in this directory. 5 // Keep this file in sync with the .proto files in this directory.
6 6
7 #include "components/sync/protocol/proto_value_conversions.h" 7 #include "components/sync/protocol/proto_value_conversions.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 // Customized 79 // Customized
80 template <class P> 80 template <class P>
81 void Visit(P& proto, const char* field_name, 81 void Visit(P& proto, const char* field_name,
82 const sync_pb::EntitySpecifics& field_value) { 82 const sync_pb::EntitySpecifics& field_value) {
83 if (include_specifics_) { 83 if (include_specifics_) {
84 VisitImpl(proto, field_name, field_value); 84 VisitImpl(proto, field_name, field_value);
85 } 85 }
86 } 86 }
87 87
88 // Customized
89 template <class P>
90 void Visit(P& proto, const char* field_name,
91 const sync_pb::EnhancedBookmarksFlags& field_value) {
92 // Obsolete, don't visit
93 }
94
95 // Customized
96 template <class P>
97 void Visit(P& proto, const char* field_name,
98 const sync_pb::WalletSyncFlags& field_value) {
99 // Obsolete, don't visit
100 }
101
88 template <class P> 102 template <class P>
89 static std::unique_ptr<base::DictionaryValue> Visit( 103 static std::unique_ptr<base::DictionaryValue> Visit(
90 const P& proto, 104 const P& proto,
91 bool include_specifics=true) { 105 bool include_specifics=true) {
92 ToValueVisitor visitor(include_specifics); 106 ToValueVisitor visitor(include_specifics);
93 visitor.VisitProto(proto); 107 visitor.VisitProto(proto);
94 return std::move(visitor.value_); 108 return std::move(visitor.value_);
95 } 109 }
96 110
97 private: 111 private:
98 explicit ToValueVisitor(bool include_specifics) 112 explicit ToValueVisitor(bool include_specifics)
99 : value_(new base::DictionaryValue()) 113 : value_(new base::DictionaryValue())
100 , include_specifics_(include_specifics) {} 114 , include_specifics_(include_specifics) {}
101 115
102 template <class P, class F> 116 template <class P, class F>
103 void VisitImpl(P& proto, const char* field_name, const F& value) { 117 void VisitImpl(P& proto, const char* field_name, const F& value) {
104 value_->Set(field_name, ToValue(value)); 118 value_->Set(field_name, ToValue(value));
105 } 119 }
106 120
107 template <class P> 121 template <class P>
108 void VisitProto(const P& proto) { 122 void VisitProto(const P& proto) {
109 VisitProtoFields(*this, proto); 123 VisitProtoFields(*this, proto);
110 } 124 }
111 125
112 // Customized 126 // Customized
113 void VisitProto(const sync_pb::PasswordSpecificsData& proto) { 127 void VisitProto(const sync_pb::PasswordSpecificsData& proto) {
114 VisitProtoFields(*this, proto); 128 VisitProtoFields(*this, proto);
115 Visit(proto, "password_value", std::string("<redacted>")); 129 value_->SetString("password_value", "<redacted>");
116 } 130 }
117 131
118 // Customized 132 // Customized
119 void VisitProto(const sync_pb::AutofillWalletSpecifics& proto) { 133 void VisitProto(const sync_pb::AutofillWalletSpecifics& proto) {
120 VisitProtoFields(*this, proto); 134 VisitProtoFields(*this, proto);
121 if (proto.type() != sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) { 135 if (proto.type() != sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) {
122 value_->Remove("address", nullptr); 136 value_->Remove("address", nullptr);
123 } 137 }
124 if (proto.type() != sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { 138 if (proto.type() != sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) {
125 value_->Remove("masked_card", nullptr); 139 value_->Remove("masked_card", nullptr);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 IMPLEMENT_PROTO_TO_VALUE(WifiCredentialSpecifics) 262 IMPLEMENT_PROTO_TO_VALUE(WifiCredentialSpecifics)
249 263
250 IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS(ClientToServerMessage) 264 IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS(ClientToServerMessage)
251 IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS(ClientToServerResponse) 265 IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS(ClientToServerResponse)
252 IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS(SyncEntity) 266 IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS(SyncEntity)
253 267
254 #undef IMPLEMENT_PROTO_TO_VALUE 268 #undef IMPLEMENT_PROTO_TO_VALUE
255 #undef IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS 269 #undef IMPLEMENT_PROTO_TO_VALUE_INCLUDE_SPECIFICS
256 270
257 } // namespace syncer 271 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/protocol/proto_size_estimations_unittest.cc ('k') | components/sync/protocol/proto_visitors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698