OLD | NEW |
---|---|
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 "sync/protocol/proto_value_conversions.h" | 7 #include "sync/protocol/proto_value_conversions.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "sync/protocol/sync.pb.h" | 44 #include "sync/protocol/sync.pb.h" |
45 #include "sync/protocol/theme_specifics.pb.h" | 45 #include "sync/protocol/theme_specifics.pb.h" |
46 #include "sync/protocol/typed_url_specifics.pb.h" | 46 #include "sync/protocol/typed_url_specifics.pb.h" |
47 #include "sync/protocol/unique_position.pb.h" | 47 #include "sync/protocol/unique_position.pb.h" |
48 #include "sync/util/time.h" | 48 #include "sync/util/time.h" |
49 | 49 |
50 namespace syncer { | 50 namespace syncer { |
51 | 51 |
52 namespace { | 52 namespace { |
53 | 53 |
54 // Basic Type -> Value functions. | 54 enum ResultType { |
stanisc
2016/07/06 21:50:31
Someone from the current Sync team should review t
ssid
2016/07/19 22:10:35
Not sure what is the alternative here. I can't thi
| |
55 MEMORY_USAGE, // Visitors return only the memory usage | |
56 CONVERT_TO_VALUE // Visitors return only the dictionary value. | |
57 }; | |
55 | 58 |
56 std::unique_ptr<base::StringValue> MakeInt64Value(int64_t x) { | 59 struct VisitorResult { |
57 return base::WrapUnique(new base::StringValue(base::Int64ToString(x))); | 60 VisitorResult(size_t usage) : memory_usage(usage) {} |
61 VisitorResult(std::unique_ptr<base::Value> value) | |
62 : memory_usage(0), as_value(std::move(value)) {} | |
63 | |
64 base::DictionaryValue* as_dict_value() { | |
65 DCHECK(as_value); | |
66 base::DictionaryValue* value; | |
67 as_value->GetAsDictionary(&value); | |
68 return value; | |
69 } | |
70 std::unique_ptr<base::DictionaryValue> TakeDictValue() { | |
71 base::DictionaryValue* value; | |
72 bool res = as_value.release()->GetAsDictionary(&value); | |
73 DCHECK(res); | |
74 return base::WrapUnique(value); | |
75 } | |
76 | |
77 size_t memory_usage; | |
78 std::unique_ptr<base::Value> as_value; | |
79 }; | |
80 | |
81 VisitorResult MakeInt64Value(int64_t x, const ResultType result_type) { | |
82 if (result_type == MEMORY_USAGE) { | |
83 return VisitorResult(0); | |
84 } | |
85 return VisitorResult( | |
86 base::WrapUnique(new base::StringValue(base::Int64ToString(x)))); | |
58 } | 87 } |
59 | 88 |
60 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use | 89 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use |
61 // that instead of a StringValue. | 90 // that instead of a StringValue. |
62 std::string Base64EncodeString(const std::string& bytes) { | 91 std::string Base64EncodeString(const std::string& bytes) { |
63 std::string bytes_base64; | 92 std::string bytes_base64; |
64 base::Base64Encode(bytes, &bytes_base64); | 93 base::Base64Encode(bytes, &bytes_base64); |
65 return bytes_base64; | 94 return bytes_base64; |
66 } | 95 } |
67 | 96 |
68 std::unique_ptr<base::StringValue> MakeStringValue(const std::string& str) { | 97 VisitorResult MakeStringValue(const std::string& str, |
69 return base::WrapUnique(new base::StringValue(str)); | 98 const ResultType result_type) { |
99 if (result_type == MEMORY_USAGE) | |
100 return VisitorResult(str.capacity()); | |
101 return VisitorResult(base::WrapUnique(new base::StringValue(str))); | |
70 } | 102 } |
71 | 103 |
72 // T is the field type, F is either RepeatedField or RepeatedPtrField, | 104 // T is the field type, F is either RepeatedField or RepeatedPtrField, |
73 // and V is a subclass of Value. | 105 // and V is a subclass of Value. |
74 template <class T, class F, class V> | 106 template <class T, class F> |
75 std::unique_ptr<base::ListValue> MakeRepeatedValue(const F& fields, | 107 VisitorResult MakeRepeatedVisit(const F& fields, |
76 V (*converter_fn)(T)) { | 108 VisitorResult (*converter_fn)(T, |
109 const ResultType), | |
110 const ResultType result_type) { | |
111 if (result_type == MEMORY_USAGE) { | |
112 size_t total = 0; | |
113 for (typename F::const_iterator it = fields.begin(); it != fields.end(); | |
114 ++it) { | |
115 total += converter_fn(*it, result_type).memory_usage + sizeof(T); | |
116 } | |
117 return VisitorResult(total); | |
118 } | |
77 std::unique_ptr<base::ListValue> list(new base::ListValue()); | 119 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
78 for (typename F::const_iterator it = fields.begin(); it != fields.end(); | 120 for (typename F::const_iterator it = fields.begin(); it != fields.end(); |
79 ++it) { | 121 ++it) { |
80 list->Append(converter_fn(*it)); | 122 list->Append(converter_fn(*it, result_type).as_value); |
81 } | 123 } |
82 return list; | 124 return VisitorResult(std::move(list)); |
83 } | 125 } |
84 | 126 |
85 } // namespace | 127 } // namespace |
86 | 128 |
87 // Helper macros to reduce the amount of boilerplate. | 129 // Helper macros to reduce the amount of boilerplate. |
88 | 130 |
89 #define SET_TYPE(field, set_fn, transform) \ | 131 #define SET_WITH_EXPR(field, visit_expr, excess_size) \ |
90 if (proto.has_##field()) { \ | 132 if (result_type == MEMORY_USAGE) { \ |
91 value->set_fn(#field, transform(proto.field())); \ | 133 result.memory_usage += visit_expr.memory_usage + excess_size; \ |
134 } else { \ | |
135 result.as_dict_value()->Set(#field, visit_expr.as_value); \ | |
92 } | 136 } |
93 #define SET(field, fn) SET_TYPE(field, Set, fn) | 137 |
138 #define SET_TYPE(field, set_fn, transform) \ | |
139 if (result_type == CONVERT_TO_VALUE && proto.has_##field()) { \ | |
140 result.as_dict_value()->set_fn(#field, transform(proto.field())); \ | |
141 } | |
142 #define SET(field, fn) \ | |
143 if (proto.has_##field()) { \ | |
144 SET_WITH_EXPR(field, fn(proto.field(), result_type), \ | |
145 sizeof(proto.field())); \ | |
146 } | |
94 #define SET_REP(field, fn) \ | 147 #define SET_REP(field, fn) \ |
95 value->Set(#field, MakeRepeatedValue(proto.field(), fn)) | 148 SET_WITH_EXPR(field, MakeRepeatedVisit(proto.field(), fn, result_type), 0) |
96 #define SET_ENUM(field, fn) SET_TYPE(field, SetString, fn) | 149 #define SET_ENUM(field, fn) SET_TYPE(field, SetString, fn) |
97 | 150 |
98 #define SET_BOOL(field) SET_TYPE(field, SetBoolean, ) | 151 #define SET_BOOL(field) SET_TYPE(field, SetBoolean, ) |
99 #define SET_BYTES(field) SET_TYPE(field, SetString, Base64EncodeString) | 152 #define SET_BYTES(field) SET_TYPE(field, SetString, Base64EncodeString) |
100 #define SET_INT32(field) SET_TYPE(field, SetString, base::Int64ToString) | 153 #define SET_INT32(field) SET_TYPE(field, SetString, base::Int64ToString) |
101 #define SET_INT32_REP(field) SET_REP(field, MakeInt64Value) | 154 #define SET_INT32_REP(field) SET_REP(field, MakeInt64Value) |
102 #define SET_INT64(field) SET_TYPE(field, SetString, base::Int64ToString) | 155 #define SET_INT64(field) SET_TYPE(field, SetString, base::Int64ToString) |
103 #define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) | 156 #define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) |
104 #define SET_STR(field) SET_TYPE(field, SetString, ) | 157 #define SET_STR(field) \ |
158 if (proto.has_##field()) { \ | |
159 SET_WITH_EXPR(field, MakeStringValue(proto.field(), result_type), \ | |
160 sizeof(std::string)); \ | |
161 } | |
105 #define SET_TIME_STR(field) SET_TYPE(field, SetString, TimestampToString) | 162 #define SET_TIME_STR(field) SET_TYPE(field, SetString, TimestampToString) |
106 #define SET_STR_REP(field) \ | 163 #define SET_STR_REP(field) \ |
107 value->Set( \ | 164 SET_WITH_EXPR( \ |
108 #field, \ | 165 field, \ |
109 MakeRepeatedValue<const std::string&, \ | 166 (MakeRepeatedVisit<const std::string&, \ |
110 google::protobuf::RepeatedPtrField<std::string>, \ | 167 google::protobuf::RepeatedPtrField<std::string>>( \ |
111 std::unique_ptr<base::StringValue>>(proto.field(), \ | 168 proto.field(), MakeStringValue, result_type)), \ |
112 MakeStringValue)) | 169 0); |
113 #define SET_EXPERIMENT_ENABLED_FIELD(field) \ | 170 #define SET_EXPERIMENT_ENABLED_FIELD(field) \ |
114 do { \ | 171 if (proto.has_##field()) { \ |
115 if (proto.has_##field() && \ | 172 if (result_type == MEMORY_USAGE) { \ |
116 proto.field().has_enabled()) { \ | 173 result.memory_usage += sizeof(proto.field()); \ |
117 value->Set(#field, \ | 174 } else if (proto.field().has_enabled()) { \ |
118 new base::FundamentalValue( \ | 175 result.as_dict_value()->Set( \ |
119 proto.field().enabled())); \ | 176 #field, new base::FundamentalValue(proto.field().enabled())); \ |
120 } \ | 177 } \ |
121 } while (0) | 178 } |
122 | 179 |
123 #define SET_FIELD(field, fn) \ | 180 #define SET_FIELD(field, fn) \ |
124 do { \ | 181 if (specifics.has_##field()) { \ |
125 if (specifics.has_##field()) { \ | 182 SET_WITH_EXPR(field, fn(specifics.field(), result_type), \ |
126 value->Set(#field, fn(specifics.field())); \ | 183 sizeof(specifics.field())); \ |
127 } \ | 184 } |
128 } while (0) | |
129 | 185 |
130 // If you add another macro, don't forget to add an #undef at the end | 186 // If you add another macro, don't forget to add an #undef at the end |
131 // of this file, too. | 187 // of this file, too. |
132 | 188 |
133 std::unique_ptr<base::DictionaryValue> EncryptedDataToValue( | 189 VisitorResult EncryptedDataVisit(const sync_pb::EncryptedData& encrypted_data, |
134 const sync_pb::EncryptedData& proto) { | 190 const ResultType result_type); |
135 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 191 |
192 VisitorResult AppListSpecificsVisit(const sync_pb::AppListSpecifics& proto, | |
193 const ResultType result_type); | |
194 | |
195 VisitorResult AppSettingsVisit( | |
196 const sync_pb::AppNotificationSettings& app_notification_settings, | |
197 const ResultType result_type); | |
198 | |
199 VisitorResult LinkedAppIconInfoVisit( | |
200 const sync_pb::LinkedAppIconInfo& linked_app_icon_info, | |
201 const ResultType result_type); | |
202 | |
203 VisitorResult SessionHeaderVisit(const sync_pb::SessionHeader& session_header, | |
204 const ResultType result_type); | |
205 | |
206 VisitorResult SessionTabVisit(const sync_pb::SessionTab& session_tab, | |
207 const ResultType result_type); | |
208 | |
209 VisitorResult SessionWindowVisit(const sync_pb::SessionWindow& session_window, | |
210 const ResultType result_type); | |
211 | |
212 VisitorResult TabNavigationVisit(const sync_pb::TabNavigation& tab_navigation, | |
213 const ResultType result_type); | |
214 | |
215 VisitorResult NavigationRedirectVisit( | |
216 const sync_pb::NavigationRedirect& navigation_redirect, | |
217 const ResultType result_type); | |
218 | |
219 VisitorResult PasswordSpecificsDataVisit( | |
220 const sync_pb::PasswordSpecificsData& password_specifics_data, | |
221 const ResultType result_type); | |
222 | |
223 VisitorResult GlobalIdDirectiveVisit( | |
224 const sync_pb::GlobalIdDirective& global_id_directive, | |
225 const ResultType result_type); | |
226 | |
227 VisitorResult TimeRangeDirectiveVisit( | |
228 const sync_pb::TimeRangeDirective& time_range_directive, | |
229 const ResultType result_type); | |
230 | |
231 VisitorResult SessionSpecificsVisit( | |
232 const sync_pb::SessionSpecifics& session_specifics, | |
233 const ResultType result_type); | |
234 | |
235 VisitorResult ArcPackageSpecificsVisit( | |
236 const sync_pb::ArcPackageSpecifics& proto, | |
237 const ResultType result_type); | |
238 | |
239 VisitorResult AppNotificationVisit( | |
240 const sync_pb::AppNotification& app_notification_specifics, | |
241 const ResultType result_type); | |
242 | |
243 VisitorResult AppSettingSpecificsVisit( | |
244 const sync_pb::AppSettingSpecifics& app_setting_specifics, | |
245 const ResultType result_type); | |
246 | |
247 VisitorResult AppSpecificsVisit(const sync_pb::AppSpecifics& app_specifics, | |
248 const ResultType result_type); | |
249 | |
250 VisitorResult ArticleSpecificsVisit( | |
251 const sync_pb::ArticleSpecifics& article_specifics, | |
252 const ResultType result_type); | |
253 | |
254 VisitorResult AutofillSpecificsVisit( | |
255 const sync_pb::AutofillSpecifics& autofill_specifics, | |
256 const ResultType result_type); | |
257 | |
258 VisitorResult AutofillProfileSpecificsVisit( | |
259 const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics, | |
260 const ResultType result_type); | |
261 | |
262 VisitorResult WalletMetadataSpecificsVisit( | |
263 const sync_pb::WalletMetadataSpecifics& wallet_metadata_specifics, | |
264 const ResultType result_type); | |
265 | |
266 VisitorResult AutofillWalletSpecificsVisit( | |
267 const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics, | |
268 const ResultType result_type); | |
269 | |
270 VisitorResult BookmarkSpecificsVisit( | |
271 const sync_pb::BookmarkSpecifics& bookmark_specifics, | |
272 const ResultType result_type); | |
273 | |
274 VisitorResult DeviceInfoSpecificsVisit( | |
275 const sync_pb::DeviceInfoSpecifics& device_info_specifics, | |
276 const ResultType result_type); | |
277 | |
278 VisitorResult DictionarySpecificsVisit( | |
279 const sync_pb::DictionarySpecifics& dictionary_specifics, | |
280 const ResultType result_type); | |
281 | |
282 VisitorResult ExperimentsSpecificsVisit( | |
283 const sync_pb::ExperimentsSpecifics& proto, | |
284 const ResultType result_type); | |
285 | |
286 VisitorResult PriorityPreferenceSpecificsVisit( | |
287 const sync_pb::PriorityPreferenceSpecifics& proto, | |
288 const ResultType result_type); | |
289 | |
290 VisitorResult ExtensionSettingSpecificsVisit( | |
291 const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics, | |
292 const ResultType result_type); | |
293 | |
294 VisitorResult ExtensionSpecificsVisit( | |
295 const sync_pb::ExtensionSpecifics& extension_specifics, | |
296 const ResultType result_type); | |
297 | |
298 VisitorResult FaviconImageSpecificsVisit( | |
299 const sync_pb::FaviconImageSpecifics& favicon_image_specifics, | |
300 const ResultType result_type); | |
301 | |
302 VisitorResult FaviconTrackingSpecificsVisit( | |
303 const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics, | |
304 const ResultType result_type); | |
305 | |
306 VisitorResult HistoryDeleteDirectiveSpecificsVisit( | |
307 const sync_pb::HistoryDeleteDirectiveSpecifics& | |
308 history_delete_directive_specifics, | |
309 const ResultType result_type); | |
310 | |
311 VisitorResult ManagedUserSettingSpecificsVisit( | |
312 const sync_pb::ManagedUserSettingSpecifics& managed_user_setting_specifics, | |
313 const ResultType result_type); | |
314 | |
315 VisitorResult ManagedUserSpecificsVisit( | |
316 const sync_pb::ManagedUserSpecifics& managed_user_specifics, | |
317 const ResultType result_type); | |
318 | |
319 VisitorResult ManagedUserSharedSettingSpecificsVisit( | |
320 const sync_pb::ManagedUserSharedSettingSpecifics& | |
321 managed_user_shared_setting_specifics, | |
322 const ResultType result_type); | |
323 | |
324 VisitorResult ManagedUserWhitelistSpecificsVisit( | |
325 const sync_pb::ManagedUserWhitelistSpecifics& | |
326 managed_user_whitelist_specifics, | |
327 const ResultType result_type); | |
328 | |
329 VisitorResult NigoriSpecificsVisit( | |
330 const sync_pb::NigoriSpecifics& nigori_specifics, | |
331 const ResultType result_type); | |
332 | |
333 VisitorResult PasswordSpecificsVisit( | |
334 const sync_pb::PasswordSpecifics& password_specifics, | |
335 const ResultType result_type); | |
336 | |
337 VisitorResult PreferenceSpecificsVisit( | |
338 const sync_pb::PreferenceSpecifics& password_specifics, | |
339 const ResultType result_type); | |
340 | |
341 VisitorResult SyncedNotificationAppInfoSpecificsVisit( | |
342 const sync_pb::SyncedNotificationAppInfoSpecifics& | |
343 synced_notification_specifics, | |
344 const ResultType result_type); | |
345 | |
346 VisitorResult SyncedNotificationSpecificsVisit( | |
347 const sync_pb::SyncedNotificationSpecifics& synced_notification_specifics, | |
348 const ResultType result_type); | |
349 | |
350 VisitorResult SearchEngineSpecificsVisit( | |
351 const sync_pb::SearchEngineSpecifics& search_engine_specifics, | |
352 const ResultType result_type); | |
353 | |
354 VisitorResult ThemeSpecificsVisit( | |
355 const sync_pb::ThemeSpecifics& theme_specifics, | |
356 const ResultType result_type); | |
357 | |
358 VisitorResult TypedUrlSpecificsVisit( | |
359 const sync_pb::TypedUrlSpecifics& typed_url_specifics, | |
360 const ResultType result_type); | |
361 | |
362 VisitorResult WalletMaskedCreditCardVisit( | |
363 const sync_pb::WalletMaskedCreditCard& wallet_masked_card, | |
364 const ResultType result_type); | |
365 | |
366 VisitorResult WalletPostalAddressVisit( | |
367 const sync_pb::WalletPostalAddress& wallet_postal_address, | |
368 const ResultType result_type); | |
369 | |
370 VisitorResult WifiCredentialSpecificsVisit( | |
371 const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics, | |
372 const ResultType result_type); | |
373 | |
374 VisitorResult EntitySpecificsVisit(const sync_pb::EntitySpecifics& specifics, | |
375 const ResultType result_type); | |
376 | |
377 VisitorResult SyncEntityVisit(const sync_pb::SyncEntity& entity, | |
378 bool include_specifics, | |
379 const ResultType result_type); | |
380 | |
381 VisitorResult ClientToServerMessageVisit( | |
382 const sync_pb::ClientToServerMessage& proto, | |
383 bool include_specifics, | |
384 const ResultType result_type); | |
385 | |
386 VisitorResult ClientToServerResponseVisit( | |
387 const sync_pb::ClientToServerResponse& proto, | |
388 bool include_specifics, | |
389 const ResultType result_type); | |
390 | |
391 VisitorResult DatatypeAssociationStatsVisit( | |
392 const sync_pb::DatatypeAssociationStats& proto, | |
393 const ResultType result_type); | |
394 | |
395 VisitorResult DebugEventInfoVisit(const sync_pb::DebugEventInfo& proto, | |
396 const ResultType result_type); | |
397 | |
398 VisitorResult DebugInfoVisit(const sync_pb::DebugInfo& proto, | |
399 const ResultType result_type); | |
400 | |
401 VisitorResult SyncCycleCompletedEventInfoVisit( | |
402 const sync_pb::SyncCycleCompletedEventInfo& proto, | |
403 const ResultType result_type); | |
404 | |
405 VisitorResult ClientConfigParamsVisit(const sync_pb::ClientConfigParams& proto, | |
406 const ResultType result_type); | |
407 | |
408 VisitorResult AttachmentIdProtoVisit(const sync_pb::AttachmentIdProto& proto, | |
409 const ResultType result_type); | |
410 | |
411 VisitorResult EncryptedDataVisit(const sync_pb::EncryptedData& proto, | |
412 const ResultType result_type) { | |
413 VisitorResult result(0); | |
414 if (result_type == CONVERT_TO_VALUE) | |
415 result.as_value.reset(new base::DictionaryValue()); | |
136 SET_STR(key_name); | 416 SET_STR(key_name); |
137 // TODO(akalin): Shouldn't blob be of type bytes instead of string? | 417 // TODO(akalin): Shouldn't blob be of type bytes instead of string? |
138 SET_BYTES(blob); | 418 SET_BYTES(blob); |
139 return value; | 419 return result; |
140 } | 420 } |
141 | 421 |
142 std::unique_ptr<base::DictionaryValue> AppSettingsToValue( | 422 VisitorResult AppSettingsVisit(const sync_pb::AppNotificationSettings& proto, |
143 const sync_pb::AppNotificationSettings& proto) { | 423 const ResultType result_type) { |
144 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 424 VisitorResult result(0); |
425 if (result_type == CONVERT_TO_VALUE) | |
426 result.as_value.reset(new base::DictionaryValue()); | |
145 SET_BOOL(initial_setup_done); | 427 SET_BOOL(initial_setup_done); |
146 SET_BOOL(disabled); | 428 SET_BOOL(disabled); |
147 SET_STR(oauth_client_id); | 429 SET_STR(oauth_client_id); |
148 return value; | 430 return result; |
149 } | 431 } |
150 | 432 |
151 std::unique_ptr<base::DictionaryValue> SessionHeaderToValue( | 433 VisitorResult SessionHeaderVisit(const sync_pb::SessionHeader& proto, |
152 const sync_pb::SessionHeader& proto) { | 434 const ResultType result_type) { |
153 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 435 VisitorResult result(0); |
154 SET_REP(window, SessionWindowToValue); | 436 if (result_type == CONVERT_TO_VALUE) |
437 result.as_value.reset(new base::DictionaryValue()); | |
438 SET_REP(window, SessionWindowVisit); | |
155 SET_STR(client_name); | 439 SET_STR(client_name); |
156 SET_ENUM(device_type, GetDeviceTypeString); | 440 SET_ENUM(device_type, GetDeviceTypeString); |
157 return value; | 441 return result; |
158 } | 442 } |
159 | 443 |
160 std::unique_ptr<base::DictionaryValue> SessionTabToValue( | 444 VisitorResult SessionTabVisit(const sync_pb::SessionTab& proto, |
161 const sync_pb::SessionTab& proto) { | 445 const ResultType result_type) { |
162 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 446 VisitorResult result(0); |
447 if (result_type == CONVERT_TO_VALUE) | |
448 result.as_value.reset(new base::DictionaryValue()); | |
163 SET_INT32(tab_id); | 449 SET_INT32(tab_id); |
164 SET_INT32(window_id); | 450 SET_INT32(window_id); |
165 SET_INT32(tab_visual_index); | 451 SET_INT32(tab_visual_index); |
166 SET_INT32(current_navigation_index); | 452 SET_INT32(current_navigation_index); |
167 SET_BOOL(pinned); | 453 SET_BOOL(pinned); |
168 SET_STR(extension_app_id); | 454 SET_STR(extension_app_id); |
169 SET_REP(navigation, TabNavigationToValue); | 455 SET_REP(navigation, TabNavigationVisit); |
170 SET_BYTES(favicon); | 456 SET_BYTES(favicon); |
171 SET_ENUM(favicon_type, GetFaviconTypeString); | 457 SET_ENUM(favicon_type, GetFaviconTypeString); |
172 SET_STR(favicon_source); | 458 SET_STR(favicon_source); |
173 SET_REP(variation_id, MakeInt64Value); | 459 SET_REP(variation_id, MakeInt64Value); |
174 return value; | 460 return result; |
175 } | 461 } |
176 | 462 |
177 std::unique_ptr<base::DictionaryValue> SessionWindowToValue( | 463 VisitorResult SessionWindowVisit(const sync_pb::SessionWindow& proto, |
178 const sync_pb::SessionWindow& proto) { | 464 const ResultType result_type) { |
179 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 465 VisitorResult result(0); |
466 if (result_type == CONVERT_TO_VALUE) | |
467 result.as_value.reset(new base::DictionaryValue()); | |
180 SET_INT32(window_id); | 468 SET_INT32(window_id); |
181 SET_INT32(selected_tab_index); | 469 SET_INT32(selected_tab_index); |
182 SET_INT32_REP(tab); | 470 SET_INT32_REP(tab); |
183 SET_ENUM(browser_type, GetBrowserTypeString); | 471 SET_ENUM(browser_type, GetBrowserTypeString); |
184 return value; | 472 return result; |
185 } | 473 } |
186 | 474 |
187 std::unique_ptr<base::DictionaryValue> TabNavigationToValue( | 475 VisitorResult TabNavigationVisit(const sync_pb::TabNavigation& proto, |
188 const sync_pb::TabNavigation& proto) { | 476 const ResultType result_type) { |
189 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 477 VisitorResult result(0); |
478 if (result_type == CONVERT_TO_VALUE) | |
479 result.as_value.reset(new base::DictionaryValue()); | |
190 SET_STR(virtual_url); | 480 SET_STR(virtual_url); |
191 SET_STR(referrer); | 481 SET_STR(referrer); |
192 SET_STR(title); | 482 SET_STR(title); |
193 SET_ENUM(page_transition, GetPageTransitionString); | 483 SET_ENUM(page_transition, GetPageTransitionString); |
194 SET_ENUM(redirect_type, GetPageTransitionRedirectTypeString); | 484 SET_ENUM(redirect_type, GetPageTransitionRedirectTypeString); |
195 SET_INT32(unique_id); | 485 SET_INT32(unique_id); |
196 SET_INT64(timestamp_msec); | 486 SET_INT64(timestamp_msec); |
197 SET_BOOL(navigation_forward_back); | 487 SET_BOOL(navigation_forward_back); |
198 SET_BOOL(navigation_from_address_bar); | 488 SET_BOOL(navigation_from_address_bar); |
199 SET_BOOL(navigation_home_page); | 489 SET_BOOL(navigation_home_page); |
200 SET_BOOL(navigation_chain_start); | 490 SET_BOOL(navigation_chain_start); |
201 SET_BOOL(navigation_chain_end); | 491 SET_BOOL(navigation_chain_end); |
202 SET_INT64(global_id); | 492 SET_INT64(global_id); |
203 SET_STR(search_terms); | 493 SET_STR(search_terms); |
204 SET_STR(favicon_url); | 494 SET_STR(favicon_url); |
205 SET_ENUM(blocked_state, GetBlockedStateString); | 495 SET_ENUM(blocked_state, GetBlockedStateString); |
206 SET_STR_REP(content_pack_categories); | 496 SET_STR_REP(content_pack_categories); |
207 SET_INT32(http_status_code); | 497 SET_INT32(http_status_code); |
208 SET_INT32(obsolete_referrer_policy); | 498 SET_INT32(obsolete_referrer_policy); |
209 SET_BOOL(is_restored); | 499 SET_BOOL(is_restored); |
210 SET_REP(navigation_redirect, NavigationRedirectToValue); | 500 SET_REP(navigation_redirect, NavigationRedirectVisit); |
211 SET_STR(last_navigation_redirect_url); | 501 SET_STR(last_navigation_redirect_url); |
212 SET_INT32(correct_referrer_policy); | 502 SET_INT32(correct_referrer_policy); |
213 return value; | 503 return result; |
214 } | 504 } |
215 | 505 |
216 std::unique_ptr<base::DictionaryValue> NavigationRedirectToValue( | 506 VisitorResult NavigationRedirectVisit(const sync_pb::NavigationRedirect& proto, |
217 const sync_pb::NavigationRedirect& proto) { | 507 const ResultType result_type) { |
218 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 508 VisitorResult result(0); |
509 if (result_type == CONVERT_TO_VALUE) | |
510 result.as_value.reset(new base::DictionaryValue()); | |
219 SET_STR(url); | 511 SET_STR(url); |
220 return value; | 512 return result; |
221 } | 513 } |
222 | 514 |
223 std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( | 515 VisitorResult PasswordSpecificsDataVisit( |
224 const sync_pb::PasswordSpecificsData& proto) { | 516 const sync_pb::PasswordSpecificsData& proto, |
225 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 517 const ResultType result_type) { |
518 VisitorResult result(0); | |
519 if (result_type == CONVERT_TO_VALUE) | |
520 result.as_value.reset(new base::DictionaryValue()); | |
226 SET_INT32(scheme); | 521 SET_INT32(scheme); |
227 SET_STR(signon_realm); | 522 SET_STR(signon_realm); |
228 SET_STR(origin); | 523 SET_STR(origin); |
229 SET_STR(action); | 524 SET_STR(action); |
230 SET_STR(username_element); | 525 SET_STR(username_element); |
231 SET_STR(username_value); | 526 SET_STR(username_value); |
232 SET_STR(password_element); | 527 SET_STR(password_element); |
233 value->SetString("password_value", "<redacted>"); | 528 if (result_type == CONVERT_TO_VALUE) |
529 result.as_dict_value()->SetString("password_value", "<redacted>"); | |
234 SET_BOOL(ssl_valid); | 530 SET_BOOL(ssl_valid); |
235 SET_BOOL(preferred); | 531 SET_BOOL(preferred); |
236 SET_INT64(date_created); | 532 SET_INT64(date_created); |
237 SET_BOOL(blacklisted); | 533 SET_BOOL(blacklisted); |
238 SET_INT32(type); | 534 SET_INT32(type); |
239 SET_INT32(times_used); | 535 SET_INT32(times_used); |
240 SET_STR(display_name); | 536 SET_STR(display_name); |
241 SET_STR(avatar_url); | 537 SET_STR(avatar_url); |
242 SET_STR(federation_url); | 538 SET_STR(federation_url); |
243 return value; | 539 return result; |
244 } | 540 } |
245 | 541 |
246 std::unique_ptr<base::DictionaryValue> GlobalIdDirectiveToValue( | 542 VisitorResult GlobalIdDirectiveVisit(const sync_pb::GlobalIdDirective& proto, |
247 const sync_pb::GlobalIdDirective& proto) { | 543 const ResultType result_type) { |
248 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 544 VisitorResult result(0); |
545 if (result_type == CONVERT_TO_VALUE) | |
546 result.as_value.reset(new base::DictionaryValue()); | |
249 SET_INT64_REP(global_id); | 547 SET_INT64_REP(global_id); |
250 SET_INT64(start_time_usec); | 548 SET_INT64(start_time_usec); |
251 SET_INT64(end_time_usec); | 549 SET_INT64(end_time_usec); |
252 return value; | 550 return result; |
253 } | 551 } |
254 | 552 |
255 std::unique_ptr<base::DictionaryValue> TimeRangeDirectiveToValue( | 553 VisitorResult TimeRangeDirectiveVisit(const sync_pb::TimeRangeDirective& proto, |
256 const sync_pb::TimeRangeDirective& proto) { | 554 const ResultType result_type) { |
257 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 555 VisitorResult result(0); |
556 if (result_type == CONVERT_TO_VALUE) | |
557 result.as_value.reset(new base::DictionaryValue()); | |
258 SET_INT64(start_time_usec); | 558 SET_INT64(start_time_usec); |
259 SET_INT64(end_time_usec); | 559 SET_INT64(end_time_usec); |
260 return value; | 560 return result; |
261 } | 561 } |
262 | 562 |
263 std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue( | 563 VisitorResult AppListSpecificsVisit(const sync_pb::AppListSpecifics& proto, |
264 const sync_pb::AppListSpecifics& proto) { | 564 const ResultType result_type) { |
265 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 565 VisitorResult result(0); |
566 if (result_type == CONVERT_TO_VALUE) | |
567 result.as_value.reset(new base::DictionaryValue()); | |
266 SET_STR(item_id); | 568 SET_STR(item_id); |
267 SET_ENUM(item_type, GetAppListItemTypeString); | 569 SET_ENUM(item_type, GetAppListItemTypeString); |
268 SET_STR(item_name); | 570 SET_STR(item_name); |
269 SET_STR(parent_id); | 571 SET_STR(parent_id); |
270 SET_STR(item_ordinal); | 572 SET_STR(item_ordinal); |
271 SET_STR(item_pin_ordinal); | 573 SET_STR(item_pin_ordinal); |
272 | 574 |
273 return value; | 575 return result; |
274 } | 576 } |
275 | 577 |
276 std::unique_ptr<base::DictionaryValue> ArcPackageSpecificsToValue( | 578 VisitorResult ArcPackageSpecificsVisit( |
277 const sync_pb::ArcPackageSpecifics& proto) { | 579 const sync_pb::ArcPackageSpecifics& proto, |
278 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 580 const ResultType result_type) { |
581 VisitorResult result(0); | |
582 if (result_type == CONVERT_TO_VALUE) | |
583 result.as_value.reset(new base::DictionaryValue()); | |
279 SET_STR(package_name); | 584 SET_STR(package_name); |
280 SET_INT32(package_version); | 585 SET_INT32(package_version); |
281 SET_INT64(last_backup_android_id); | 586 SET_INT64(last_backup_android_id); |
282 SET_INT64(last_backup_time); | 587 SET_INT64(last_backup_time); |
283 | 588 |
284 return value; | 589 return result; |
285 } | 590 } |
286 | 591 |
287 std::unique_ptr<base::DictionaryValue> AppNotificationToValue( | 592 VisitorResult AppNotificationVisit(const sync_pb::AppNotification& proto, |
288 const sync_pb::AppNotification& proto) { | 593 const ResultType result_type) { |
289 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 594 VisitorResult result(0); |
595 if (result_type == CONVERT_TO_VALUE) | |
596 result.as_value.reset(new base::DictionaryValue()); | |
290 SET_STR(guid); | 597 SET_STR(guid); |
291 SET_STR(app_id); | 598 SET_STR(app_id); |
292 SET_INT64(creation_timestamp_ms); | 599 SET_INT64(creation_timestamp_ms); |
293 SET_STR(title); | 600 SET_STR(title); |
294 SET_STR(body_text); | 601 SET_STR(body_text); |
295 SET_STR(link_url); | 602 SET_STR(link_url); |
296 SET_STR(link_text); | 603 SET_STR(link_text); |
297 return value; | 604 return result; |
298 } | 605 } |
299 | 606 |
300 std::unique_ptr<base::DictionaryValue> AppSettingSpecificsToValue( | 607 VisitorResult AppSettingSpecificsVisit( |
301 const sync_pb::AppSettingSpecifics& proto) { | 608 const sync_pb::AppSettingSpecifics& proto, |
302 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 609 const ResultType result_type) { |
303 SET(extension_setting, ExtensionSettingSpecificsToValue); | 610 VisitorResult result(0); |
304 return value; | 611 if (result_type == CONVERT_TO_VALUE) |
612 result.as_value.reset(new base::DictionaryValue()); | |
613 SET(extension_setting, ExtensionSettingSpecificsVisit); | |
614 return result; | |
305 } | 615 } |
306 | 616 |
307 std::unique_ptr<base::DictionaryValue> LinkedAppIconInfoToValue( | 617 VisitorResult LinkedAppIconInfoVisit(const sync_pb::LinkedAppIconInfo& proto, |
308 const sync_pb::LinkedAppIconInfo& proto) { | 618 const ResultType result_type) { |
309 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 619 VisitorResult result(0); |
620 if (result_type == CONVERT_TO_VALUE) | |
621 result.as_value.reset(new base::DictionaryValue()); | |
310 SET_STR(url); | 622 SET_STR(url); |
311 SET_INT32(size); | 623 SET_INT32(size); |
312 return value; | 624 return result; |
313 } | 625 } |
314 | 626 |
315 std::unique_ptr<base::DictionaryValue> AppSpecificsToValue( | 627 VisitorResult AppSpecificsVisit(const sync_pb::AppSpecifics& proto, |
316 const sync_pb::AppSpecifics& proto) { | 628 const ResultType result_type) { |
317 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 629 VisitorResult result(0); |
318 SET(extension, ExtensionSpecificsToValue); | 630 if (result_type == CONVERT_TO_VALUE) |
319 SET(notification_settings, AppSettingsToValue); | 631 result.as_value.reset(new base::DictionaryValue()); |
632 SET(extension, ExtensionSpecificsVisit); | |
633 SET(notification_settings, AppSettingsVisit); | |
320 SET_STR(app_launch_ordinal); | 634 SET_STR(app_launch_ordinal); |
321 SET_STR(page_ordinal); | 635 SET_STR(page_ordinal); |
322 SET_ENUM(launch_type, GetLaunchTypeString); | 636 SET_ENUM(launch_type, GetLaunchTypeString); |
323 SET_STR(bookmark_app_url); | 637 SET_STR(bookmark_app_url); |
324 SET_STR(bookmark_app_description); | 638 SET_STR(bookmark_app_description); |
325 SET_STR(bookmark_app_icon_color); | 639 SET_STR(bookmark_app_icon_color); |
326 SET_REP(linked_app_icons, LinkedAppIconInfoToValue); | 640 SET_REP(linked_app_icons, LinkedAppIconInfoVisit); |
327 | 641 |
328 return value; | 642 return result; |
329 } | 643 } |
330 | 644 |
331 std::unique_ptr<base::DictionaryValue> AutofillSpecificsToValue( | 645 VisitorResult AutofillSpecificsVisit(const sync_pb::AutofillSpecifics& proto, |
332 const sync_pb::AutofillSpecifics& proto) { | 646 const ResultType result_type) { |
333 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 647 VisitorResult result(0); |
648 if (result_type == CONVERT_TO_VALUE) | |
649 result.as_value.reset(new base::DictionaryValue()); | |
334 SET_STR(name); | 650 SET_STR(name); |
335 SET_STR(value); | 651 SET_STR(value); |
336 SET_INT64_REP(usage_timestamp); | 652 SET_INT64_REP(usage_timestamp); |
337 SET(profile, AutofillProfileSpecificsToValue); | 653 SET(profile, AutofillProfileSpecificsVisit); |
338 return value; | 654 return result; |
339 } | 655 } |
340 | 656 |
341 std::unique_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( | 657 VisitorResult AutofillProfileSpecificsVisit( |
342 const sync_pb::AutofillProfileSpecifics& proto) { | 658 const sync_pb::AutofillProfileSpecifics& proto, |
343 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 659 const ResultType result_type) { |
660 VisitorResult result(0); | |
661 if (result_type == CONVERT_TO_VALUE) | |
662 result.as_value.reset(new base::DictionaryValue()); | |
344 SET_STR(guid); | 663 SET_STR(guid); |
345 SET_STR(origin); | 664 SET_STR(origin); |
346 SET_INT64(use_count); | 665 SET_INT64(use_count); |
347 SET_INT64(use_date); | 666 SET_INT64(use_date); |
348 | 667 |
349 SET_STR_REP(name_first); | 668 SET_STR_REP(name_first); |
350 SET_STR_REP(name_middle); | 669 SET_STR_REP(name_middle); |
351 SET_STR_REP(name_last); | 670 SET_STR_REP(name_last); |
352 SET_STR_REP(name_full); | 671 SET_STR_REP(name_full); |
353 SET_STR_REP(email_address); | 672 SET_STR_REP(email_address); |
354 SET_STR(company_name); | 673 SET_STR(company_name); |
355 | 674 |
356 SET_STR(address_home_line1); | 675 SET_STR(address_home_line1); |
357 SET_STR(address_home_line2); | 676 SET_STR(address_home_line2); |
358 SET_STR(address_home_city); | 677 SET_STR(address_home_city); |
359 SET_STR(address_home_state); | 678 SET_STR(address_home_state); |
360 SET_STR(address_home_zip); | 679 SET_STR(address_home_zip); |
361 SET_STR(address_home_country); | 680 SET_STR(address_home_country); |
362 | 681 |
363 SET_STR(address_home_street_address); | 682 SET_STR(address_home_street_address); |
364 SET_STR(address_home_sorting_code); | 683 SET_STR(address_home_sorting_code); |
365 SET_STR(address_home_dependent_locality); | 684 SET_STR(address_home_dependent_locality); |
366 SET_STR(address_home_language_code); | 685 SET_STR(address_home_language_code); |
367 | 686 |
368 SET_STR_REP(phone_home_whole_number); | 687 SET_STR_REP(phone_home_whole_number); |
369 return value; | 688 return result; |
370 } | 689 } |
371 | 690 |
372 std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue( | 691 VisitorResult WalletMetadataSpecificsVisit( |
373 const sync_pb::WalletMetadataSpecifics& proto) { | 692 const sync_pb::WalletMetadataSpecifics& proto, |
374 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 693 const ResultType result_type) { |
694 VisitorResult result(0); | |
695 if (result_type == CONVERT_TO_VALUE) | |
696 result.as_value.reset(new base::DictionaryValue()); | |
375 SET_ENUM(type, GetWalletMetadataTypeString); | 697 SET_ENUM(type, GetWalletMetadataTypeString); |
376 SET_STR(id); | 698 SET_STR(id); |
377 SET_INT64(use_count); | 699 SET_INT64(use_count); |
378 SET_INT64(use_date); | 700 SET_INT64(use_date); |
379 return value; | 701 return result; |
380 } | 702 } |
381 | 703 |
382 std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( | 704 VisitorResult AutofillWalletSpecificsVisit( |
383 const sync_pb::AutofillWalletSpecifics& proto) { | 705 const sync_pb::AutofillWalletSpecifics& proto, |
384 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 706 const ResultType result_type) { |
707 VisitorResult result(0); | |
708 if (result_type == CONVERT_TO_VALUE) | |
709 result.as_value.reset(new base::DictionaryValue()); | |
385 | 710 |
386 SET_ENUM(type, GetWalletInfoTypeString); | 711 SET_ENUM(type, GetWalletInfoTypeString); |
387 if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { | 712 if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { |
388 value->Set("masked_card", | 713 SET_WITH_EXPR(masked_card, |
389 WalletMaskedCreditCardToValue(proto.masked_card())); | 714 WalletMaskedCreditCardVisit(proto.masked_card(), result_type), |
715 sizeof(sync_pb::WalletMaskedCreditCard)); | |
390 } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) { | 716 } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) { |
391 value->Set("address", | 717 SET_WITH_EXPR(address, |
392 WalletPostalAddressToValue(proto.address())); | 718 WalletPostalAddressVisit(proto.address(), result_type), |
719 sizeof(sync_pb::WalletPostalAddress)); | |
393 } | 720 } |
394 return value; | 721 return result; |
395 } | 722 } |
396 | 723 |
397 std::unique_ptr<base::DictionaryValue> MetaInfoToValue( | 724 VisitorResult MetaInfoVisit(const sync_pb::MetaInfo& proto, |
398 const sync_pb::MetaInfo& proto) { | 725 const ResultType result_type) { |
399 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 726 VisitorResult result(0); |
727 if (result_type == CONVERT_TO_VALUE) | |
728 result.as_value.reset(new base::DictionaryValue()); | |
400 SET_STR(key); | 729 SET_STR(key); |
401 SET_STR(value); | 730 SET_STR(value); |
402 return value; | 731 return result; |
403 } | 732 } |
404 | 733 |
405 std::unique_ptr<base::DictionaryValue> BookmarkSpecificsToValue( | 734 VisitorResult BookmarkSpecificsVisit(const sync_pb::BookmarkSpecifics& proto, |
406 const sync_pb::BookmarkSpecifics& proto) { | 735 const ResultType result_type) { |
407 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 736 VisitorResult result(0); |
737 if (result_type == CONVERT_TO_VALUE) | |
738 result.as_value.reset(new base::DictionaryValue()); | |
408 SET_STR(url); | 739 SET_STR(url); |
409 SET_BYTES(favicon); | 740 SET_BYTES(favicon); |
410 SET_STR(title); | 741 SET_STR(title); |
411 SET_INT64(creation_time_us); | 742 SET_INT64(creation_time_us); |
412 SET_STR(icon_url); | 743 SET_STR(icon_url); |
413 SET_REP(meta_info, &MetaInfoToValue); | 744 SET_REP(meta_info, &MetaInfoVisit); |
414 return value; | 745 return result; |
415 } | 746 } |
416 | 747 |
417 std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue( | 748 VisitorResult DeviceInfoSpecificsVisit( |
418 const sync_pb::DeviceInfoSpecifics& proto) { | 749 const sync_pb::DeviceInfoSpecifics& proto, |
419 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 750 const ResultType result_type) { |
751 VisitorResult result(0); | |
752 if (result_type == CONVERT_TO_VALUE) | |
753 result.as_value.reset(new base::DictionaryValue()); | |
420 SET_STR(cache_guid); | 754 SET_STR(cache_guid); |
421 SET_STR(client_name); | 755 SET_STR(client_name); |
422 SET_ENUM(device_type, GetDeviceTypeString); | 756 SET_ENUM(device_type, GetDeviceTypeString); |
423 SET_STR(sync_user_agent); | 757 SET_STR(sync_user_agent); |
424 SET_STR(chrome_version); | 758 SET_STR(chrome_version); |
425 SET_STR(signin_scoped_device_id); | 759 SET_STR(signin_scoped_device_id); |
426 return value; | 760 return result; |
427 } | 761 } |
428 | 762 |
429 std::unique_ptr<base::DictionaryValue> DictionarySpecificsToValue( | 763 VisitorResult DictionarySpecificsVisit( |
430 const sync_pb::DictionarySpecifics& proto) { | 764 const sync_pb::DictionarySpecifics& proto, |
431 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 765 const ResultType result_type) { |
766 VisitorResult result(0); | |
767 if (result_type == CONVERT_TO_VALUE) | |
768 result.as_value.reset(new base::DictionaryValue()); | |
432 SET_STR(word); | 769 SET_STR(word); |
433 return value; | 770 return result; |
434 } | 771 } |
435 | 772 |
436 namespace { | 773 namespace { |
437 | 774 |
438 std::unique_ptr<base::DictionaryValue> FaviconSyncFlagsToValue( | 775 VisitorResult FaviconSyncFlagsVisit(const sync_pb::FaviconSyncFlags& proto, |
439 const sync_pb::FaviconSyncFlags& proto) { | 776 const ResultType result_type) { |
440 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 777 VisitorResult result(0); |
778 if (result_type == CONVERT_TO_VALUE) | |
779 result.as_value.reset(new base::DictionaryValue()); | |
441 SET_BOOL(enabled); | 780 SET_BOOL(enabled); |
442 SET_INT32(favicon_sync_limit); | 781 SET_INT32(favicon_sync_limit); |
443 return value; | 782 return result; |
444 } | 783 } |
445 | 784 |
446 } // namespace | 785 } // namespace |
447 | 786 |
448 std::unique_ptr<base::DictionaryValue> ExperimentsSpecificsToValue( | 787 VisitorResult ExperimentsSpecificsVisit( |
449 const sync_pb::ExperimentsSpecifics& proto) { | 788 const sync_pb::ExperimentsSpecifics& proto, |
450 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 789 const ResultType result_type) { |
790 VisitorResult result(0); | |
791 if (result_type == CONVERT_TO_VALUE) | |
792 result.as_value.reset(new base::DictionaryValue()); | |
451 SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption); | 793 SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption); |
452 SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives); | 794 SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives); |
453 SET_EXPERIMENT_ENABLED_FIELD(autofill_culling); | 795 SET_EXPERIMENT_ENABLED_FIELD(autofill_culling); |
454 SET_EXPERIMENT_ENABLED_FIELD(pre_commit_update_avoidance); | 796 SET_EXPERIMENT_ENABLED_FIELD(pre_commit_update_avoidance); |
455 SET(favicon_sync, FaviconSyncFlagsToValue); | 797 SET(favicon_sync, FaviconSyncFlagsVisit); |
456 SET_EXPERIMENT_ENABLED_FIELD(gcm_channel); | 798 SET_EXPERIMENT_ENABLED_FIELD(gcm_channel); |
457 SET_EXPERIMENT_ENABLED_FIELD(gcm_invalidations); | 799 SET_EXPERIMENT_ENABLED_FIELD(gcm_invalidations); |
458 return value; | 800 return result; |
459 } | 801 } |
460 | 802 |
461 std::unique_ptr<base::DictionaryValue> ExtensionSettingSpecificsToValue( | 803 VisitorResult ExtensionSettingSpecificsVisit( |
462 const sync_pb::ExtensionSettingSpecifics& proto) { | 804 const sync_pb::ExtensionSettingSpecifics& proto, |
463 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 805 const ResultType result_type) { |
806 VisitorResult result(0); | |
807 if (result_type == CONVERT_TO_VALUE) | |
808 result.as_value.reset(new base::DictionaryValue()); | |
464 SET_STR(extension_id); | 809 SET_STR(extension_id); |
465 SET_STR(key); | 810 SET_STR(key); |
466 SET_STR(value); | 811 SET_STR(value); |
467 return value; | 812 return result; |
468 } | 813 } |
469 | 814 |
470 std::unique_ptr<base::DictionaryValue> ExtensionSpecificsToValue( | 815 VisitorResult ExtensionSpecificsVisit(const sync_pb::ExtensionSpecifics& proto, |
471 const sync_pb::ExtensionSpecifics& proto) { | 816 const ResultType result_type) { |
472 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 817 VisitorResult result(0); |
818 if (result_type == CONVERT_TO_VALUE) | |
819 result.as_value.reset(new base::DictionaryValue()); | |
473 SET_STR(id); | 820 SET_STR(id); |
474 SET_STR(version); | 821 SET_STR(version); |
475 SET_STR(update_url); | 822 SET_STR(update_url); |
476 SET_BOOL(enabled); | 823 SET_BOOL(enabled); |
477 SET_BOOL(incognito_enabled); | 824 SET_BOOL(incognito_enabled); |
478 SET_STR(name); | 825 SET_STR(name); |
479 SET_BOOL(remote_install); | 826 SET_BOOL(remote_install); |
480 SET_BOOL(installed_by_custodian); | 827 SET_BOOL(installed_by_custodian); |
481 SET_BOOL(all_urls_enabled); | 828 SET_BOOL(all_urls_enabled); |
482 SET_INT32(disable_reasons); | 829 SET_INT32(disable_reasons); |
483 return value; | 830 return result; |
484 } | 831 } |
485 | 832 |
486 namespace { | 833 namespace { |
487 std::unique_ptr<base::DictionaryValue> FaviconDataToValue( | 834 VisitorResult FaviconDataVisit(const sync_pb::FaviconData& proto, |
488 const sync_pb::FaviconData& proto) { | 835 const ResultType result_type) { |
489 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 836 VisitorResult result(0); |
837 if (result_type == CONVERT_TO_VALUE) | |
838 result.as_value.reset(new base::DictionaryValue()); | |
490 SET_BYTES(favicon); | 839 SET_BYTES(favicon); |
491 SET_INT32(width); | 840 SET_INT32(width); |
492 SET_INT32(height); | 841 SET_INT32(height); |
493 return value; | 842 return result; |
494 } | 843 } |
495 } // namespace | 844 } // namespace |
496 | 845 |
497 std::unique_ptr<base::DictionaryValue> FaviconImageSpecificsToValue( | 846 VisitorResult FaviconImageSpecificsVisit( |
498 const sync_pb::FaviconImageSpecifics& proto) { | 847 const sync_pb::FaviconImageSpecifics& proto, |
499 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 848 const ResultType result_type) { |
849 VisitorResult result(0); | |
850 if (result_type == CONVERT_TO_VALUE) | |
851 result.as_value.reset(new base::DictionaryValue()); | |
500 SET_STR(favicon_url); | 852 SET_STR(favicon_url); |
501 SET(favicon_web, FaviconDataToValue); | 853 SET(favicon_web, FaviconDataVisit); |
502 SET(favicon_web_32, FaviconDataToValue); | 854 SET(favicon_web_32, FaviconDataVisit); |
503 SET(favicon_touch_64, FaviconDataToValue); | 855 SET(favicon_touch_64, FaviconDataVisit); |
504 SET(favicon_touch_precomposed_64, FaviconDataToValue); | 856 SET(favicon_touch_precomposed_64, FaviconDataVisit); |
505 return value; | 857 return result; |
506 } | 858 } |
507 | 859 |
508 std::unique_ptr<base::DictionaryValue> FaviconTrackingSpecificsToValue( | 860 VisitorResult FaviconTrackingSpecificsVisit( |
509 const sync_pb::FaviconTrackingSpecifics& proto) { | 861 const sync_pb::FaviconTrackingSpecifics& proto, |
510 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 862 const ResultType result_type) { |
863 VisitorResult result(0); | |
864 if (result_type == CONVERT_TO_VALUE) | |
865 result.as_value.reset(new base::DictionaryValue()); | |
511 SET_STR(favicon_url); | 866 SET_STR(favicon_url); |
512 SET_INT64(last_visit_time_ms) | 867 SET_INT64(last_visit_time_ms) |
513 SET_BOOL(is_bookmarked); | 868 SET_BOOL(is_bookmarked); |
514 return value; | 869 return result; |
515 } | 870 } |
516 | 871 |
517 std::unique_ptr<base::DictionaryValue> HistoryDeleteDirectiveSpecificsToValue( | 872 VisitorResult HistoryDeleteDirectiveSpecificsVisit( |
518 const sync_pb::HistoryDeleteDirectiveSpecifics& proto) { | 873 const sync_pb::HistoryDeleteDirectiveSpecifics& proto, |
519 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 874 const ResultType result_type) { |
520 SET(global_id_directive, GlobalIdDirectiveToValue); | 875 VisitorResult result(0); |
521 SET(time_range_directive, TimeRangeDirectiveToValue); | 876 if (result_type == CONVERT_TO_VALUE) |
522 return value; | 877 result.as_value.reset(new base::DictionaryValue()); |
878 SET(global_id_directive, GlobalIdDirectiveVisit); | |
879 SET(time_range_directive, TimeRangeDirectiveVisit); | |
880 return result; | |
523 } | 881 } |
524 | 882 |
525 std::unique_ptr<base::DictionaryValue> ManagedUserSettingSpecificsToValue( | 883 VisitorResult ManagedUserSettingSpecificsVisit( |
526 const sync_pb::ManagedUserSettingSpecifics& proto) { | 884 const sync_pb::ManagedUserSettingSpecifics& proto, |
527 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 885 const ResultType result_type) { |
886 VisitorResult result(0); | |
887 if (result_type == CONVERT_TO_VALUE) | |
888 result.as_value.reset(new base::DictionaryValue()); | |
528 SET_STR(name); | 889 SET_STR(name); |
529 SET_STR(value); | 890 SET_STR(value); |
530 return value; | 891 return result; |
531 } | 892 } |
532 | 893 |
533 std::unique_ptr<base::DictionaryValue> ManagedUserSpecificsToValue( | 894 VisitorResult ManagedUserSpecificsVisit( |
534 const sync_pb::ManagedUserSpecifics& proto) { | 895 const sync_pb::ManagedUserSpecifics& proto, |
535 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 896 const ResultType result_type) { |
897 VisitorResult result(0); | |
898 if (result_type == CONVERT_TO_VALUE) | |
899 result.as_value.reset(new base::DictionaryValue()); | |
536 SET_STR(id); | 900 SET_STR(id); |
537 SET_STR(name); | 901 SET_STR(name); |
538 SET_BOOL(acknowledged); | 902 SET_BOOL(acknowledged); |
539 SET_STR(master_key); | 903 SET_STR(master_key); |
540 SET_STR(chrome_avatar); | 904 SET_STR(chrome_avatar); |
541 SET_STR(chromeos_avatar); | 905 SET_STR(chromeos_avatar); |
542 return value; | 906 return result; |
543 } | 907 } |
544 | 908 |
545 std::unique_ptr<base::DictionaryValue> ManagedUserSharedSettingSpecificsToValue( | 909 VisitorResult ManagedUserSharedSettingSpecificsVisit( |
546 const sync_pb::ManagedUserSharedSettingSpecifics& proto) { | 910 const sync_pb::ManagedUserSharedSettingSpecifics& proto, |
547 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 911 const ResultType result_type) { |
912 VisitorResult result(0); | |
913 if (result_type == CONVERT_TO_VALUE) | |
914 result.as_value.reset(new base::DictionaryValue()); | |
548 SET_STR(mu_id); | 915 SET_STR(mu_id); |
549 SET_STR(key); | 916 SET_STR(key); |
550 SET_STR(value); | 917 SET_STR(value); |
551 SET_BOOL(acknowledged); | 918 SET_BOOL(acknowledged); |
552 return value; | 919 return result; |
553 } | 920 } |
554 | 921 |
555 std::unique_ptr<base::DictionaryValue> ManagedUserWhitelistSpecificsToValue( | 922 VisitorResult ManagedUserWhitelistSpecificsVisit( |
556 const sync_pb::ManagedUserWhitelistSpecifics& proto) { | 923 const sync_pb::ManagedUserWhitelistSpecifics& proto, |
557 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 924 const ResultType result_type) { |
925 VisitorResult result(0); | |
926 if (result_type == CONVERT_TO_VALUE) | |
927 result.as_value.reset(new base::DictionaryValue()); | |
558 SET_STR(id); | 928 SET_STR(id); |
559 SET_STR(name); | 929 SET_STR(name); |
560 return value; | 930 return result; |
561 } | 931 } |
562 | 932 |
563 std::unique_ptr<base::DictionaryValue> NigoriSpecificsToValue( | 933 VisitorResult NigoriSpecificsVisit(const sync_pb::NigoriSpecifics& proto, |
564 const sync_pb::NigoriSpecifics& proto) { | 934 const ResultType result_type) { |
565 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 935 VisitorResult result(0); |
566 SET(encryption_keybag, EncryptedDataToValue); | 936 if (result_type == CONVERT_TO_VALUE) |
937 result.as_value.reset(new base::DictionaryValue()); | |
938 SET(encryption_keybag, EncryptedDataVisit); | |
567 SET_BOOL(keybag_is_frozen); | 939 SET_BOOL(keybag_is_frozen); |
568 SET_BOOL(encrypt_bookmarks); | 940 SET_BOOL(encrypt_bookmarks); |
569 SET_BOOL(encrypt_preferences); | 941 SET_BOOL(encrypt_preferences); |
570 SET_BOOL(encrypt_autofill_profile); | 942 SET_BOOL(encrypt_autofill_profile); |
571 SET_BOOL(encrypt_autofill); | 943 SET_BOOL(encrypt_autofill); |
572 SET_BOOL(encrypt_themes); | 944 SET_BOOL(encrypt_themes); |
573 SET_BOOL(encrypt_typed_urls); | 945 SET_BOOL(encrypt_typed_urls); |
574 SET_BOOL(encrypt_extension_settings); | 946 SET_BOOL(encrypt_extension_settings); |
575 SET_BOOL(encrypt_extensions); | 947 SET_BOOL(encrypt_extensions); |
576 SET_BOOL(encrypt_sessions); | 948 SET_BOOL(encrypt_sessions); |
577 SET_BOOL(encrypt_app_settings); | 949 SET_BOOL(encrypt_app_settings); |
578 SET_BOOL(encrypt_apps); | 950 SET_BOOL(encrypt_apps); |
579 SET_BOOL(encrypt_search_engines); | 951 SET_BOOL(encrypt_search_engines); |
580 SET_BOOL(encrypt_dictionary); | 952 SET_BOOL(encrypt_dictionary); |
581 SET_BOOL(encrypt_articles); | 953 SET_BOOL(encrypt_articles); |
582 SET_BOOL(encrypt_app_list); | 954 SET_BOOL(encrypt_app_list); |
583 SET_BOOL(encrypt_arc_package); | 955 SET_BOOL(encrypt_arc_package); |
584 SET_BOOL(encrypt_everything); | 956 SET_BOOL(encrypt_everything); |
585 SET_BOOL(server_only_was_missing_keystore_migration_time); | 957 SET_BOOL(server_only_was_missing_keystore_migration_time); |
586 SET_BOOL(sync_tab_favicons); | 958 SET_BOOL(sync_tab_favicons); |
587 SET_ENUM(passphrase_type, PassphraseTypeString); | 959 SET_ENUM(passphrase_type, PassphraseTypeString); |
588 SET(keystore_decryptor_token, EncryptedDataToValue); | 960 SET(keystore_decryptor_token, EncryptedDataVisit); |
589 SET_INT64(keystore_migration_time); | 961 SET_INT64(keystore_migration_time); |
590 SET_INT64(custom_passphrase_time); | 962 SET_INT64(custom_passphrase_time); |
591 return value; | 963 return result; |
592 } | 964 } |
593 | 965 |
594 std::unique_ptr<base::DictionaryValue> ArticlePageToValue( | 966 VisitorResult ArticlePageVisit(const sync_pb::ArticlePage& proto, |
595 const sync_pb::ArticlePage& proto) { | 967 const ResultType result_type) { |
596 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 968 VisitorResult result(0); |
969 if (result_type == CONVERT_TO_VALUE) | |
970 result.as_value.reset(new base::DictionaryValue()); | |
597 SET_STR(url); | 971 SET_STR(url); |
598 return value; | 972 return result; |
599 } | 973 } |
600 | 974 |
601 std::unique_ptr<base::DictionaryValue> ArticleSpecificsToValue( | 975 VisitorResult ArticleSpecificsVisit(const sync_pb::ArticleSpecifics& proto, |
602 const sync_pb::ArticleSpecifics& proto) { | 976 const ResultType result_type) { |
603 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 977 VisitorResult result(0); |
978 if (result_type == CONVERT_TO_VALUE) | |
979 result.as_value.reset(new base::DictionaryValue()); | |
604 SET_STR(entry_id); | 980 SET_STR(entry_id); |
605 SET_STR(title); | 981 SET_STR(title); |
606 SET_REP(pages, ArticlePageToValue); | 982 SET_REP(pages, ArticlePageVisit); |
607 return value; | 983 return result; |
608 } | 984 } |
609 | 985 |
610 std::unique_ptr<base::DictionaryValue> PasswordSpecificsToValue( | 986 VisitorResult PasswordSpecificsVisit(const sync_pb::PasswordSpecifics& proto, |
611 const sync_pb::PasswordSpecifics& proto) { | 987 const ResultType result_type) { |
612 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 988 VisitorResult result(0); |
613 SET(encrypted, EncryptedDataToValue); | 989 if (result_type == CONVERT_TO_VALUE) |
614 return value; | 990 result.as_value.reset(new base::DictionaryValue()); |
991 SET(encrypted, EncryptedDataVisit); | |
992 return result; | |
615 } | 993 } |
616 | 994 |
617 std::unique_ptr<base::DictionaryValue> PreferenceSpecificsToValue( | 995 VisitorResult PreferenceSpecificsVisit( |
618 const sync_pb::PreferenceSpecifics& proto) { | 996 const sync_pb::PreferenceSpecifics& proto, |
619 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 997 const ResultType result_type) { |
998 VisitorResult result(0); | |
999 if (result_type == CONVERT_TO_VALUE) | |
1000 result.as_value.reset(new base::DictionaryValue()); | |
620 SET_STR(name); | 1001 SET_STR(name); |
621 SET_STR(value); | 1002 SET_STR(value); |
622 return value; | 1003 return result; |
623 } | 1004 } |
624 | 1005 |
625 std::unique_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue( | 1006 VisitorResult PriorityPreferenceSpecificsVisit( |
626 const sync_pb::PriorityPreferenceSpecifics& specifics) { | 1007 const sync_pb::PriorityPreferenceSpecifics& specifics, |
627 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1008 const ResultType result_type) { |
628 SET_FIELD(preference, PreferenceSpecificsToValue); | 1009 VisitorResult result(0); |
629 return value; | 1010 if (result_type == CONVERT_TO_VALUE) |
1011 result.as_value.reset(new base::DictionaryValue()); | |
1012 SET_FIELD(preference, PreferenceSpecificsVisit); | |
1013 return result; | |
630 } | 1014 } |
631 | 1015 |
632 std::unique_ptr<base::DictionaryValue> | 1016 VisitorResult SyncedNotificationAppInfoSpecificsVisit( |
633 SyncedNotificationAppInfoSpecificsToValue( | 1017 const sync_pb::SyncedNotificationAppInfoSpecifics& proto, |
634 const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { | 1018 const ResultType result_type) { |
635 return base::WrapUnique(new base::DictionaryValue()); | 1019 if (result_type == MEMORY_USAGE) |
1020 return VisitorResult(sizeof(sync_pb::SyncedNotificationAppInfoSpecifics)); | |
1021 return VisitorResult(base::WrapUnique(new base::DictionaryValue())); | |
636 } | 1022 } |
637 | 1023 |
638 std::unique_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue( | 1024 VisitorResult SyncedNotificationSpecificsVisit( |
639 const sync_pb::SyncedNotificationSpecifics& proto) { | 1025 const sync_pb::SyncedNotificationSpecifics& proto, |
640 return base::WrapUnique(new base::DictionaryValue()); | 1026 const ResultType result_type) { |
1027 if (result_type == MEMORY_USAGE) | |
1028 return VisitorResult(sizeof(sync_pb::SyncedNotificationSpecifics)); | |
1029 return VisitorResult(base::WrapUnique(new base::DictionaryValue())); | |
641 } | 1030 } |
642 | 1031 |
643 std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( | 1032 VisitorResult SearchEngineSpecificsVisit( |
644 const sync_pb::SearchEngineSpecifics& proto) { | 1033 const sync_pb::SearchEngineSpecifics& proto, |
645 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1034 const ResultType result_type) { |
1035 VisitorResult result(0); | |
1036 if (result_type == CONVERT_TO_VALUE) | |
1037 result.as_value.reset(new base::DictionaryValue()); | |
646 SET_STR(short_name); | 1038 SET_STR(short_name); |
647 SET_STR(keyword); | 1039 SET_STR(keyword); |
648 SET_STR(favicon_url); | 1040 SET_STR(favicon_url); |
649 SET_STR(url); | 1041 SET_STR(url); |
650 SET_BOOL(safe_for_autoreplace); | 1042 SET_BOOL(safe_for_autoreplace); |
651 SET_STR(originating_url); | 1043 SET_STR(originating_url); |
652 SET_INT64(date_created); | 1044 SET_INT64(date_created); |
653 SET_STR(input_encodings); | 1045 SET_STR(input_encodings); |
654 SET_BOOL(show_in_default_list); | 1046 SET_BOOL(show_in_default_list); |
655 SET_STR(suggestions_url); | 1047 SET_STR(suggestions_url); |
656 SET_INT32(prepopulate_id); | 1048 SET_INT32(prepopulate_id); |
657 SET_BOOL(autogenerate_keyword); | 1049 SET_BOOL(autogenerate_keyword); |
658 SET_STR(instant_url); | 1050 SET_STR(instant_url); |
659 SET_INT64(last_modified); | 1051 SET_INT64(last_modified); |
660 SET_STR(sync_guid); | 1052 SET_STR(sync_guid); |
661 SET_STR_REP(alternate_urls); | 1053 SET_STR_REP(alternate_urls); |
662 SET_STR(search_terms_replacement_key); | 1054 SET_STR(search_terms_replacement_key); |
663 SET_STR(image_url); | 1055 SET_STR(image_url); |
664 SET_STR(search_url_post_params); | 1056 SET_STR(search_url_post_params); |
665 SET_STR(suggestions_url_post_params); | 1057 SET_STR(suggestions_url_post_params); |
666 SET_STR(instant_url_post_params); | 1058 SET_STR(instant_url_post_params); |
667 SET_STR(image_url_post_params); | 1059 SET_STR(image_url_post_params); |
668 SET_STR(new_tab_url); | 1060 SET_STR(new_tab_url); |
669 return value; | 1061 return result; |
670 } | 1062 } |
671 | 1063 |
672 std::unique_ptr<base::DictionaryValue> SessionSpecificsToValue( | 1064 VisitorResult SessionSpecificsVisit(const sync_pb::SessionSpecifics& proto, |
673 const sync_pb::SessionSpecifics& proto) { | 1065 const ResultType result_type) { |
674 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1066 VisitorResult result(0); |
1067 if (result_type == CONVERT_TO_VALUE) | |
1068 result.as_value.reset(new base::DictionaryValue()); | |
675 SET_STR(session_tag); | 1069 SET_STR(session_tag); |
676 SET(header, SessionHeaderToValue); | 1070 SET(header, SessionHeaderVisit); |
677 SET(tab, SessionTabToValue); | 1071 SET(tab, SessionTabVisit); |
678 SET_INT32(tab_node_id); | 1072 SET_INT32(tab_node_id); |
679 return value; | 1073 return result; |
680 } | 1074 } |
681 | 1075 |
682 std::unique_ptr<base::DictionaryValue> ThemeSpecificsToValue( | 1076 VisitorResult ThemeSpecificsVisit(const sync_pb::ThemeSpecifics& proto, |
683 const sync_pb::ThemeSpecifics& proto) { | 1077 const ResultType result_type) { |
684 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1078 VisitorResult result(0); |
1079 if (result_type == CONVERT_TO_VALUE) | |
1080 result.as_value.reset(new base::DictionaryValue()); | |
685 SET_BOOL(use_custom_theme); | 1081 SET_BOOL(use_custom_theme); |
686 SET_BOOL(use_system_theme_by_default); | 1082 SET_BOOL(use_system_theme_by_default); |
687 SET_STR(custom_theme_name); | 1083 SET_STR(custom_theme_name); |
688 SET_STR(custom_theme_id); | 1084 SET_STR(custom_theme_id); |
689 SET_STR(custom_theme_update_url); | 1085 SET_STR(custom_theme_update_url); |
690 return value; | 1086 return result; |
691 } | 1087 } |
692 | 1088 |
693 std::unique_ptr<base::DictionaryValue> TypedUrlSpecificsToValue( | 1089 VisitorResult TypedUrlSpecificsVisit(const sync_pb::TypedUrlSpecifics& proto, |
694 const sync_pb::TypedUrlSpecifics& proto) { | 1090 const ResultType result_type) { |
695 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1091 VisitorResult result(0); |
1092 if (result_type == CONVERT_TO_VALUE) | |
1093 result.as_value.reset(new base::DictionaryValue()); | |
696 SET_STR(url); | 1094 SET_STR(url); |
697 SET_STR(title); | 1095 SET_STR(title); |
698 SET_BOOL(hidden); | 1096 SET_BOOL(hidden); |
699 SET_INT64_REP(visits); | 1097 SET_INT64_REP(visits); |
700 SET_INT32_REP(visit_transitions); | 1098 SET_INT32_REP(visit_transitions); |
701 return value; | 1099 return result; |
702 } | 1100 } |
703 | 1101 |
704 std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( | 1102 VisitorResult WalletMaskedCreditCardVisit( |
705 const sync_pb::WalletMaskedCreditCard& proto) { | 1103 const sync_pb::WalletMaskedCreditCard& proto, |
706 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1104 const ResultType result_type) { |
1105 VisitorResult result(0); | |
1106 if (result_type == CONVERT_TO_VALUE) | |
1107 result.as_value.reset(new base::DictionaryValue()); | |
707 SET_STR(id); | 1108 SET_STR(id); |
708 SET_ENUM(status, GetWalletCardStatusString); | 1109 SET_ENUM(status, GetWalletCardStatusString); |
709 SET_STR(name_on_card); | 1110 SET_STR(name_on_card); |
710 SET_ENUM(type, GetWalletCardTypeString); | 1111 SET_ENUM(type, GetWalletCardTypeString); |
711 SET_STR(last_four); | 1112 SET_STR(last_four); |
712 SET_INT32(exp_month); | 1113 SET_INT32(exp_month); |
713 SET_INT32(exp_year); | 1114 SET_INT32(exp_year); |
714 SET_STR(billing_address_id); | 1115 SET_STR(billing_address_id); |
715 return value; | 1116 return result; |
716 } | 1117 } |
717 | 1118 |
718 std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue( | 1119 VisitorResult WalletPostalAddressVisit( |
719 const sync_pb::WalletPostalAddress& proto) { | 1120 const sync_pb::WalletPostalAddress& proto, |
720 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1121 const ResultType result_type) { |
1122 VisitorResult result(0); | |
1123 if (result_type == CONVERT_TO_VALUE) | |
1124 result.as_value.reset(new base::DictionaryValue()); | |
721 SET_STR(id); | 1125 SET_STR(id); |
722 SET_STR(recipient_name); | 1126 SET_STR(recipient_name); |
723 SET_STR(company_name); | 1127 SET_STR(company_name); |
724 SET_STR_REP(street_address); | 1128 SET_STR_REP(street_address); |
725 SET_STR(address_1); | 1129 SET_STR(address_1); |
726 SET_STR(address_2); | 1130 SET_STR(address_2); |
727 SET_STR(address_3); | 1131 SET_STR(address_3); |
728 SET_STR(address_4); | 1132 SET_STR(address_4); |
729 SET_STR(postal_code); | 1133 SET_STR(postal_code); |
730 SET_STR(sorting_code); | 1134 SET_STR(sorting_code); |
731 SET_STR(country_code); | 1135 SET_STR(country_code); |
732 SET_STR(phone_number); | 1136 SET_STR(phone_number); |
733 SET_STR(language_code); | 1137 SET_STR(language_code); |
734 return value; | 1138 return result; |
735 } | 1139 } |
736 | 1140 |
737 std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue( | 1141 VisitorResult WifiCredentialSpecificsVisit( |
738 const sync_pb::WifiCredentialSpecifics& proto) { | 1142 const sync_pb::WifiCredentialSpecifics& proto, |
739 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1143 const ResultType result_type) { |
1144 VisitorResult result(0); | |
1145 if (result_type == CONVERT_TO_VALUE) | |
1146 result.as_value.reset(new base::DictionaryValue()); | |
740 SET_BYTES(ssid); | 1147 SET_BYTES(ssid); |
741 SET_ENUM(security_class, GetWifiCredentialSecurityClassString); | 1148 SET_ENUM(security_class, GetWifiCredentialSecurityClassString); |
742 SET_BYTES(passphrase); | 1149 SET_BYTES(passphrase); |
743 return value; | 1150 return result; |
744 } | 1151 } |
745 | 1152 |
746 std::unique_ptr<base::DictionaryValue> EntitySpecificsToValue( | 1153 VisitorResult EntitySpecificsVisit(const sync_pb::EntitySpecifics& specifics, |
747 const sync_pb::EntitySpecifics& specifics) { | 1154 const ResultType result_type) { |
748 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1155 VisitorResult result(0); |
749 SET_FIELD(app, AppSpecificsToValue); | 1156 if (result_type == CONVERT_TO_VALUE) |
750 SET_FIELD(app_list, AppListSpecificsToValue); | 1157 result.as_value.reset(new base::DictionaryValue()); |
751 SET_FIELD(app_notification, AppNotificationToValue); | 1158 SET_FIELD(app, AppSpecificsVisit); |
752 SET_FIELD(app_setting, AppSettingSpecificsToValue); | 1159 SET_FIELD(app_list, AppListSpecificsVisit); |
753 SET_FIELD(arc_package, ArcPackageSpecificsToValue); | 1160 SET_FIELD(app_notification, AppNotificationVisit); |
754 SET_FIELD(article, ArticleSpecificsToValue); | 1161 SET_FIELD(app_setting, AppSettingSpecificsVisit); |
755 SET_FIELD(autofill, AutofillSpecificsToValue); | 1162 SET_FIELD(arc_package, ArcPackageSpecificsVisit); |
756 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); | 1163 SET_FIELD(article, ArticleSpecificsVisit); |
757 SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue); | 1164 SET_FIELD(autofill, AutofillSpecificsVisit); |
758 SET_FIELD(wallet_metadata, WalletMetadataSpecificsToValue); | 1165 SET_FIELD(autofill_profile, AutofillProfileSpecificsVisit); |
759 SET_FIELD(bookmark, BookmarkSpecificsToValue); | 1166 SET_FIELD(autofill_wallet, AutofillWalletSpecificsVisit); |
760 SET_FIELD(device_info, DeviceInfoSpecificsToValue); | 1167 SET_FIELD(wallet_metadata, WalletMetadataSpecificsVisit); |
761 SET_FIELD(dictionary, DictionarySpecificsToValue); | 1168 SET_FIELD(bookmark, BookmarkSpecificsVisit); |
762 SET_FIELD(experiments, ExperimentsSpecificsToValue); | 1169 SET_FIELD(device_info, DeviceInfoSpecificsVisit); |
763 SET_FIELD(extension, ExtensionSpecificsToValue); | 1170 SET_FIELD(dictionary, DictionarySpecificsVisit); |
764 SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); | 1171 SET_FIELD(experiments, ExperimentsSpecificsVisit); |
765 SET_FIELD(favicon_image, FaviconImageSpecificsToValue); | 1172 SET_FIELD(extension, ExtensionSpecificsVisit); |
766 SET_FIELD(favicon_tracking, FaviconTrackingSpecificsToValue); | 1173 SET_FIELD(extension_setting, ExtensionSettingSpecificsVisit); |
767 SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); | 1174 SET_FIELD(favicon_image, FaviconImageSpecificsVisit); |
768 SET_FIELD(managed_user_setting, ManagedUserSettingSpecificsToValue); | 1175 SET_FIELD(favicon_tracking, FaviconTrackingSpecificsVisit); |
1176 SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsVisit); | |
1177 SET_FIELD(managed_user_setting, ManagedUserSettingSpecificsVisit); | |
769 SET_FIELD(managed_user_shared_setting, | 1178 SET_FIELD(managed_user_shared_setting, |
770 ManagedUserSharedSettingSpecificsToValue); | 1179 ManagedUserSharedSettingSpecificsVisit); |
771 SET_FIELD(managed_user, ManagedUserSpecificsToValue); | 1180 SET_FIELD(managed_user, ManagedUserSpecificsVisit); |
772 SET_FIELD(managed_user_whitelist, ManagedUserWhitelistSpecificsToValue); | 1181 SET_FIELD(managed_user_whitelist, ManagedUserWhitelistSpecificsVisit); |
773 SET_FIELD(nigori, NigoriSpecificsToValue); | 1182 SET_FIELD(nigori, NigoriSpecificsVisit); |
774 SET_FIELD(password, PasswordSpecificsToValue); | 1183 SET_FIELD(password, PasswordSpecificsVisit); |
775 SET_FIELD(preference, PreferenceSpecificsToValue); | 1184 SET_FIELD(preference, PreferenceSpecificsVisit); |
776 SET_FIELD(priority_preference, PriorityPreferenceSpecificsToValue); | 1185 SET_FIELD(priority_preference, PriorityPreferenceSpecificsVisit); |
777 SET_FIELD(search_engine, SearchEngineSpecificsToValue); | 1186 SET_FIELD(search_engine, SearchEngineSpecificsVisit); |
778 SET_FIELD(session, SessionSpecificsToValue); | 1187 SET_FIELD(session, SessionSpecificsVisit); |
779 SET_FIELD(synced_notification, SyncedNotificationSpecificsToValue); | 1188 SET_FIELD(synced_notification, SyncedNotificationSpecificsVisit); |
780 SET_FIELD(synced_notification_app_info, | 1189 SET_FIELD(synced_notification_app_info, |
781 SyncedNotificationAppInfoSpecificsToValue); | 1190 SyncedNotificationAppInfoSpecificsVisit); |
782 SET_FIELD(theme, ThemeSpecificsToValue); | 1191 SET_FIELD(theme, ThemeSpecificsVisit); |
783 SET_FIELD(typed_url, TypedUrlSpecificsToValue); | 1192 SET_FIELD(typed_url, TypedUrlSpecificsVisit); |
784 SET_FIELD(wifi_credential, WifiCredentialSpecificsToValue); | 1193 SET_FIELD(wifi_credential, WifiCredentialSpecificsVisit); |
785 return value; | 1194 return result; |
786 } | 1195 } |
787 | 1196 |
788 namespace { | 1197 namespace { |
789 | 1198 |
790 base::StringValue* UniquePositionToStringValue( | 1199 VisitorResult UniquePositionToStringValue(const sync_pb::UniquePosition& proto, |
791 const sync_pb::UniquePosition& proto) { | 1200 const ResultType result_type) { |
1201 if (result_type == MEMORY_USAGE) { | |
1202 VisitorResult result(0); | |
1203 SET_STR(compressed_value); | |
1204 SET_STR(custom_compressed_v1); | |
1205 return result; | |
1206 } | |
792 UniquePosition pos = UniquePosition::FromProto(proto); | 1207 UniquePosition pos = UniquePosition::FromProto(proto); |
793 return new base::StringValue(pos.ToDebugString()); | 1208 return VisitorResult( |
1209 base::WrapUnique(new base::StringValue(pos.ToDebugString()))); | |
794 } | 1210 } |
795 | 1211 |
796 } // namespace | 1212 } // namespace |
797 | 1213 |
798 std::unique_ptr<base::DictionaryValue> SyncEntityToValue( | 1214 VisitorResult SyncEntityVisit(const sync_pb::SyncEntity& proto, |
799 const sync_pb::SyncEntity& proto, | 1215 bool include_specifics, |
800 bool include_specifics) { | 1216 const ResultType result_type) { |
801 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1217 VisitorResult result(0); |
1218 if (result_type == CONVERT_TO_VALUE) | |
1219 result.as_value.reset(new base::DictionaryValue()); | |
802 SET_STR(id_string); | 1220 SET_STR(id_string); |
803 SET_STR(parent_id_string); | 1221 SET_STR(parent_id_string); |
804 SET_STR(old_parent_id); | 1222 SET_STR(old_parent_id); |
805 SET_INT64(version); | 1223 SET_INT64(version); |
806 SET_INT64(mtime); | 1224 SET_INT64(mtime); |
807 SET_INT64(ctime); | 1225 SET_INT64(ctime); |
808 SET_STR(name); | 1226 SET_STR(name); |
809 SET_STR(non_unique_name); | 1227 SET_STR(non_unique_name); |
810 SET_INT64(sync_timestamp); | 1228 SET_INT64(sync_timestamp); |
811 SET_STR(server_defined_unique_tag); | 1229 SET_STR(server_defined_unique_tag); |
812 SET_INT64(position_in_parent); | 1230 SET_INT64(position_in_parent); |
813 SET(unique_position, UniquePositionToStringValue); | 1231 SET(unique_position, UniquePositionToStringValue); |
814 SET_STR(insert_after_item_id); | 1232 SET_STR(insert_after_item_id); |
815 SET_BOOL(deleted); | 1233 SET_BOOL(deleted); |
816 SET_STR(originator_cache_guid); | 1234 SET_STR(originator_cache_guid); |
817 SET_STR(originator_client_item_id); | 1235 SET_STR(originator_client_item_id); |
818 if (include_specifics) | 1236 if (include_specifics) |
819 SET(specifics, EntitySpecificsToValue); | 1237 SET(specifics, EntitySpecificsVisit); |
820 SET_BOOL(folder); | 1238 SET_BOOL(folder); |
821 SET_STR(client_defined_unique_tag); | 1239 SET_STR(client_defined_unique_tag); |
822 SET_REP(attachment_id, AttachmentIdProtoToValue); | 1240 SET_REP(attachment_id, AttachmentIdProtoVisit); |
823 return value; | 1241 return result; |
824 } | 1242 } |
825 | 1243 |
826 namespace { | 1244 namespace { |
827 | 1245 |
828 base::ListValue* SyncEntitiesToValue( | 1246 VisitorResult SyncEntitiesVisit( |
829 const ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, | 1247 const ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, |
830 bool include_specifics) { | 1248 bool include_specifics, |
831 base::ListValue* list = new base::ListValue(); | 1249 const ResultType result_type) { |
832 ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it; | 1250 ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it; |
1251 if (result_type == MEMORY_USAGE) { | |
1252 size_t total = 0; | |
1253 for (it = entities.begin(); it != entities.end(); ++it) { | |
1254 total += | |
1255 SyncEntityVisit(*it, include_specifics, result_type).memory_usage + | |
1256 sizeof(sync_pb::SyncEntity); | |
1257 } | |
1258 return VisitorResult(total); | |
1259 } | |
1260 std::unique_ptr<base::ListValue> list(new base::ListValue()); | |
833 for (it = entities.begin(); it != entities.end(); ++it) { | 1261 for (it = entities.begin(); it != entities.end(); ++it) { |
834 list->Append(SyncEntityToValue(*it, include_specifics)); | 1262 list->Append(SyncEntityVisit(*it, include_specifics, result_type).as_value); |
835 } | 1263 } |
836 | 1264 return VisitorResult(std::move(list)); |
837 return list; | |
838 } | 1265 } |
839 | 1266 |
840 std::unique_ptr<base::DictionaryValue> ChromiumExtensionActivityToValue( | 1267 VisitorResult ChromiumExtensionActivityVisit( |
841 const sync_pb::ChromiumExtensionsActivity& proto) { | 1268 const sync_pb::ChromiumExtensionsActivity& proto, |
842 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1269 const ResultType result_type) { |
1270 VisitorResult result(0); | |
1271 if (result_type == CONVERT_TO_VALUE) | |
1272 result.as_value.reset(new base::DictionaryValue()); | |
843 SET_STR(extension_id); | 1273 SET_STR(extension_id); |
844 SET_INT32(bookmark_writes_since_last_commit); | 1274 SET_INT32(bookmark_writes_since_last_commit); |
845 return value; | 1275 return result; |
846 } | 1276 } |
847 | 1277 |
848 std::unique_ptr<base::DictionaryValue> CommitMessageToValue( | 1278 VisitorResult CommitMessageVisit(const sync_pb::CommitMessage& proto, |
849 const sync_pb::CommitMessage& proto, | 1279 bool include_specifics, |
850 bool include_specifics) { | 1280 const ResultType result_type) { |
851 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1281 VisitorResult result(0); |
852 value->Set("entries", | 1282 if (result_type == CONVERT_TO_VALUE) |
853 SyncEntitiesToValue(proto.entries(), include_specifics)); | 1283 result.as_value.reset(new base::DictionaryValue()); |
1284 SET_WITH_EXPR( | |
1285 entries, | |
1286 SyncEntitiesVisit(proto.entries(), include_specifics, result_type), 0); | |
854 SET_STR(cache_guid); | 1287 SET_STR(cache_guid); |
855 SET_REP(extensions_activity, ChromiumExtensionActivityToValue); | 1288 SET_REP(extensions_activity, ChromiumExtensionActivityVisit); |
856 SET(config_params, ClientConfigParamsToValue); | 1289 SET(config_params, ClientConfigParamsVisit); |
857 return value; | 1290 return result; |
858 } | 1291 } |
859 | 1292 |
860 std::unique_ptr<base::DictionaryValue> GetUpdateTriggersToValue( | 1293 VisitorResult GetUpdateTriggersVisit(const sync_pb::GetUpdateTriggers& proto, |
861 const sync_pb::GetUpdateTriggers& proto) { | 1294 const ResultType result_type) { |
862 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1295 VisitorResult result(0); |
1296 if (result_type == CONVERT_TO_VALUE) | |
1297 result.as_value.reset(new base::DictionaryValue()); | |
863 SET_STR_REP(notification_hint); | 1298 SET_STR_REP(notification_hint); |
864 SET_BOOL(client_dropped_hints); | 1299 SET_BOOL(client_dropped_hints); |
865 SET_BOOL(invalidations_out_of_sync); | 1300 SET_BOOL(invalidations_out_of_sync); |
866 SET_INT64(local_modification_nudges); | 1301 SET_INT64(local_modification_nudges); |
867 SET_INT64(datatype_refresh_nudges); | 1302 SET_INT64(datatype_refresh_nudges); |
868 return value; | 1303 return result; |
869 } | 1304 } |
870 | 1305 |
871 std::unique_ptr<base::DictionaryValue> DataTypeProgressMarkerToValue( | 1306 VisitorResult DataTypeProgressMarkerVisit( |
872 const sync_pb::DataTypeProgressMarker& proto) { | 1307 const sync_pb::DataTypeProgressMarker& proto, |
873 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1308 const ResultType result_type) { |
1309 VisitorResult result(0); | |
1310 if (result_type == CONVERT_TO_VALUE) | |
1311 result.as_value.reset(new base::DictionaryValue()); | |
874 SET_INT32(data_type_id); | 1312 SET_INT32(data_type_id); |
875 SET_BYTES(token); | 1313 SET_BYTES(token); |
876 SET_INT64(timestamp_token_for_migration); | 1314 SET_INT64(timestamp_token_for_migration); |
877 SET_STR(notification_hint); | 1315 SET_STR(notification_hint); |
878 SET(get_update_triggers, GetUpdateTriggersToValue); | 1316 SET(get_update_triggers, GetUpdateTriggersVisit); |
879 return value; | 1317 return result; |
880 } | 1318 } |
881 | 1319 |
882 std::unique_ptr<base::DictionaryValue> DataTypeContextToValue( | 1320 VisitorResult DataTypeContextVisit(const sync_pb::DataTypeContext& proto, |
883 const sync_pb::DataTypeContext& proto) { | 1321 const ResultType result_type) { |
884 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1322 VisitorResult result(0); |
1323 if (result_type == CONVERT_TO_VALUE) | |
1324 result.as_value.reset(new base::DictionaryValue()); | |
885 SET_INT32(data_type_id); | 1325 SET_INT32(data_type_id); |
886 SET_STR(context); | 1326 SET_STR(context); |
887 SET_INT64(version); | 1327 SET_INT64(version); |
888 return value; | 1328 return result; |
889 } | 1329 } |
890 | 1330 |
891 std::unique_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue( | 1331 VisitorResult GetUpdatesCallerInfoVisit( |
892 const sync_pb::GetUpdatesCallerInfo& proto) { | 1332 const sync_pb::GetUpdatesCallerInfo& proto, |
893 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1333 const ResultType result_type) { |
1334 VisitorResult result(0); | |
1335 if (result_type == CONVERT_TO_VALUE) | |
1336 result.as_value.reset(new base::DictionaryValue()); | |
894 SET_ENUM(source, GetUpdatesSourceString); | 1337 SET_ENUM(source, GetUpdatesSourceString); |
895 SET_BOOL(notifications_enabled); | 1338 SET_BOOL(notifications_enabled); |
896 return value; | 1339 return result; |
897 } | 1340 } |
898 | 1341 |
899 std::unique_ptr<base::DictionaryValue> GetUpdatesMessageToValue( | 1342 VisitorResult GetUpdatesMessageVisit(const sync_pb::GetUpdatesMessage& proto, |
900 const sync_pb::GetUpdatesMessage& proto) { | 1343 const ResultType result_type) { |
901 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1344 VisitorResult result(0); |
902 SET(caller_info, GetUpdatesCallerInfoToValue); | 1345 if (result_type == CONVERT_TO_VALUE) |
1346 result.as_value.reset(new base::DictionaryValue()); | |
1347 SET(caller_info, GetUpdatesCallerInfoVisit); | |
903 SET_BOOL(fetch_folders); | 1348 SET_BOOL(fetch_folders); |
904 SET_INT32(batch_size); | 1349 SET_INT32(batch_size); |
905 SET_REP(from_progress_marker, DataTypeProgressMarkerToValue); | 1350 SET_REP(from_progress_marker, DataTypeProgressMarkerVisit); |
906 SET_BOOL(streaming); | 1351 SET_BOOL(streaming); |
907 SET_BOOL(need_encryption_key); | 1352 SET_BOOL(need_encryption_key); |
908 SET_BOOL(create_mobile_bookmarks_folder); | 1353 SET_BOOL(create_mobile_bookmarks_folder); |
909 SET_ENUM(get_updates_origin, GetUpdatesOriginString); | 1354 SET_ENUM(get_updates_origin, GetUpdatesOriginString); |
910 SET_REP(client_contexts, DataTypeContextToValue); | 1355 SET_REP(client_contexts, DataTypeContextVisit); |
911 return value; | 1356 return result; |
912 } | 1357 } |
913 | 1358 |
914 std::unique_ptr<base::DictionaryValue> ClientStatusToValue( | 1359 VisitorResult ClientStatusVisit(const sync_pb::ClientStatus& proto, |
915 const sync_pb::ClientStatus& proto) { | 1360 const ResultType result_type) { |
916 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1361 VisitorResult result(0); |
1362 if (result_type == CONVERT_TO_VALUE) | |
1363 result.as_value.reset(new base::DictionaryValue()); | |
917 SET_BOOL(hierarchy_conflict_detected); | 1364 SET_BOOL(hierarchy_conflict_detected); |
918 return value; | 1365 return result; |
919 } | 1366 } |
920 | 1367 |
921 std::unique_ptr<base::DictionaryValue> EntryResponseToValue( | 1368 VisitorResult EntryResponseVisit( |
922 const sync_pb::CommitResponse::EntryResponse& proto) { | 1369 const sync_pb::CommitResponse::EntryResponse& proto, |
923 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1370 const ResultType result_type) { |
1371 VisitorResult result(0); | |
1372 if (result_type == CONVERT_TO_VALUE) | |
1373 result.as_value.reset(new base::DictionaryValue()); | |
924 SET_ENUM(response_type, GetResponseTypeString); | 1374 SET_ENUM(response_type, GetResponseTypeString); |
925 SET_STR(id_string); | 1375 SET_STR(id_string); |
926 SET_STR(parent_id_string); | 1376 SET_STR(parent_id_string); |
927 SET_INT64(position_in_parent); | 1377 SET_INT64(position_in_parent); |
928 SET_INT64(version); | 1378 SET_INT64(version); |
929 SET_STR(name); | 1379 SET_STR(name); |
930 SET_STR(error_message); | 1380 SET_STR(error_message); |
931 SET_INT64(mtime); | 1381 SET_INT64(mtime); |
932 return value; | 1382 return result; |
933 } | 1383 } |
934 | 1384 |
935 std::unique_ptr<base::DictionaryValue> CommitResponseToValue( | 1385 VisitorResult CommitResponseVisit(const sync_pb::CommitResponse& proto, |
936 const sync_pb::CommitResponse& proto) { | 1386 const ResultType result_type) { |
937 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1387 VisitorResult result(0); |
938 SET_REP(entryresponse, EntryResponseToValue); | 1388 if (result_type == CONVERT_TO_VALUE) |
939 return value; | 1389 result.as_value.reset(new base::DictionaryValue()); |
1390 SET_REP(entryresponse, EntryResponseVisit); | |
1391 return result; | |
940 } | 1392 } |
941 | 1393 |
942 std::unique_ptr<base::DictionaryValue> GetUpdatesResponseToValue( | 1394 VisitorResult GetUpdatesResponseVisit(const sync_pb::GetUpdatesResponse& proto, |
943 const sync_pb::GetUpdatesResponse& proto, | 1395 bool include_specifics, |
944 bool include_specifics) { | 1396 const ResultType result_type) { |
945 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1397 VisitorResult result(0); |
946 value->Set("entries", | 1398 if (result_type == CONVERT_TO_VALUE) |
947 SyncEntitiesToValue(proto.entries(), include_specifics)); | 1399 result.as_value.reset(new base::DictionaryValue()); |
1400 SET_WITH_EXPR( | |
1401 entries, | |
1402 SyncEntitiesVisit(proto.entries(), include_specifics, result_type), 0); | |
948 SET_INT64(changes_remaining); | 1403 SET_INT64(changes_remaining); |
949 SET_REP(new_progress_marker, DataTypeProgressMarkerToValue); | 1404 SET_REP(new_progress_marker, DataTypeProgressMarkerVisit); |
950 SET_REP(context_mutations, DataTypeContextToValue); | 1405 SET_REP(context_mutations, DataTypeContextVisit); |
951 return value; | 1406 return result; |
952 } | 1407 } |
953 | 1408 |
954 std::unique_ptr<base::DictionaryValue> ClientCommandToValue( | 1409 VisitorResult ClientCommandVisit(const sync_pb::ClientCommand& proto, |
955 const sync_pb::ClientCommand& proto) { | 1410 const ResultType result_type) { |
956 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1411 VisitorResult result(0); |
1412 if (result_type == CONVERT_TO_VALUE) | |
1413 result.as_value.reset(new base::DictionaryValue()); | |
957 SET_INT32(set_sync_poll_interval); | 1414 SET_INT32(set_sync_poll_interval); |
958 SET_INT32(set_sync_long_poll_interval); | 1415 SET_INT32(set_sync_long_poll_interval); |
959 SET_INT32(max_commit_batch_size); | 1416 SET_INT32(max_commit_batch_size); |
960 SET_INT32(sessions_commit_delay_seconds); | 1417 SET_INT32(sessions_commit_delay_seconds); |
961 SET_INT32(throttle_delay_seconds); | 1418 SET_INT32(throttle_delay_seconds); |
962 SET_INT32(client_invalidation_hint_buffer_size); | 1419 SET_INT32(client_invalidation_hint_buffer_size); |
963 return value; | 1420 return result; |
964 } | 1421 } |
965 | 1422 |
966 std::unique_ptr<base::DictionaryValue> ErrorToValue( | 1423 VisitorResult ErrorVisit(const sync_pb::ClientToServerResponse::Error& proto, |
967 const sync_pb::ClientToServerResponse::Error& proto) { | 1424 const ResultType result_type) { |
968 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1425 VisitorResult result(0); |
1426 if (result_type == CONVERT_TO_VALUE) | |
1427 result.as_value.reset(new base::DictionaryValue()); | |
969 SET_ENUM(error_type, GetErrorTypeString); | 1428 SET_ENUM(error_type, GetErrorTypeString); |
970 SET_STR(error_description); | 1429 SET_STR(error_description); |
971 SET_STR(url); | 1430 SET_STR(url); |
972 SET_ENUM(action, GetActionString); | 1431 SET_ENUM(action, GetActionString); |
973 return value; | 1432 return result; |
974 } | 1433 } |
975 | 1434 |
976 } // namespace | 1435 } // namespace |
977 | 1436 |
978 std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue( | 1437 VisitorResult ClientToServerResponseVisit( |
979 const sync_pb::ClientToServerResponse& proto, | 1438 const sync_pb::ClientToServerResponse& proto, |
980 bool include_specifics) { | 1439 bool include_specifics, |
981 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1440 const ResultType result_type) { |
982 SET(commit, CommitResponseToValue); | 1441 VisitorResult result(0); |
1442 if (result_type == CONVERT_TO_VALUE) | |
1443 result.as_value.reset(new base::DictionaryValue()); | |
1444 SET(commit, CommitResponseVisit); | |
983 if (proto.has_get_updates()) { | 1445 if (proto.has_get_updates()) { |
984 value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(), | 1446 SET_WITH_EXPR(get_updates, |
985 include_specifics)); | 1447 GetUpdatesResponseVisit(proto.get_updates(), |
1448 include_specifics, result_type), | |
1449 sizeof(proto.get_updates())); | |
986 } | 1450 } |
987 | 1451 |
988 SET(error, ErrorToValue); | 1452 SET(error, ErrorVisit); |
989 SET_ENUM(error_code, GetErrorTypeString); | 1453 SET_ENUM(error_code, GetErrorTypeString); |
990 SET_STR(error_message); | 1454 SET_STR(error_message); |
991 SET_STR(store_birthday); | 1455 SET_STR(store_birthday); |
992 SET(client_command, ClientCommandToValue); | 1456 SET(client_command, ClientCommandVisit); |
993 SET_INT32_REP(migrated_data_type_id); | 1457 SET_INT32_REP(migrated_data_type_id); |
994 return value; | 1458 return result; |
995 } | 1459 } |
996 | 1460 |
997 std::unique_ptr<base::DictionaryValue> ClientToServerMessageToValue( | 1461 VisitorResult ClientToServerMessageVisit( |
998 const sync_pb::ClientToServerMessage& proto, | 1462 const sync_pb::ClientToServerMessage& proto, |
999 bool include_specifics) { | 1463 bool include_specifics, |
1000 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1464 const ResultType result_type) { |
1465 VisitorResult result(0); | |
1466 if (result_type == CONVERT_TO_VALUE) | |
1467 result.as_value.reset(new base::DictionaryValue()); | |
1001 SET_STR(share); | 1468 SET_STR(share); |
1002 SET_INT32(protocol_version); | 1469 SET_INT32(protocol_version); |
1003 if (proto.has_commit()) { | 1470 if (proto.has_commit()) { |
1004 value->Set("commit", | 1471 SET_WITH_EXPR(commit, CommitMessageVisit(proto.commit(), include_specifics, |
1005 CommitMessageToValue(proto.commit(), include_specifics)); | 1472 result_type), |
1473 sizeof(proto.commit())); | |
1006 } | 1474 } |
1007 | 1475 |
1008 SET(get_updates, GetUpdatesMessageToValue); | 1476 SET(get_updates, GetUpdatesMessageVisit); |
1009 SET_STR(store_birthday); | 1477 SET_STR(store_birthday); |
1010 SET_BOOL(sync_problem_detected); | 1478 SET_BOOL(sync_problem_detected); |
1011 SET(debug_info, DebugInfoToValue); | 1479 SET(debug_info, DebugInfoVisit); |
1012 SET(client_status, ClientStatusToValue); | 1480 SET(client_status, ClientStatusVisit); |
1013 return value; | 1481 return result; |
1014 } | 1482 } |
1015 | 1483 |
1016 std::unique_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue( | 1484 VisitorResult DatatypeAssociationStatsVisit( |
1017 const sync_pb::DatatypeAssociationStats& proto) { | 1485 const sync_pb::DatatypeAssociationStats& proto, |
1018 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1486 const ResultType result_type) { |
1487 VisitorResult result(0); | |
1488 if (result_type == CONVERT_TO_VALUE) | |
1489 result.as_value.reset(new base::DictionaryValue()); | |
1019 SET_INT32(data_type_id); | 1490 SET_INT32(data_type_id); |
1020 SET_INT32(num_local_items_before_association); | 1491 SET_INT32(num_local_items_before_association); |
1021 SET_INT32(num_sync_items_before_association); | 1492 SET_INT32(num_sync_items_before_association); |
1022 SET_INT32(num_local_items_after_association); | 1493 SET_INT32(num_local_items_after_association); |
1023 SET_INT32(num_sync_items_after_association); | 1494 SET_INT32(num_sync_items_after_association); |
1024 SET_INT32(num_local_items_added); | 1495 SET_INT32(num_local_items_added); |
1025 SET_INT32(num_local_items_deleted); | 1496 SET_INT32(num_local_items_deleted); |
1026 SET_INT32(num_local_items_modified); | 1497 SET_INT32(num_local_items_modified); |
1027 SET_INT32(num_sync_items_added); | 1498 SET_INT32(num_sync_items_added); |
1028 SET_INT32(num_sync_items_deleted); | 1499 SET_INT32(num_sync_items_deleted); |
1029 SET_INT32(num_sync_items_modified); | 1500 SET_INT32(num_sync_items_modified); |
1030 SET_INT64(local_version_pre_association); | 1501 SET_INT64(local_version_pre_association); |
1031 SET_INT64(sync_version_pre_association) | 1502 SET_INT64(sync_version_pre_association) |
1032 SET_BOOL(had_error); | 1503 SET_BOOL(had_error); |
1033 SET_INT64(download_wait_time_us); | 1504 SET_INT64(download_wait_time_us); |
1034 SET_INT64(download_time_us); | 1505 SET_INT64(download_time_us); |
1035 SET_INT64(association_wait_time_for_high_priority_us); | 1506 SET_INT64(association_wait_time_for_high_priority_us); |
1036 SET_INT64(association_wait_time_for_same_priority_us); | 1507 SET_INT64(association_wait_time_for_same_priority_us); |
1037 return value; | 1508 return result; |
1038 } | 1509 } |
1039 | 1510 |
1040 std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue( | 1511 VisitorResult DebugEventInfoVisit(const sync_pb::DebugEventInfo& proto, |
1041 const sync_pb::DebugEventInfo& proto) { | 1512 const ResultType result_type) { |
1042 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1513 VisitorResult result(0); |
1514 if (result_type == CONVERT_TO_VALUE) | |
1515 result.as_value.reset(new base::DictionaryValue()); | |
1043 SET_ENUM(singleton_event, SingletonDebugEventTypeString); | 1516 SET_ENUM(singleton_event, SingletonDebugEventTypeString); |
1044 SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue); | 1517 SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoVisit); |
1045 SET_INT32(nudging_datatype); | 1518 SET_INT32(nudging_datatype); |
1046 SET_INT32_REP(datatypes_notified_from_server); | 1519 SET_INT32_REP(datatypes_notified_from_server); |
1047 SET(datatype_association_stats, DatatypeAssociationStatsToValue); | 1520 SET(datatype_association_stats, DatatypeAssociationStatsVisit); |
1048 return value; | 1521 return result; |
1049 } | 1522 } |
1050 | 1523 |
1051 std::unique_ptr<base::DictionaryValue> DebugInfoToValue( | 1524 VisitorResult DebugInfoVisit(const sync_pb::DebugInfo& proto, |
1052 const sync_pb::DebugInfo& proto) { | 1525 const ResultType result_type) { |
1053 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1526 VisitorResult result(0); |
1054 SET_REP(events, DebugEventInfoToValue); | 1527 if (result_type == CONVERT_TO_VALUE) |
1528 result.as_value.reset(new base::DictionaryValue()); | |
1529 SET_REP(events, DebugEventInfoVisit); | |
1055 SET_BOOL(cryptographer_ready); | 1530 SET_BOOL(cryptographer_ready); |
1056 SET_BOOL(cryptographer_has_pending_keys); | 1531 SET_BOOL(cryptographer_has_pending_keys); |
1057 SET_BOOL(events_dropped); | 1532 SET_BOOL(events_dropped); |
1058 return value; | 1533 return result; |
1059 } | 1534 } |
1060 | 1535 |
1061 std::unique_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue( | 1536 VisitorResult SyncCycleCompletedEventInfoVisit( |
1062 const sync_pb::SyncCycleCompletedEventInfo& proto) { | 1537 const sync_pb::SyncCycleCompletedEventInfo& proto, |
1063 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1538 const ResultType result_type) { |
1539 VisitorResult result(0); | |
1540 if (result_type == CONVERT_TO_VALUE) | |
1541 result.as_value.reset(new base::DictionaryValue()); | |
1064 SET_INT32(num_encryption_conflicts); | 1542 SET_INT32(num_encryption_conflicts); |
1065 SET_INT32(num_hierarchy_conflicts); | 1543 SET_INT32(num_hierarchy_conflicts); |
1066 SET_INT32(num_server_conflicts); | 1544 SET_INT32(num_server_conflicts); |
1067 SET_INT32(num_updates_downloaded); | 1545 SET_INT32(num_updates_downloaded); |
1068 SET_INT32(num_reflected_updates_downloaded); | 1546 SET_INT32(num_reflected_updates_downloaded); |
1069 SET(caller_info, GetUpdatesCallerInfoToValue); | 1547 SET(caller_info, GetUpdatesCallerInfoVisit); |
1070 return value; | 1548 return result; |
1071 } | 1549 } |
1072 | 1550 |
1073 std::unique_ptr<base::DictionaryValue> ClientConfigParamsToValue( | 1551 VisitorResult ClientConfigParamsVisit(const sync_pb::ClientConfigParams& proto, |
1074 const sync_pb::ClientConfigParams& proto) { | 1552 const ResultType result_type) { |
1075 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1553 VisitorResult result(0); |
1554 if (result_type == CONVERT_TO_VALUE) | |
1555 result.as_value.reset(new base::DictionaryValue()); | |
1076 SET_INT32_REP(enabled_type_ids); | 1556 SET_INT32_REP(enabled_type_ids); |
1077 SET_BOOL(tabs_datatype_enabled); | 1557 SET_BOOL(tabs_datatype_enabled); |
1078 SET_BOOL(cookie_jar_mismatch); | 1558 SET_BOOL(cookie_jar_mismatch); |
1079 return value; | 1559 return result; |
1560 } | |
1561 | |
1562 VisitorResult AttachmentIdProtoVisit(const sync_pb::AttachmentIdProto& proto, | |
1563 const ResultType result_type) { | |
1564 VisitorResult result(0); | |
1565 if (result_type == CONVERT_TO_VALUE) | |
1566 result.as_value.reset(new base::DictionaryValue()); | |
1567 SET_STR(unique_id); | |
1568 return result; | |
1569 } | |
1570 | |
1571 std::unique_ptr<base::DictionaryValue> EncryptedDataToValue( | |
1572 const sync_pb::EncryptedData& encrypted_data) { | |
1573 return EncryptedDataVisit(encrypted_data, CONVERT_TO_VALUE).TakeDictValue(); | |
1574 } | |
1575 | |
1576 std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue( | |
1577 const sync_pb::AppListSpecifics& proto) { | |
1578 return AppListSpecificsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); | |
1579 } | |
1580 | |
1581 std::unique_ptr<base::DictionaryValue> AppSettingsToValue( | |
1582 const sync_pb::AppNotificationSettings& app_notification_settings) { | |
1583 return AppSettingsVisit(app_notification_settings, CONVERT_TO_VALUE) | |
1584 .TakeDictValue(); | |
1585 } | |
1586 | |
1587 std::unique_ptr<base::DictionaryValue> LinkedAppIconInfoToValue( | |
1588 const sync_pb::LinkedAppIconInfo& linked_app_icon_info) { | |
1589 return LinkedAppIconInfoVisit(linked_app_icon_info, CONVERT_TO_VALUE) | |
1590 .TakeDictValue(); | |
1591 } | |
1592 | |
1593 std::unique_ptr<base::DictionaryValue> SessionHeaderToValue( | |
1594 const sync_pb::SessionHeader& session_header) { | |
1595 return SessionHeaderVisit(session_header, CONVERT_TO_VALUE).TakeDictValue(); | |
1596 } | |
1597 | |
1598 std::unique_ptr<base::DictionaryValue> SessionTabToValue( | |
1599 const sync_pb::SessionTab& session_tab) { | |
1600 return SessionTabVisit(session_tab, CONVERT_TO_VALUE).TakeDictValue(); | |
1601 } | |
1602 | |
1603 std::unique_ptr<base::DictionaryValue> SessionWindowToValue( | |
1604 const sync_pb::SessionWindow& session_window) { | |
1605 return SessionWindowVisit(session_window, CONVERT_TO_VALUE).TakeDictValue(); | |
1606 } | |
1607 | |
1608 std::unique_ptr<base::DictionaryValue> TabNavigationToValue( | |
1609 const sync_pb::TabNavigation& tab_navigation) { | |
1610 return TabNavigationVisit(tab_navigation, CONVERT_TO_VALUE).TakeDictValue(); | |
1611 } | |
1612 | |
1613 std::unique_ptr<base::DictionaryValue> NavigationRedirectToValue( | |
1614 const sync_pb::NavigationRedirect& navigation_redirect) { | |
1615 return NavigationRedirectVisit(navigation_redirect, CONVERT_TO_VALUE) | |
1616 .TakeDictValue(); | |
1617 } | |
1618 | |
1619 std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( | |
1620 const sync_pb::PasswordSpecificsData& password_specifics_data) { | |
1621 return PasswordSpecificsDataVisit(password_specifics_data, CONVERT_TO_VALUE) | |
1622 .TakeDictValue(); | |
1623 } | |
1624 | |
1625 std::unique_ptr<base::DictionaryValue> GlobalIdDirectiveToValue( | |
1626 const sync_pb::GlobalIdDirective& global_id_directive) { | |
1627 return GlobalIdDirectiveVisit(global_id_directive, CONVERT_TO_VALUE) | |
1628 .TakeDictValue(); | |
1629 } | |
1630 | |
1631 std::unique_ptr<base::DictionaryValue> TimeRangeDirectiveToValue( | |
1632 const sync_pb::TimeRangeDirective& time_range_directive) { | |
1633 return TimeRangeDirectiveVisit(time_range_directive, CONVERT_TO_VALUE) | |
1634 .TakeDictValue(); | |
1635 } | |
1636 | |
1637 std::unique_ptr<base::DictionaryValue> SessionSpecificsToValue( | |
1638 const sync_pb::SessionSpecifics& session_specifics) { | |
1639 return SessionSpecificsVisit(session_specifics, CONVERT_TO_VALUE) | |
1640 .TakeDictValue(); | |
1641 } | |
1642 | |
1643 std::unique_ptr<base::DictionaryValue> ArcPackageSpecificsToValue( | |
1644 const sync_pb::ArcPackageSpecifics& proto) { | |
1645 return ArcPackageSpecificsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); | |
1646 } | |
1647 | |
1648 std::unique_ptr<base::DictionaryValue> AppNotificationToValue( | |
1649 const sync_pb::AppNotification& app_notification_specifics) { | |
1650 return AppNotificationVisit(app_notification_specifics, CONVERT_TO_VALUE) | |
1651 .TakeDictValue(); | |
1652 } | |
1653 | |
1654 std::unique_ptr<base::DictionaryValue> AppSettingSpecificsToValue( | |
1655 const sync_pb::AppSettingSpecifics& app_setting_specifics) { | |
1656 return AppSettingSpecificsVisit(app_setting_specifics, CONVERT_TO_VALUE) | |
1657 .TakeDictValue(); | |
1658 } | |
1659 | |
1660 std::unique_ptr<base::DictionaryValue> AppSpecificsToValue( | |
1661 const sync_pb::AppSpecifics& app_specifics) { | |
1662 return AppSpecificsVisit(app_specifics, CONVERT_TO_VALUE).TakeDictValue(); | |
1663 } | |
1664 | |
1665 std::unique_ptr<base::DictionaryValue> ArticleSpecificsToValue( | |
1666 const sync_pb::ArticleSpecifics& article_specifics) { | |
1667 return ArticleSpecificsVisit(article_specifics, CONVERT_TO_VALUE) | |
1668 .TakeDictValue(); | |
1669 } | |
1670 | |
1671 std::unique_ptr<base::DictionaryValue> AutofillSpecificsToValue( | |
1672 const sync_pb::AutofillSpecifics& autofill_specifics) { | |
1673 return AutofillSpecificsVisit(autofill_specifics, CONVERT_TO_VALUE) | |
1674 .TakeDictValue(); | |
1675 } | |
1676 | |
1677 std::unique_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( | |
1678 const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics) { | |
1679 return AutofillProfileSpecificsVisit(autofill_profile_specifics, | |
1680 CONVERT_TO_VALUE) | |
1681 .TakeDictValue(); | |
1682 } | |
1683 | |
1684 std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue( | |
1685 const sync_pb::WalletMetadataSpecifics& wallet_metadata_specifics) { | |
1686 return WalletMetadataSpecificsVisit(wallet_metadata_specifics, | |
1687 CONVERT_TO_VALUE) | |
1688 .TakeDictValue(); | |
1689 } | |
1690 | |
1691 std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( | |
1692 const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics) { | |
1693 return AutofillWalletSpecificsVisit(autofill_wallet_specifics, | |
1694 CONVERT_TO_VALUE) | |
1695 .TakeDictValue(); | |
1696 } | |
1697 | |
1698 std::unique_ptr<base::DictionaryValue> BookmarkSpecificsToValue( | |
1699 const sync_pb::BookmarkSpecifics& bookmark_specifics) { | |
1700 return BookmarkSpecificsVisit(bookmark_specifics, CONVERT_TO_VALUE) | |
1701 .TakeDictValue(); | |
1702 } | |
1703 | |
1704 std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue( | |
1705 const sync_pb::DeviceInfoSpecifics& device_info_specifics) { | |
1706 return DeviceInfoSpecificsVisit(device_info_specifics, CONVERT_TO_VALUE) | |
1707 .TakeDictValue(); | |
1708 } | |
1709 | |
1710 std::unique_ptr<base::DictionaryValue> DictionarySpecificsToValue( | |
1711 const sync_pb::DictionarySpecifics& dictionary_specifics) { | |
1712 return DictionarySpecificsVisit(dictionary_specifics, CONVERT_TO_VALUE) | |
1713 .TakeDictValue(); | |
1714 } | |
1715 | |
1716 std::unique_ptr<base::DictionaryValue> ExperimentsSpecificsToValue( | |
1717 const sync_pb::ExperimentsSpecifics& proto) { | |
1718 return ExperimentsSpecificsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); | |
1719 } | |
1720 | |
1721 std::unique_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue( | |
1722 const sync_pb::PriorityPreferenceSpecifics& proto) { | |
1723 return PriorityPreferenceSpecificsVisit(proto, CONVERT_TO_VALUE) | |
1724 .TakeDictValue(); | |
1725 } | |
1726 | |
1727 std::unique_ptr<base::DictionaryValue> ExtensionSettingSpecificsToValue( | |
1728 const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics) { | |
1729 return ExtensionSettingSpecificsVisit(extension_setting_specifics, | |
1730 CONVERT_TO_VALUE) | |
1731 .TakeDictValue(); | |
1732 } | |
1733 | |
1734 std::unique_ptr<base::DictionaryValue> ExtensionSpecificsToValue( | |
1735 const sync_pb::ExtensionSpecifics& extension_specifics) { | |
1736 return ExtensionSpecificsVisit(extension_specifics, CONVERT_TO_VALUE) | |
1737 .TakeDictValue(); | |
1738 } | |
1739 | |
1740 std::unique_ptr<base::DictionaryValue> FaviconImageSpecificsToValue( | |
1741 const sync_pb::FaviconImageSpecifics& favicon_image_specifics) { | |
1742 return FaviconImageSpecificsVisit(favicon_image_specifics, CONVERT_TO_VALUE) | |
1743 .TakeDictValue(); | |
1744 } | |
1745 | |
1746 std::unique_ptr<base::DictionaryValue> FaviconTrackingSpecificsToValue( | |
1747 const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics) { | |
1748 return FaviconTrackingSpecificsVisit(favicon_tracking_specifics, | |
1749 CONVERT_TO_VALUE) | |
1750 .TakeDictValue(); | |
1751 } | |
1752 | |
1753 std::unique_ptr<base::DictionaryValue> HistoryDeleteDirectiveSpecificsToValue( | |
1754 const sync_pb::HistoryDeleteDirectiveSpecifics& | |
1755 history_delete_directive_specifics) { | |
1756 return HistoryDeleteDirectiveSpecificsVisit( | |
1757 history_delete_directive_specifics, CONVERT_TO_VALUE) | |
1758 .TakeDictValue(); | |
1759 } | |
1760 | |
1761 std::unique_ptr<base::DictionaryValue> ManagedUserSettingSpecificsToValue( | |
1762 const sync_pb::ManagedUserSettingSpecifics& | |
1763 managed_user_setting_specifics) { | |
1764 return ManagedUserSettingSpecificsVisit(managed_user_setting_specifics, | |
1765 CONVERT_TO_VALUE) | |
1766 .TakeDictValue(); | |
1767 } | |
1768 | |
1769 std::unique_ptr<base::DictionaryValue> ManagedUserSpecificsToValue( | |
1770 const sync_pb::ManagedUserSpecifics& managed_user_specifics) { | |
1771 return ManagedUserSpecificsVisit(managed_user_specifics, CONVERT_TO_VALUE) | |
1772 .TakeDictValue(); | |
1773 } | |
1774 | |
1775 std::unique_ptr<base::DictionaryValue> ManagedUserSharedSettingSpecificsToValue( | |
1776 const sync_pb::ManagedUserSharedSettingSpecifics& | |
1777 managed_user_shared_setting_specifics) { | |
1778 return ManagedUserSharedSettingSpecificsVisit( | |
1779 managed_user_shared_setting_specifics, CONVERT_TO_VALUE) | |
1780 .TakeDictValue(); | |
1781 } | |
1782 | |
1783 std::unique_ptr<base::DictionaryValue> ManagedUserWhitelistSpecificsToValue( | |
1784 const sync_pb::ManagedUserWhitelistSpecifics& | |
1785 managed_user_whitelist_specifics) { | |
1786 return ManagedUserWhitelistSpecificsVisit(managed_user_whitelist_specifics, | |
1787 CONVERT_TO_VALUE) | |
1788 .TakeDictValue(); | |
1789 } | |
1790 | |
1791 std::unique_ptr<base::DictionaryValue> NigoriSpecificsToValue( | |
1792 const sync_pb::NigoriSpecifics& nigori_specifics) { | |
1793 return NigoriSpecificsVisit(nigori_specifics, CONVERT_TO_VALUE) | |
1794 .TakeDictValue(); | |
1795 } | |
1796 | |
1797 std::unique_ptr<base::DictionaryValue> PasswordSpecificsToValue( | |
1798 const sync_pb::PasswordSpecifics& password_specifics) { | |
1799 return PasswordSpecificsVisit(password_specifics, CONVERT_TO_VALUE) | |
1800 .TakeDictValue(); | |
1801 } | |
1802 | |
1803 std::unique_ptr<base::DictionaryValue> PreferenceSpecificsToValue( | |
1804 const sync_pb::PreferenceSpecifics& password_specifics) { | |
1805 return PreferenceSpecificsVisit(password_specifics, CONVERT_TO_VALUE) | |
1806 .TakeDictValue(); | |
1807 } | |
1808 | |
1809 std::unique_ptr<base::DictionaryValue> | |
1810 SyncedNotificationAppInfoSpecificsToValue( | |
1811 const sync_pb::SyncedNotificationAppInfoSpecifics& | |
1812 synced_notification_specifics) { | |
1813 return SyncedNotificationAppInfoSpecificsVisit(synced_notification_specifics, | |
1814 CONVERT_TO_VALUE) | |
1815 .TakeDictValue(); | |
1816 } | |
1817 | |
1818 std::unique_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue( | |
1819 const sync_pb::SyncedNotificationSpecifics& synced_notification_specifics) { | |
1820 return SyncedNotificationSpecificsVisit(synced_notification_specifics, | |
1821 CONVERT_TO_VALUE) | |
1822 .TakeDictValue(); | |
1823 } | |
1824 | |
1825 std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( | |
1826 const sync_pb::SearchEngineSpecifics& search_engine_specifics) { | |
1827 return SearchEngineSpecificsVisit(search_engine_specifics, CONVERT_TO_VALUE) | |
1828 .TakeDictValue(); | |
1829 } | |
1830 | |
1831 std::unique_ptr<base::DictionaryValue> ThemeSpecificsToValue( | |
1832 const sync_pb::ThemeSpecifics& theme_specifics) { | |
1833 return ThemeSpecificsVisit(theme_specifics, CONVERT_TO_VALUE).TakeDictValue(); | |
1834 } | |
1835 | |
1836 std::unique_ptr<base::DictionaryValue> TypedUrlSpecificsToValue( | |
1837 const sync_pb::TypedUrlSpecifics& typed_url_specifics) { | |
1838 return TypedUrlSpecificsVisit(typed_url_specifics, CONVERT_TO_VALUE) | |
1839 .TakeDictValue(); | |
1840 } | |
1841 | |
1842 std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( | |
1843 const sync_pb::WalletMaskedCreditCard& wallet_masked_card) { | |
1844 return WalletMaskedCreditCardVisit(wallet_masked_card, CONVERT_TO_VALUE) | |
1845 .TakeDictValue(); | |
1846 } | |
1847 | |
1848 std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue( | |
1849 const sync_pb::WalletPostalAddress& wallet_postal_address) { | |
1850 return WalletPostalAddressVisit(wallet_postal_address, CONVERT_TO_VALUE) | |
1851 .TakeDictValue(); | |
1852 } | |
1853 | |
1854 std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue( | |
1855 const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics) { | |
1856 return WifiCredentialSpecificsVisit(wifi_credential_specifics, | |
1857 CONVERT_TO_VALUE) | |
1858 .TakeDictValue(); | |
1859 } | |
1860 | |
1861 std::unique_ptr<base::DictionaryValue> EntitySpecificsToValue( | |
1862 const sync_pb::EntitySpecifics& specifics) { | |
1863 return EntitySpecificsVisit(specifics, CONVERT_TO_VALUE).TakeDictValue(); | |
1864 } | |
1865 | |
1866 std::unique_ptr<base::DictionaryValue> SyncEntityToValue( | |
1867 const sync_pb::SyncEntity& entity, | |
1868 bool include_specifics) { | |
1869 return SyncEntityVisit(entity, include_specifics, CONVERT_TO_VALUE) | |
1870 .TakeDictValue(); | |
1871 } | |
1872 | |
1873 std::unique_ptr<base::DictionaryValue> ClientToServerMessageToValue( | |
1874 const sync_pb::ClientToServerMessage& proto, | |
1875 bool include_specifics) { | |
1876 return ClientToServerMessageVisit(proto, include_specifics, CONVERT_TO_VALUE) | |
1877 .TakeDictValue(); | |
1878 } | |
1879 | |
1880 std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue( | |
1881 const sync_pb::ClientToServerResponse& proto, | |
1882 bool include_specifics) { | |
1883 return ClientToServerResponseVisit(proto, include_specifics, CONVERT_TO_VALUE) | |
1884 .TakeDictValue(); | |
1885 } | |
1886 | |
1887 std::unique_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue( | |
1888 const sync_pb::DatatypeAssociationStats& proto) { | |
1889 return DatatypeAssociationStatsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); | |
1890 } | |
1891 | |
1892 std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue( | |
1893 const sync_pb::DebugEventInfo& proto) { | |
1894 return DebugEventInfoVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); | |
1895 } | |
1896 | |
1897 std::unique_ptr<base::DictionaryValue> DebugInfoToValue( | |
1898 const sync_pb::DebugInfo& proto) { | |
1899 return DebugInfoVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); | |
1900 } | |
1901 | |
1902 std::unique_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue( | |
1903 const sync_pb::SyncCycleCompletedEventInfo& proto) { | |
1904 return SyncCycleCompletedEventInfoVisit(proto, CONVERT_TO_VALUE) | |
1905 .TakeDictValue(); | |
1906 } | |
1907 | |
1908 std::unique_ptr<base::DictionaryValue> ClientConfigParamsToValue( | |
1909 const sync_pb::ClientConfigParams& proto) { | |
1910 return ClientConfigParamsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); | |
1080 } | 1911 } |
1081 | 1912 |
1082 std::unique_ptr<base::DictionaryValue> AttachmentIdProtoToValue( | 1913 std::unique_ptr<base::DictionaryValue> AttachmentIdProtoToValue( |
1083 const sync_pb::AttachmentIdProto& proto) { | 1914 const sync_pb::AttachmentIdProto& proto) { |
1084 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1915 return AttachmentIdProtoVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
1085 SET_STR(unique_id); | 1916 } |
1086 return value; | 1917 |
1087 } | 1918 size_t GetEntitySpecificsSize(const sync_pb::EntitySpecifics& specifics) { |
1088 | 1919 return EntitySpecificsVisit(specifics, MEMORY_USAGE).memory_usage + |
1920 sizeof(specifics); | |
1921 } | |
1922 | |
1923 #undef SET_WITH_EXPR | |
1089 #undef SET_TYPE | 1924 #undef SET_TYPE |
1090 #undef SET | 1925 #undef SET |
1091 #undef SET_REP | 1926 #undef SET_REP |
1927 #undef SET_ENUM | |
1092 | 1928 |
1093 #undef SET_BOOL | 1929 #undef SET_BOOL |
1094 #undef SET_BYTES | 1930 #undef SET_BYTES |
1095 #undef SET_INT32 | 1931 #undef SET_INT32 |
1096 #undef SET_INT64 | 1932 #undef SET_INT64 |
1097 #undef SET_INT64_REP | 1933 #undef SET_INT64_REP |
1098 #undef SET_STR | 1934 #undef SET_STR |
1935 #undef SET_TIME_STR | |
1099 #undef SET_STR_REP | 1936 #undef SET_STR_REP |
1100 | 1937 |
1938 #undef SET_EXPERIMENT_ENABLED_FIELD | |
1101 #undef SET_FIELD | 1939 #undef SET_FIELD |
1102 | 1940 |
1103 } // namespace syncer | 1941 } // namespace syncer |
OLD | NEW |