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