Chromium Code Reviews| Index: sync/protocol/proto_value_conversions.cc |
| diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc |
| index fc6192a7b1c36a63f5ce3fc9e5d2feaae81af80b..3c8db97b47d4991cad527d1ee7ea601d549d0921 100644 |
| --- a/sync/protocol/proto_value_conversions.cc |
| +++ b/sync/protocol/proto_value_conversions.cc |
| @@ -51,10 +51,39 @@ namespace syncer { |
| namespace { |
| -// Basic Type -> Value functions. |
| +enum ResultType { |
|
stanisc
2016/07/06 21:50:31
Someone from the current Sync team should review t
ssid
2016/07/19 22:10:35
Not sure what is the alternative here. I can't thi
|
| + MEMORY_USAGE, // Visitors return only the memory usage |
| + CONVERT_TO_VALUE // Visitors return only the dictionary value. |
| +}; |
| + |
| +struct VisitorResult { |
| + VisitorResult(size_t usage) : memory_usage(usage) {} |
| + VisitorResult(std::unique_ptr<base::Value> value) |
| + : memory_usage(0), as_value(std::move(value)) {} |
| + |
| + base::DictionaryValue* as_dict_value() { |
| + DCHECK(as_value); |
| + base::DictionaryValue* value; |
| + as_value->GetAsDictionary(&value); |
| + return value; |
| + } |
| + std::unique_ptr<base::DictionaryValue> TakeDictValue() { |
| + base::DictionaryValue* value; |
| + bool res = as_value.release()->GetAsDictionary(&value); |
| + DCHECK(res); |
| + return base::WrapUnique(value); |
| + } |
| + |
| + size_t memory_usage; |
| + std::unique_ptr<base::Value> as_value; |
| +}; |
| -std::unique_ptr<base::StringValue> MakeInt64Value(int64_t x) { |
| - return base::WrapUnique(new base::StringValue(base::Int64ToString(x))); |
| +VisitorResult MakeInt64Value(int64_t x, const ResultType result_type) { |
| + if (result_type == MEMORY_USAGE) { |
| + return VisitorResult(0); |
| + } |
| + return VisitorResult( |
| + base::WrapUnique(new base::StringValue(base::Int64ToString(x)))); |
| } |
| // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use |
| @@ -65,34 +94,58 @@ std::string Base64EncodeString(const std::string& bytes) { |
| return bytes_base64; |
| } |
| -std::unique_ptr<base::StringValue> MakeStringValue(const std::string& str) { |
| - return base::WrapUnique(new base::StringValue(str)); |
| +VisitorResult MakeStringValue(const std::string& str, |
| + const ResultType result_type) { |
| + if (result_type == MEMORY_USAGE) |
| + return VisitorResult(str.capacity()); |
| + return VisitorResult(base::WrapUnique(new base::StringValue(str))); |
| } |
| // T is the field type, F is either RepeatedField or RepeatedPtrField, |
| // and V is a subclass of Value. |
| -template <class T, class F, class V> |
| -std::unique_ptr<base::ListValue> MakeRepeatedValue(const F& fields, |
| - V (*converter_fn)(T)) { |
| +template <class T, class F> |
| +VisitorResult MakeRepeatedVisit(const F& fields, |
| + VisitorResult (*converter_fn)(T, |
| + const ResultType), |
| + const ResultType result_type) { |
| + if (result_type == MEMORY_USAGE) { |
| + size_t total = 0; |
| + for (typename F::const_iterator it = fields.begin(); it != fields.end(); |
| + ++it) { |
| + total += converter_fn(*it, result_type).memory_usage + sizeof(T); |
| + } |
| + return VisitorResult(total); |
| + } |
| std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| for (typename F::const_iterator it = fields.begin(); it != fields.end(); |
| ++it) { |
| - list->Append(converter_fn(*it)); |
| + list->Append(converter_fn(*it, result_type).as_value); |
| } |
| - return list; |
| + return VisitorResult(std::move(list)); |
| } |
| } // namespace |
| // Helper macros to reduce the amount of boilerplate. |
| -#define SET_TYPE(field, set_fn, transform) \ |
| - if (proto.has_##field()) { \ |
| - value->set_fn(#field, transform(proto.field())); \ |
| +#define SET_WITH_EXPR(field, visit_expr, excess_size) \ |
| + if (result_type == MEMORY_USAGE) { \ |
| + result.memory_usage += visit_expr.memory_usage + excess_size; \ |
| + } else { \ |
| + result.as_dict_value()->Set(#field, visit_expr.as_value); \ |
| + } |
| + |
| +#define SET_TYPE(field, set_fn, transform) \ |
| + if (result_type == CONVERT_TO_VALUE && proto.has_##field()) { \ |
| + result.as_dict_value()->set_fn(#field, transform(proto.field())); \ |
| + } |
| +#define SET(field, fn) \ |
| + if (proto.has_##field()) { \ |
| + SET_WITH_EXPR(field, fn(proto.field(), result_type), \ |
| + sizeof(proto.field())); \ |
| } |
| -#define SET(field, fn) SET_TYPE(field, Set, fn) |
| #define SET_REP(field, fn) \ |
| - value->Set(#field, MakeRepeatedValue(proto.field(), fn)) |
| + SET_WITH_EXPR(field, MakeRepeatedVisit(proto.field(), fn, result_type), 0) |
| #define SET_ENUM(field, fn) SET_TYPE(field, SetString, fn) |
| #define SET_BOOL(field) SET_TYPE(field, SetBoolean, ) |
| @@ -101,92 +154,329 @@ std::unique_ptr<base::ListValue> MakeRepeatedValue(const F& fields, |
| #define SET_INT32_REP(field) SET_REP(field, MakeInt64Value) |
| #define SET_INT64(field) SET_TYPE(field, SetString, base::Int64ToString) |
| #define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) |
| -#define SET_STR(field) SET_TYPE(field, SetString, ) |
| +#define SET_STR(field) \ |
| + if (proto.has_##field()) { \ |
| + SET_WITH_EXPR(field, MakeStringValue(proto.field(), result_type), \ |
| + sizeof(std::string)); \ |
| + } |
| #define SET_TIME_STR(field) SET_TYPE(field, SetString, TimestampToString) |
| #define SET_STR_REP(field) \ |
| - value->Set( \ |
| - #field, \ |
| - MakeRepeatedValue<const std::string&, \ |
| - google::protobuf::RepeatedPtrField<std::string>, \ |
| - std::unique_ptr<base::StringValue>>(proto.field(), \ |
| - MakeStringValue)) |
| -#define SET_EXPERIMENT_ENABLED_FIELD(field) \ |
| - do { \ |
| - if (proto.has_##field() && \ |
| - proto.field().has_enabled()) { \ |
| - value->Set(#field, \ |
| - new base::FundamentalValue( \ |
| - proto.field().enabled())); \ |
| - } \ |
| - } while (0) |
| - |
| -#define SET_FIELD(field, fn) \ |
| - do { \ |
| - if (specifics.has_##field()) { \ |
| - value->Set(#field, fn(specifics.field())); \ |
| - } \ |
| - } while (0) |
| + SET_WITH_EXPR( \ |
| + field, \ |
| + (MakeRepeatedVisit<const std::string&, \ |
| + google::protobuf::RepeatedPtrField<std::string>>( \ |
| + proto.field(), MakeStringValue, result_type)), \ |
| + 0); |
| +#define SET_EXPERIMENT_ENABLED_FIELD(field) \ |
| + if (proto.has_##field()) { \ |
| + if (result_type == MEMORY_USAGE) { \ |
| + result.memory_usage += sizeof(proto.field()); \ |
| + } else if (proto.field().has_enabled()) { \ |
| + result.as_dict_value()->Set( \ |
| + #field, new base::FundamentalValue(proto.field().enabled())); \ |
| + } \ |
| + } |
| + |
| +#define SET_FIELD(field, fn) \ |
| + if (specifics.has_##field()) { \ |
| + SET_WITH_EXPR(field, fn(specifics.field(), result_type), \ |
| + sizeof(specifics.field())); \ |
| + } |
| // If you add another macro, don't forget to add an #undef at the end |
| // of this file, too. |
| -std::unique_ptr<base::DictionaryValue> EncryptedDataToValue( |
| - const sync_pb::EncryptedData& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult EncryptedDataVisit(const sync_pb::EncryptedData& encrypted_data, |
| + const ResultType result_type); |
| + |
| +VisitorResult AppListSpecificsVisit(const sync_pb::AppListSpecifics& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult AppSettingsVisit( |
| + const sync_pb::AppNotificationSettings& app_notification_settings, |
| + const ResultType result_type); |
| + |
| +VisitorResult LinkedAppIconInfoVisit( |
| + const sync_pb::LinkedAppIconInfo& linked_app_icon_info, |
| + const ResultType result_type); |
| + |
| +VisitorResult SessionHeaderVisit(const sync_pb::SessionHeader& session_header, |
| + const ResultType result_type); |
| + |
| +VisitorResult SessionTabVisit(const sync_pb::SessionTab& session_tab, |
| + const ResultType result_type); |
| + |
| +VisitorResult SessionWindowVisit(const sync_pb::SessionWindow& session_window, |
| + const ResultType result_type); |
| + |
| +VisitorResult TabNavigationVisit(const sync_pb::TabNavigation& tab_navigation, |
| + const ResultType result_type); |
| + |
| +VisitorResult NavigationRedirectVisit( |
| + const sync_pb::NavigationRedirect& navigation_redirect, |
| + const ResultType result_type); |
| + |
| +VisitorResult PasswordSpecificsDataVisit( |
| + const sync_pb::PasswordSpecificsData& password_specifics_data, |
| + const ResultType result_type); |
| + |
| +VisitorResult GlobalIdDirectiveVisit( |
| + const sync_pb::GlobalIdDirective& global_id_directive, |
| + const ResultType result_type); |
| + |
| +VisitorResult TimeRangeDirectiveVisit( |
| + const sync_pb::TimeRangeDirective& time_range_directive, |
| + const ResultType result_type); |
| + |
| +VisitorResult SessionSpecificsVisit( |
| + const sync_pb::SessionSpecifics& session_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ArcPackageSpecificsVisit( |
| + const sync_pb::ArcPackageSpecifics& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult AppNotificationVisit( |
| + const sync_pb::AppNotification& app_notification_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult AppSettingSpecificsVisit( |
| + const sync_pb::AppSettingSpecifics& app_setting_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult AppSpecificsVisit(const sync_pb::AppSpecifics& app_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ArticleSpecificsVisit( |
| + const sync_pb::ArticleSpecifics& article_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult AutofillSpecificsVisit( |
| + const sync_pb::AutofillSpecifics& autofill_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult AutofillProfileSpecificsVisit( |
| + const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult WalletMetadataSpecificsVisit( |
| + const sync_pb::WalletMetadataSpecifics& wallet_metadata_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult AutofillWalletSpecificsVisit( |
| + const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult BookmarkSpecificsVisit( |
| + const sync_pb::BookmarkSpecifics& bookmark_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult DeviceInfoSpecificsVisit( |
| + const sync_pb::DeviceInfoSpecifics& device_info_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult DictionarySpecificsVisit( |
| + const sync_pb::DictionarySpecifics& dictionary_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ExperimentsSpecificsVisit( |
| + const sync_pb::ExperimentsSpecifics& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult PriorityPreferenceSpecificsVisit( |
| + const sync_pb::PriorityPreferenceSpecifics& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult ExtensionSettingSpecificsVisit( |
| + const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ExtensionSpecificsVisit( |
| + const sync_pb::ExtensionSpecifics& extension_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult FaviconImageSpecificsVisit( |
| + const sync_pb::FaviconImageSpecifics& favicon_image_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult FaviconTrackingSpecificsVisit( |
| + const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult HistoryDeleteDirectiveSpecificsVisit( |
| + const sync_pb::HistoryDeleteDirectiveSpecifics& |
| + history_delete_directive_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ManagedUserSettingSpecificsVisit( |
| + const sync_pb::ManagedUserSettingSpecifics& managed_user_setting_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ManagedUserSpecificsVisit( |
| + const sync_pb::ManagedUserSpecifics& managed_user_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ManagedUserSharedSettingSpecificsVisit( |
| + const sync_pb::ManagedUserSharedSettingSpecifics& |
| + managed_user_shared_setting_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ManagedUserWhitelistSpecificsVisit( |
| + const sync_pb::ManagedUserWhitelistSpecifics& |
| + managed_user_whitelist_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult NigoriSpecificsVisit( |
| + const sync_pb::NigoriSpecifics& nigori_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult PasswordSpecificsVisit( |
| + const sync_pb::PasswordSpecifics& password_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult PreferenceSpecificsVisit( |
| + const sync_pb::PreferenceSpecifics& password_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult SyncedNotificationAppInfoSpecificsVisit( |
| + const sync_pb::SyncedNotificationAppInfoSpecifics& |
| + synced_notification_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult SyncedNotificationSpecificsVisit( |
| + const sync_pb::SyncedNotificationSpecifics& synced_notification_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult SearchEngineSpecificsVisit( |
| + const sync_pb::SearchEngineSpecifics& search_engine_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ThemeSpecificsVisit( |
| + const sync_pb::ThemeSpecifics& theme_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult TypedUrlSpecificsVisit( |
| + const sync_pb::TypedUrlSpecifics& typed_url_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult WalletMaskedCreditCardVisit( |
| + const sync_pb::WalletMaskedCreditCard& wallet_masked_card, |
| + const ResultType result_type); |
| + |
| +VisitorResult WalletPostalAddressVisit( |
| + const sync_pb::WalletPostalAddress& wallet_postal_address, |
| + const ResultType result_type); |
| + |
| +VisitorResult WifiCredentialSpecificsVisit( |
| + const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult EntitySpecificsVisit(const sync_pb::EntitySpecifics& specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult SyncEntityVisit(const sync_pb::SyncEntity& entity, |
| + bool include_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ClientToServerMessageVisit( |
| + const sync_pb::ClientToServerMessage& proto, |
| + bool include_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult ClientToServerResponseVisit( |
| + const sync_pb::ClientToServerResponse& proto, |
| + bool include_specifics, |
| + const ResultType result_type); |
| + |
| +VisitorResult DatatypeAssociationStatsVisit( |
| + const sync_pb::DatatypeAssociationStats& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult DebugEventInfoVisit(const sync_pb::DebugEventInfo& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult DebugInfoVisit(const sync_pb::DebugInfo& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult SyncCycleCompletedEventInfoVisit( |
| + const sync_pb::SyncCycleCompletedEventInfo& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult ClientConfigParamsVisit(const sync_pb::ClientConfigParams& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult AttachmentIdProtoVisit(const sync_pb::AttachmentIdProto& proto, |
| + const ResultType result_type); |
| + |
| +VisitorResult EncryptedDataVisit(const sync_pb::EncryptedData& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(key_name); |
| // TODO(akalin): Shouldn't blob be of type bytes instead of string? |
| SET_BYTES(blob); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AppSettingsToValue( |
| - const sync_pb::AppNotificationSettings& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult AppSettingsVisit(const sync_pb::AppNotificationSettings& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_BOOL(initial_setup_done); |
| SET_BOOL(disabled); |
| SET_STR(oauth_client_id); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> SessionHeaderToValue( |
| - const sync_pb::SessionHeader& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET_REP(window, SessionWindowToValue); |
| +VisitorResult SessionHeaderVisit(const sync_pb::SessionHeader& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_REP(window, SessionWindowVisit); |
| SET_STR(client_name); |
| SET_ENUM(device_type, GetDeviceTypeString); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> SessionTabToValue( |
| - const sync_pb::SessionTab& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult SessionTabVisit(const sync_pb::SessionTab& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(tab_id); |
| SET_INT32(window_id); |
| SET_INT32(tab_visual_index); |
| SET_INT32(current_navigation_index); |
| SET_BOOL(pinned); |
| SET_STR(extension_app_id); |
| - SET_REP(navigation, TabNavigationToValue); |
| + SET_REP(navigation, TabNavigationVisit); |
| SET_BYTES(favicon); |
| SET_ENUM(favicon_type, GetFaviconTypeString); |
| SET_STR(favicon_source); |
| SET_REP(variation_id, MakeInt64Value); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> SessionWindowToValue( |
| - const sync_pb::SessionWindow& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult SessionWindowVisit(const sync_pb::SessionWindow& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(window_id); |
| SET_INT32(selected_tab_index); |
| SET_INT32_REP(tab); |
| SET_ENUM(browser_type, GetBrowserTypeString); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> TabNavigationToValue( |
| - const sync_pb::TabNavigation& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult TabNavigationVisit(const sync_pb::TabNavigation& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(virtual_url); |
| SET_STR(referrer); |
| SET_STR(title); |
| @@ -207,22 +497,27 @@ std::unique_ptr<base::DictionaryValue> TabNavigationToValue( |
| SET_INT32(http_status_code); |
| SET_INT32(obsolete_referrer_policy); |
| SET_BOOL(is_restored); |
| - SET_REP(navigation_redirect, NavigationRedirectToValue); |
| + SET_REP(navigation_redirect, NavigationRedirectVisit); |
| SET_STR(last_navigation_redirect_url); |
| SET_INT32(correct_referrer_policy); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> NavigationRedirectToValue( |
| - const sync_pb::NavigationRedirect& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult NavigationRedirectVisit(const sync_pb::NavigationRedirect& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(url); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( |
| - const sync_pb::PasswordSpecificsData& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult PasswordSpecificsDataVisit( |
| + const sync_pb::PasswordSpecificsData& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(scheme); |
| SET_STR(signon_realm); |
| SET_STR(origin); |
| @@ -230,7 +525,8 @@ std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( |
| SET_STR(username_element); |
| SET_STR(username_value); |
| SET_STR(password_element); |
| - value->SetString("password_value", "<redacted>"); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_dict_value()->SetString("password_value", "<redacted>"); |
| SET_BOOL(ssl_valid); |
| SET_BOOL(preferred); |
| SET_INT64(date_created); |
| @@ -240,29 +536,35 @@ std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( |
| SET_STR(display_name); |
| SET_STR(avatar_url); |
| SET_STR(federation_url); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> GlobalIdDirectiveToValue( |
| - const sync_pb::GlobalIdDirective& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult GlobalIdDirectiveVisit(const sync_pb::GlobalIdDirective& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT64_REP(global_id); |
| SET_INT64(start_time_usec); |
| SET_INT64(end_time_usec); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> TimeRangeDirectiveToValue( |
| - const sync_pb::TimeRangeDirective& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult TimeRangeDirectiveVisit(const sync_pb::TimeRangeDirective& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT64(start_time_usec); |
| SET_INT64(end_time_usec); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue( |
| - const sync_pb::AppListSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult AppListSpecificsVisit(const sync_pb::AppListSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(item_id); |
| SET_ENUM(item_type, GetAppListItemTypeString); |
| SET_STR(item_name); |
| @@ -270,23 +572,28 @@ std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue( |
| SET_STR(item_ordinal); |
| SET_STR(item_pin_ordinal); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ArcPackageSpecificsToValue( |
| - const sync_pb::ArcPackageSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ArcPackageSpecificsVisit( |
| + const sync_pb::ArcPackageSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(package_name); |
| SET_INT32(package_version); |
| SET_INT64(last_backup_android_id); |
| SET_INT64(last_backup_time); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AppNotificationToValue( |
| - const sync_pb::AppNotification& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult AppNotificationVisit(const sync_pb::AppNotification& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(guid); |
| SET_STR(app_id); |
| SET_INT64(creation_timestamp_ms); |
| @@ -294,53 +601,65 @@ std::unique_ptr<base::DictionaryValue> AppNotificationToValue( |
| SET_STR(body_text); |
| SET_STR(link_url); |
| SET_STR(link_text); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AppSettingSpecificsToValue( |
| - const sync_pb::AppSettingSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET(extension_setting, ExtensionSettingSpecificsToValue); |
| - return value; |
| +VisitorResult AppSettingSpecificsVisit( |
| + const sync_pb::AppSettingSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET(extension_setting, ExtensionSettingSpecificsVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> LinkedAppIconInfoToValue( |
| - const sync_pb::LinkedAppIconInfo& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult LinkedAppIconInfoVisit(const sync_pb::LinkedAppIconInfo& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(url); |
| SET_INT32(size); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AppSpecificsToValue( |
| - const sync_pb::AppSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET(extension, ExtensionSpecificsToValue); |
| - SET(notification_settings, AppSettingsToValue); |
| +VisitorResult AppSpecificsVisit(const sync_pb::AppSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET(extension, ExtensionSpecificsVisit); |
| + SET(notification_settings, AppSettingsVisit); |
| SET_STR(app_launch_ordinal); |
| SET_STR(page_ordinal); |
| SET_ENUM(launch_type, GetLaunchTypeString); |
| SET_STR(bookmark_app_url); |
| SET_STR(bookmark_app_description); |
| SET_STR(bookmark_app_icon_color); |
| - SET_REP(linked_app_icons, LinkedAppIconInfoToValue); |
| + SET_REP(linked_app_icons, LinkedAppIconInfoVisit); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AutofillSpecificsToValue( |
| - const sync_pb::AutofillSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult AutofillSpecificsVisit(const sync_pb::AutofillSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(name); |
| SET_STR(value); |
| SET_INT64_REP(usage_timestamp); |
| - SET(profile, AutofillProfileSpecificsToValue); |
| - return value; |
| + SET(profile, AutofillProfileSpecificsVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( |
| - const sync_pb::AutofillProfileSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult AutofillProfileSpecificsVisit( |
| + const sync_pb::AutofillProfileSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(guid); |
| SET_STR(origin); |
| SET_INT64(use_count); |
| @@ -366,110 +685,138 @@ std::unique_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( |
| SET_STR(address_home_language_code); |
| SET_STR_REP(phone_home_whole_number); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue( |
| - const sync_pb::WalletMetadataSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult WalletMetadataSpecificsVisit( |
| + const sync_pb::WalletMetadataSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_ENUM(type, GetWalletMetadataTypeString); |
| SET_STR(id); |
| SET_INT64(use_count); |
| SET_INT64(use_date); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( |
| - const sync_pb::AutofillWalletSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult AutofillWalletSpecificsVisit( |
| + const sync_pb::AutofillWalletSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_ENUM(type, GetWalletInfoTypeString); |
| if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { |
| - value->Set("masked_card", |
| - WalletMaskedCreditCardToValue(proto.masked_card())); |
| + SET_WITH_EXPR(masked_card, |
| + WalletMaskedCreditCardVisit(proto.masked_card(), result_type), |
| + sizeof(sync_pb::WalletMaskedCreditCard)); |
| } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) { |
| - value->Set("address", |
| - WalletPostalAddressToValue(proto.address())); |
| + SET_WITH_EXPR(address, |
| + WalletPostalAddressVisit(proto.address(), result_type), |
| + sizeof(sync_pb::WalletPostalAddress)); |
| } |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> MetaInfoToValue( |
| - const sync_pb::MetaInfo& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult MetaInfoVisit(const sync_pb::MetaInfo& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(key); |
| SET_STR(value); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> BookmarkSpecificsToValue( |
| - const sync_pb::BookmarkSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult BookmarkSpecificsVisit(const sync_pb::BookmarkSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(url); |
| SET_BYTES(favicon); |
| SET_STR(title); |
| SET_INT64(creation_time_us); |
| SET_STR(icon_url); |
| - SET_REP(meta_info, &MetaInfoToValue); |
| - return value; |
| + SET_REP(meta_info, &MetaInfoVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue( |
| - const sync_pb::DeviceInfoSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult DeviceInfoSpecificsVisit( |
| + const sync_pb::DeviceInfoSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(cache_guid); |
| SET_STR(client_name); |
| SET_ENUM(device_type, GetDeviceTypeString); |
| SET_STR(sync_user_agent); |
| SET_STR(chrome_version); |
| SET_STR(signin_scoped_device_id); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> DictionarySpecificsToValue( |
| - const sync_pb::DictionarySpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult DictionarySpecificsVisit( |
| + const sync_pb::DictionarySpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(word); |
| - return value; |
| + return result; |
| } |
| namespace { |
| -std::unique_ptr<base::DictionaryValue> FaviconSyncFlagsToValue( |
| - const sync_pb::FaviconSyncFlags& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult FaviconSyncFlagsVisit(const sync_pb::FaviconSyncFlags& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_BOOL(enabled); |
| SET_INT32(favicon_sync_limit); |
| - return value; |
| + return result; |
| } |
| } // namespace |
| -std::unique_ptr<base::DictionaryValue> ExperimentsSpecificsToValue( |
| - const sync_pb::ExperimentsSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ExperimentsSpecificsVisit( |
| + const sync_pb::ExperimentsSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption); |
| SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives); |
| SET_EXPERIMENT_ENABLED_FIELD(autofill_culling); |
| SET_EXPERIMENT_ENABLED_FIELD(pre_commit_update_avoidance); |
| - SET(favicon_sync, FaviconSyncFlagsToValue); |
| + SET(favicon_sync, FaviconSyncFlagsVisit); |
| SET_EXPERIMENT_ENABLED_FIELD(gcm_channel); |
| SET_EXPERIMENT_ENABLED_FIELD(gcm_invalidations); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ExtensionSettingSpecificsToValue( |
| - const sync_pb::ExtensionSettingSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ExtensionSettingSpecificsVisit( |
| + const sync_pb::ExtensionSettingSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(extension_id); |
| SET_STR(key); |
| SET_STR(value); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ExtensionSpecificsToValue( |
| - const sync_pb::ExtensionSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ExtensionSpecificsVisit(const sync_pb::ExtensionSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(id); |
| SET_STR(version); |
| SET_STR(update_url); |
| @@ -480,90 +827,115 @@ std::unique_ptr<base::DictionaryValue> ExtensionSpecificsToValue( |
| SET_BOOL(installed_by_custodian); |
| SET_BOOL(all_urls_enabled); |
| SET_INT32(disable_reasons); |
| - return value; |
| + return result; |
| } |
| namespace { |
| -std::unique_ptr<base::DictionaryValue> FaviconDataToValue( |
| - const sync_pb::FaviconData& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult FaviconDataVisit(const sync_pb::FaviconData& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_BYTES(favicon); |
| SET_INT32(width); |
| SET_INT32(height); |
| - return value; |
| + return result; |
| } |
| } // namespace |
| -std::unique_ptr<base::DictionaryValue> FaviconImageSpecificsToValue( |
| - const sync_pb::FaviconImageSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult FaviconImageSpecificsVisit( |
| + const sync_pb::FaviconImageSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(favicon_url); |
| - SET(favicon_web, FaviconDataToValue); |
| - SET(favicon_web_32, FaviconDataToValue); |
| - SET(favicon_touch_64, FaviconDataToValue); |
| - SET(favicon_touch_precomposed_64, FaviconDataToValue); |
| - return value; |
| -} |
| - |
| -std::unique_ptr<base::DictionaryValue> FaviconTrackingSpecificsToValue( |
| - const sync_pb::FaviconTrackingSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| + SET(favicon_web, FaviconDataVisit); |
| + SET(favicon_web_32, FaviconDataVisit); |
| + SET(favicon_touch_64, FaviconDataVisit); |
| + SET(favicon_touch_precomposed_64, FaviconDataVisit); |
| + return result; |
| +} |
| + |
| +VisitorResult FaviconTrackingSpecificsVisit( |
| + const sync_pb::FaviconTrackingSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(favicon_url); |
| SET_INT64(last_visit_time_ms) |
| SET_BOOL(is_bookmarked); |
| - return value; |
| -} |
| - |
| -std::unique_ptr<base::DictionaryValue> HistoryDeleteDirectiveSpecificsToValue( |
| - const sync_pb::HistoryDeleteDirectiveSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET(global_id_directive, GlobalIdDirectiveToValue); |
| - SET(time_range_directive, TimeRangeDirectiveToValue); |
| - return value; |
| -} |
| - |
| -std::unique_ptr<base::DictionaryValue> ManagedUserSettingSpecificsToValue( |
| - const sync_pb::ManagedUserSettingSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| + return result; |
| +} |
| + |
| +VisitorResult HistoryDeleteDirectiveSpecificsVisit( |
| + const sync_pb::HistoryDeleteDirectiveSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET(global_id_directive, GlobalIdDirectiveVisit); |
| + SET(time_range_directive, TimeRangeDirectiveVisit); |
| + return result; |
| +} |
| + |
| +VisitorResult ManagedUserSettingSpecificsVisit( |
| + const sync_pb::ManagedUserSettingSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(name); |
| SET_STR(value); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ManagedUserSpecificsToValue( |
| - const sync_pb::ManagedUserSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ManagedUserSpecificsVisit( |
| + const sync_pb::ManagedUserSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(id); |
| SET_STR(name); |
| SET_BOOL(acknowledged); |
| SET_STR(master_key); |
| SET_STR(chrome_avatar); |
| SET_STR(chromeos_avatar); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ManagedUserSharedSettingSpecificsToValue( |
| - const sync_pb::ManagedUserSharedSettingSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ManagedUserSharedSettingSpecificsVisit( |
| + const sync_pb::ManagedUserSharedSettingSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(mu_id); |
| SET_STR(key); |
| SET_STR(value); |
| SET_BOOL(acknowledged); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ManagedUserWhitelistSpecificsToValue( |
| - const sync_pb::ManagedUserWhitelistSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ManagedUserWhitelistSpecificsVisit( |
| + const sync_pb::ManagedUserWhitelistSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(id); |
| SET_STR(name); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> NigoriSpecificsToValue( |
| - const sync_pb::NigoriSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET(encryption_keybag, EncryptedDataToValue); |
| +VisitorResult NigoriSpecificsVisit(const sync_pb::NigoriSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET(encryption_keybag, EncryptedDataVisit); |
| SET_BOOL(keybag_is_frozen); |
| SET_BOOL(encrypt_bookmarks); |
| SET_BOOL(encrypt_preferences); |
| @@ -585,64 +957,84 @@ std::unique_ptr<base::DictionaryValue> NigoriSpecificsToValue( |
| SET_BOOL(server_only_was_missing_keystore_migration_time); |
| SET_BOOL(sync_tab_favicons); |
| SET_ENUM(passphrase_type, PassphraseTypeString); |
| - SET(keystore_decryptor_token, EncryptedDataToValue); |
| + SET(keystore_decryptor_token, EncryptedDataVisit); |
| SET_INT64(keystore_migration_time); |
| SET_INT64(custom_passphrase_time); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ArticlePageToValue( |
| - const sync_pb::ArticlePage& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ArticlePageVisit(const sync_pb::ArticlePage& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(url); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ArticleSpecificsToValue( |
| - const sync_pb::ArticleSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ArticleSpecificsVisit(const sync_pb::ArticleSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(entry_id); |
| SET_STR(title); |
| - SET_REP(pages, ArticlePageToValue); |
| - return value; |
| + SET_REP(pages, ArticlePageVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> PasswordSpecificsToValue( |
| - const sync_pb::PasswordSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET(encrypted, EncryptedDataToValue); |
| - return value; |
| +VisitorResult PasswordSpecificsVisit(const sync_pb::PasswordSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET(encrypted, EncryptedDataVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> PreferenceSpecificsToValue( |
| - const sync_pb::PreferenceSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult PreferenceSpecificsVisit( |
| + const sync_pb::PreferenceSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(name); |
| SET_STR(value); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue( |
| - const sync_pb::PriorityPreferenceSpecifics& specifics) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET_FIELD(preference, PreferenceSpecificsToValue); |
| - return value; |
| +VisitorResult PriorityPreferenceSpecificsVisit( |
| + const sync_pb::PriorityPreferenceSpecifics& specifics, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_FIELD(preference, PreferenceSpecificsVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> |
| -SyncedNotificationAppInfoSpecificsToValue( |
| - const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { |
| - return base::WrapUnique(new base::DictionaryValue()); |
| +VisitorResult SyncedNotificationAppInfoSpecificsVisit( |
| + const sync_pb::SyncedNotificationAppInfoSpecifics& proto, |
| + const ResultType result_type) { |
| + if (result_type == MEMORY_USAGE) |
| + return VisitorResult(sizeof(sync_pb::SyncedNotificationAppInfoSpecifics)); |
| + return VisitorResult(base::WrapUnique(new base::DictionaryValue())); |
| } |
| -std::unique_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue( |
| - const sync_pb::SyncedNotificationSpecifics& proto) { |
| - return base::WrapUnique(new base::DictionaryValue()); |
| +VisitorResult SyncedNotificationSpecificsVisit( |
| + const sync_pb::SyncedNotificationSpecifics& proto, |
| + const ResultType result_type) { |
| + if (result_type == MEMORY_USAGE) |
| + return VisitorResult(sizeof(sync_pb::SyncedNotificationSpecifics)); |
| + return VisitorResult(base::WrapUnique(new base::DictionaryValue())); |
| } |
| -std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( |
| - const sync_pb::SearchEngineSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult SearchEngineSpecificsVisit( |
| + const sync_pb::SearchEngineSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(short_name); |
| SET_STR(keyword); |
| SET_STR(favicon_url); |
| @@ -666,44 +1058,53 @@ std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( |
| SET_STR(instant_url_post_params); |
| SET_STR(image_url_post_params); |
| SET_STR(new_tab_url); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> SessionSpecificsToValue( |
| - const sync_pb::SessionSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult SessionSpecificsVisit(const sync_pb::SessionSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(session_tag); |
| - SET(header, SessionHeaderToValue); |
| - SET(tab, SessionTabToValue); |
| + SET(header, SessionHeaderVisit); |
| + SET(tab, SessionTabVisit); |
| SET_INT32(tab_node_id); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ThemeSpecificsToValue( |
| - const sync_pb::ThemeSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ThemeSpecificsVisit(const sync_pb::ThemeSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_BOOL(use_custom_theme); |
| SET_BOOL(use_system_theme_by_default); |
| SET_STR(custom_theme_name); |
| SET_STR(custom_theme_id); |
| SET_STR(custom_theme_update_url); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> TypedUrlSpecificsToValue( |
| - const sync_pb::TypedUrlSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult TypedUrlSpecificsVisit(const sync_pb::TypedUrlSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(url); |
| SET_STR(title); |
| SET_BOOL(hidden); |
| SET_INT64_REP(visits); |
| SET_INT32_REP(visit_transitions); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( |
| - const sync_pb::WalletMaskedCreditCard& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult WalletMaskedCreditCardVisit( |
| + const sync_pb::WalletMaskedCreditCard& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(id); |
| SET_ENUM(status, GetWalletCardStatusString); |
| SET_STR(name_on_card); |
| @@ -712,12 +1113,15 @@ std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( |
| SET_INT32(exp_month); |
| SET_INT32(exp_year); |
| SET_STR(billing_address_id); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue( |
| - const sync_pb::WalletPostalAddress& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult WalletPostalAddressVisit( |
| + const sync_pb::WalletPostalAddress& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(id); |
| SET_STR(recipient_name); |
| SET_STR(company_name); |
| @@ -731,74 +1135,88 @@ std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue( |
| SET_STR(country_code); |
| SET_STR(phone_number); |
| SET_STR(language_code); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue( |
| - const sync_pb::WifiCredentialSpecifics& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult WifiCredentialSpecificsVisit( |
| + const sync_pb::WifiCredentialSpecifics& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_BYTES(ssid); |
| SET_ENUM(security_class, GetWifiCredentialSecurityClassString); |
| SET_BYTES(passphrase); |
| - return value; |
| -} |
| - |
| -std::unique_ptr<base::DictionaryValue> EntitySpecificsToValue( |
| - const sync_pb::EntitySpecifics& specifics) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET_FIELD(app, AppSpecificsToValue); |
| - SET_FIELD(app_list, AppListSpecificsToValue); |
| - SET_FIELD(app_notification, AppNotificationToValue); |
| - SET_FIELD(app_setting, AppSettingSpecificsToValue); |
| - SET_FIELD(arc_package, ArcPackageSpecificsToValue); |
| - SET_FIELD(article, ArticleSpecificsToValue); |
| - SET_FIELD(autofill, AutofillSpecificsToValue); |
| - SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); |
| - SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue); |
| - SET_FIELD(wallet_metadata, WalletMetadataSpecificsToValue); |
| - SET_FIELD(bookmark, BookmarkSpecificsToValue); |
| - SET_FIELD(device_info, DeviceInfoSpecificsToValue); |
| - SET_FIELD(dictionary, DictionarySpecificsToValue); |
| - SET_FIELD(experiments, ExperimentsSpecificsToValue); |
| - SET_FIELD(extension, ExtensionSpecificsToValue); |
| - SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); |
| - SET_FIELD(favicon_image, FaviconImageSpecificsToValue); |
| - SET_FIELD(favicon_tracking, FaviconTrackingSpecificsToValue); |
| - SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); |
| - SET_FIELD(managed_user_setting, ManagedUserSettingSpecificsToValue); |
| + return result; |
| +} |
| + |
| +VisitorResult EntitySpecificsVisit(const sync_pb::EntitySpecifics& specifics, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_FIELD(app, AppSpecificsVisit); |
| + SET_FIELD(app_list, AppListSpecificsVisit); |
| + SET_FIELD(app_notification, AppNotificationVisit); |
| + SET_FIELD(app_setting, AppSettingSpecificsVisit); |
| + SET_FIELD(arc_package, ArcPackageSpecificsVisit); |
| + SET_FIELD(article, ArticleSpecificsVisit); |
| + SET_FIELD(autofill, AutofillSpecificsVisit); |
| + SET_FIELD(autofill_profile, AutofillProfileSpecificsVisit); |
| + SET_FIELD(autofill_wallet, AutofillWalletSpecificsVisit); |
| + SET_FIELD(wallet_metadata, WalletMetadataSpecificsVisit); |
| + SET_FIELD(bookmark, BookmarkSpecificsVisit); |
| + SET_FIELD(device_info, DeviceInfoSpecificsVisit); |
| + SET_FIELD(dictionary, DictionarySpecificsVisit); |
| + SET_FIELD(experiments, ExperimentsSpecificsVisit); |
| + SET_FIELD(extension, ExtensionSpecificsVisit); |
| + SET_FIELD(extension_setting, ExtensionSettingSpecificsVisit); |
| + SET_FIELD(favicon_image, FaviconImageSpecificsVisit); |
| + SET_FIELD(favicon_tracking, FaviconTrackingSpecificsVisit); |
| + SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsVisit); |
| + SET_FIELD(managed_user_setting, ManagedUserSettingSpecificsVisit); |
| SET_FIELD(managed_user_shared_setting, |
| - ManagedUserSharedSettingSpecificsToValue); |
| - SET_FIELD(managed_user, ManagedUserSpecificsToValue); |
| - SET_FIELD(managed_user_whitelist, ManagedUserWhitelistSpecificsToValue); |
| - SET_FIELD(nigori, NigoriSpecificsToValue); |
| - SET_FIELD(password, PasswordSpecificsToValue); |
| - SET_FIELD(preference, PreferenceSpecificsToValue); |
| - SET_FIELD(priority_preference, PriorityPreferenceSpecificsToValue); |
| - SET_FIELD(search_engine, SearchEngineSpecificsToValue); |
| - SET_FIELD(session, SessionSpecificsToValue); |
| - SET_FIELD(synced_notification, SyncedNotificationSpecificsToValue); |
| + ManagedUserSharedSettingSpecificsVisit); |
| + SET_FIELD(managed_user, ManagedUserSpecificsVisit); |
| + SET_FIELD(managed_user_whitelist, ManagedUserWhitelistSpecificsVisit); |
| + SET_FIELD(nigori, NigoriSpecificsVisit); |
| + SET_FIELD(password, PasswordSpecificsVisit); |
| + SET_FIELD(preference, PreferenceSpecificsVisit); |
| + SET_FIELD(priority_preference, PriorityPreferenceSpecificsVisit); |
| + SET_FIELD(search_engine, SearchEngineSpecificsVisit); |
| + SET_FIELD(session, SessionSpecificsVisit); |
| + SET_FIELD(synced_notification, SyncedNotificationSpecificsVisit); |
| SET_FIELD(synced_notification_app_info, |
| - SyncedNotificationAppInfoSpecificsToValue); |
| - SET_FIELD(theme, ThemeSpecificsToValue); |
| - SET_FIELD(typed_url, TypedUrlSpecificsToValue); |
| - SET_FIELD(wifi_credential, WifiCredentialSpecificsToValue); |
| - return value; |
| + SyncedNotificationAppInfoSpecificsVisit); |
| + SET_FIELD(theme, ThemeSpecificsVisit); |
| + SET_FIELD(typed_url, TypedUrlSpecificsVisit); |
| + SET_FIELD(wifi_credential, WifiCredentialSpecificsVisit); |
| + return result; |
| } |
| namespace { |
| -base::StringValue* UniquePositionToStringValue( |
| - const sync_pb::UniquePosition& proto) { |
| +VisitorResult UniquePositionToStringValue(const sync_pb::UniquePosition& proto, |
| + const ResultType result_type) { |
| + if (result_type == MEMORY_USAGE) { |
| + VisitorResult result(0); |
| + SET_STR(compressed_value); |
| + SET_STR(custom_compressed_v1); |
| + return result; |
| + } |
| UniquePosition pos = UniquePosition::FromProto(proto); |
| - return new base::StringValue(pos.ToDebugString()); |
| + return VisitorResult( |
| + base::WrapUnique(new base::StringValue(pos.ToDebugString()))); |
| } |
| } // namespace |
| -std::unique_ptr<base::DictionaryValue> SyncEntityToValue( |
| - const sync_pb::SyncEntity& proto, |
| - bool include_specifics) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult SyncEntityVisit(const sync_pb::SyncEntity& proto, |
| + bool include_specifics, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(id_string); |
| SET_STR(parent_id_string); |
| SET_STR(old_parent_id); |
| @@ -816,111 +1234,143 @@ std::unique_ptr<base::DictionaryValue> SyncEntityToValue( |
| SET_STR(originator_cache_guid); |
| SET_STR(originator_client_item_id); |
| if (include_specifics) |
| - SET(specifics, EntitySpecificsToValue); |
| + SET(specifics, EntitySpecificsVisit); |
| SET_BOOL(folder); |
| SET_STR(client_defined_unique_tag); |
| - SET_REP(attachment_id, AttachmentIdProtoToValue); |
| - return value; |
| + SET_REP(attachment_id, AttachmentIdProtoVisit); |
| + return result; |
| } |
| namespace { |
| -base::ListValue* SyncEntitiesToValue( |
| +VisitorResult SyncEntitiesVisit( |
| const ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, |
| - bool include_specifics) { |
| - base::ListValue* list = new base::ListValue(); |
| + bool include_specifics, |
| + const ResultType result_type) { |
| ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it; |
| + if (result_type == MEMORY_USAGE) { |
| + size_t total = 0; |
| + for (it = entities.begin(); it != entities.end(); ++it) { |
| + total += |
| + SyncEntityVisit(*it, include_specifics, result_type).memory_usage + |
| + sizeof(sync_pb::SyncEntity); |
| + } |
| + return VisitorResult(total); |
| + } |
| + std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| for (it = entities.begin(); it != entities.end(); ++it) { |
| - list->Append(SyncEntityToValue(*it, include_specifics)); |
| + list->Append(SyncEntityVisit(*it, include_specifics, result_type).as_value); |
| } |
| - |
| - return list; |
| + return VisitorResult(std::move(list)); |
| } |
| -std::unique_ptr<base::DictionaryValue> ChromiumExtensionActivityToValue( |
| - const sync_pb::ChromiumExtensionsActivity& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ChromiumExtensionActivityVisit( |
| + const sync_pb::ChromiumExtensionsActivity& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(extension_id); |
| SET_INT32(bookmark_writes_since_last_commit); |
| - return value; |
| -} |
| - |
| -std::unique_ptr<base::DictionaryValue> CommitMessageToValue( |
| - const sync_pb::CommitMessage& proto, |
| - bool include_specifics) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - value->Set("entries", |
| - SyncEntitiesToValue(proto.entries(), include_specifics)); |
| + return result; |
| +} |
| + |
| +VisitorResult CommitMessageVisit(const sync_pb::CommitMessage& proto, |
| + bool include_specifics, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_WITH_EXPR( |
| + entries, |
| + SyncEntitiesVisit(proto.entries(), include_specifics, result_type), 0); |
| SET_STR(cache_guid); |
| - SET_REP(extensions_activity, ChromiumExtensionActivityToValue); |
| - SET(config_params, ClientConfigParamsToValue); |
| - return value; |
| + SET_REP(extensions_activity, ChromiumExtensionActivityVisit); |
| + SET(config_params, ClientConfigParamsVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> GetUpdateTriggersToValue( |
| - const sync_pb::GetUpdateTriggers& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult GetUpdateTriggersVisit(const sync_pb::GetUpdateTriggers& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR_REP(notification_hint); |
| SET_BOOL(client_dropped_hints); |
| SET_BOOL(invalidations_out_of_sync); |
| SET_INT64(local_modification_nudges); |
| SET_INT64(datatype_refresh_nudges); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> DataTypeProgressMarkerToValue( |
| - const sync_pb::DataTypeProgressMarker& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult DataTypeProgressMarkerVisit( |
| + const sync_pb::DataTypeProgressMarker& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(data_type_id); |
| SET_BYTES(token); |
| SET_INT64(timestamp_token_for_migration); |
| SET_STR(notification_hint); |
| - SET(get_update_triggers, GetUpdateTriggersToValue); |
| - return value; |
| + SET(get_update_triggers, GetUpdateTriggersVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> DataTypeContextToValue( |
| - const sync_pb::DataTypeContext& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult DataTypeContextVisit(const sync_pb::DataTypeContext& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(data_type_id); |
| SET_STR(context); |
| SET_INT64(version); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue( |
| - const sync_pb::GetUpdatesCallerInfo& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult GetUpdatesCallerInfoVisit( |
| + const sync_pb::GetUpdatesCallerInfo& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_ENUM(source, GetUpdatesSourceString); |
| SET_BOOL(notifications_enabled); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> GetUpdatesMessageToValue( |
| - const sync_pb::GetUpdatesMessage& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET(caller_info, GetUpdatesCallerInfoToValue); |
| +VisitorResult GetUpdatesMessageVisit(const sync_pb::GetUpdatesMessage& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET(caller_info, GetUpdatesCallerInfoVisit); |
| SET_BOOL(fetch_folders); |
| SET_INT32(batch_size); |
| - SET_REP(from_progress_marker, DataTypeProgressMarkerToValue); |
| + SET_REP(from_progress_marker, DataTypeProgressMarkerVisit); |
| SET_BOOL(streaming); |
| SET_BOOL(need_encryption_key); |
| SET_BOOL(create_mobile_bookmarks_folder); |
| SET_ENUM(get_updates_origin, GetUpdatesOriginString); |
| - SET_REP(client_contexts, DataTypeContextToValue); |
| - return value; |
| + SET_REP(client_contexts, DataTypeContextVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ClientStatusToValue( |
| - const sync_pb::ClientStatus& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ClientStatusVisit(const sync_pb::ClientStatus& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_BOOL(hierarchy_conflict_detected); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> EntryResponseToValue( |
| - const sync_pb::CommitResponse::EntryResponse& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult EntryResponseVisit( |
| + const sync_pb::CommitResponse::EntryResponse& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_ENUM(response_type, GetResponseTypeString); |
| SET_STR(id_string); |
| SET_STR(parent_id_string); |
| @@ -929,93 +1379,114 @@ std::unique_ptr<base::DictionaryValue> EntryResponseToValue( |
| SET_STR(name); |
| SET_STR(error_message); |
| SET_INT64(mtime); |
| - return value; |
| -} |
| - |
| -std::unique_ptr<base::DictionaryValue> CommitResponseToValue( |
| - const sync_pb::CommitResponse& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET_REP(entryresponse, EntryResponseToValue); |
| - return value; |
| -} |
| - |
| -std::unique_ptr<base::DictionaryValue> GetUpdatesResponseToValue( |
| - const sync_pb::GetUpdatesResponse& proto, |
| - bool include_specifics) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - value->Set("entries", |
| - SyncEntitiesToValue(proto.entries(), include_specifics)); |
| + return result; |
| +} |
| + |
| +VisitorResult CommitResponseVisit(const sync_pb::CommitResponse& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_REP(entryresponse, EntryResponseVisit); |
| + return result; |
| +} |
| + |
| +VisitorResult GetUpdatesResponseVisit(const sync_pb::GetUpdatesResponse& proto, |
| + bool include_specifics, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_WITH_EXPR( |
| + entries, |
| + SyncEntitiesVisit(proto.entries(), include_specifics, result_type), 0); |
| SET_INT64(changes_remaining); |
| - SET_REP(new_progress_marker, DataTypeProgressMarkerToValue); |
| - SET_REP(context_mutations, DataTypeContextToValue); |
| - return value; |
| + SET_REP(new_progress_marker, DataTypeProgressMarkerVisit); |
| + SET_REP(context_mutations, DataTypeContextVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ClientCommandToValue( |
| - const sync_pb::ClientCommand& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ClientCommandVisit(const sync_pb::ClientCommand& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(set_sync_poll_interval); |
| SET_INT32(set_sync_long_poll_interval); |
| SET_INT32(max_commit_batch_size); |
| SET_INT32(sessions_commit_delay_seconds); |
| SET_INT32(throttle_delay_seconds); |
| SET_INT32(client_invalidation_hint_buffer_size); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ErrorToValue( |
| - const sync_pb::ClientToServerResponse::Error& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ErrorVisit(const sync_pb::ClientToServerResponse::Error& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_ENUM(error_type, GetErrorTypeString); |
| SET_STR(error_description); |
| SET_STR(url); |
| SET_ENUM(action, GetActionString); |
| - return value; |
| + return result; |
| } |
| } // namespace |
| -std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue( |
| +VisitorResult ClientToServerResponseVisit( |
| const sync_pb::ClientToServerResponse& proto, |
| - bool include_specifics) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET(commit, CommitResponseToValue); |
| + bool include_specifics, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET(commit, CommitResponseVisit); |
| if (proto.has_get_updates()) { |
| - value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(), |
| - include_specifics)); |
| + SET_WITH_EXPR(get_updates, |
| + GetUpdatesResponseVisit(proto.get_updates(), |
| + include_specifics, result_type), |
| + sizeof(proto.get_updates())); |
| } |
| - SET(error, ErrorToValue); |
| + SET(error, ErrorVisit); |
| SET_ENUM(error_code, GetErrorTypeString); |
| SET_STR(error_message); |
| SET_STR(store_birthday); |
| - SET(client_command, ClientCommandToValue); |
| + SET(client_command, ClientCommandVisit); |
| SET_INT32_REP(migrated_data_type_id); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ClientToServerMessageToValue( |
| +VisitorResult ClientToServerMessageVisit( |
| const sync_pb::ClientToServerMessage& proto, |
| - bool include_specifics) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| + bool include_specifics, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_STR(share); |
| SET_INT32(protocol_version); |
| if (proto.has_commit()) { |
| - value->Set("commit", |
| - CommitMessageToValue(proto.commit(), include_specifics)); |
| + SET_WITH_EXPR(commit, CommitMessageVisit(proto.commit(), include_specifics, |
| + result_type), |
| + sizeof(proto.commit())); |
| } |
| - SET(get_updates, GetUpdatesMessageToValue); |
| + SET(get_updates, GetUpdatesMessageVisit); |
| SET_STR(store_birthday); |
| SET_BOOL(sync_problem_detected); |
| - SET(debug_info, DebugInfoToValue); |
| - SET(client_status, ClientStatusToValue); |
| - return value; |
| + SET(debug_info, DebugInfoVisit); |
| + SET(client_status, ClientStatusVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue( |
| - const sync_pb::DatatypeAssociationStats& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult DatatypeAssociationStatsVisit( |
| + const sync_pb::DatatypeAssociationStats& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(data_type_id); |
| SET_INT32(num_local_items_before_association); |
| SET_INT32(num_sync_items_before_association); |
| @@ -1034,61 +1505,426 @@ std::unique_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue( |
| SET_INT64(download_time_us); |
| SET_INT64(association_wait_time_for_high_priority_us); |
| SET_INT64(association_wait_time_for_same_priority_us); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue( |
| - const sync_pb::DebugEventInfo& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult DebugEventInfoVisit(const sync_pb::DebugEventInfo& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_ENUM(singleton_event, SingletonDebugEventTypeString); |
| - SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue); |
| + SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoVisit); |
| SET_INT32(nudging_datatype); |
| SET_INT32_REP(datatypes_notified_from_server); |
| - SET(datatype_association_stats, DatatypeAssociationStatsToValue); |
| - return value; |
| + SET(datatype_association_stats, DatatypeAssociationStatsVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> DebugInfoToValue( |
| - const sync_pb::DebugInfo& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET_REP(events, DebugEventInfoToValue); |
| +VisitorResult DebugInfoVisit(const sync_pb::DebugInfo& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_REP(events, DebugEventInfoVisit); |
| SET_BOOL(cryptographer_ready); |
| SET_BOOL(cryptographer_has_pending_keys); |
| SET_BOOL(events_dropped); |
| - return value; |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue( |
| - const sync_pb::SyncCycleCompletedEventInfo& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult SyncCycleCompletedEventInfoVisit( |
| + const sync_pb::SyncCycleCompletedEventInfo& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32(num_encryption_conflicts); |
| SET_INT32(num_hierarchy_conflicts); |
| SET_INT32(num_server_conflicts); |
| SET_INT32(num_updates_downloaded); |
| SET_INT32(num_reflected_updates_downloaded); |
| - SET(caller_info, GetUpdatesCallerInfoToValue); |
| - return value; |
| + SET(caller_info, GetUpdatesCallerInfoVisit); |
| + return result; |
| } |
| -std::unique_ptr<base::DictionaryValue> ClientConfigParamsToValue( |
| - const sync_pb::ClientConfigParams& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| +VisitorResult ClientConfigParamsVisit(const sync_pb::ClientConfigParams& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| SET_INT32_REP(enabled_type_ids); |
| SET_BOOL(tabs_datatype_enabled); |
| SET_BOOL(cookie_jar_mismatch); |
| - return value; |
| + return result; |
| +} |
| + |
| +VisitorResult AttachmentIdProtoVisit(const sync_pb::AttachmentIdProto& proto, |
| + const ResultType result_type) { |
| + VisitorResult result(0); |
| + if (result_type == CONVERT_TO_VALUE) |
| + result.as_value.reset(new base::DictionaryValue()); |
| + SET_STR(unique_id); |
| + return result; |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> EncryptedDataToValue( |
| + const sync_pb::EncryptedData& encrypted_data) { |
| + return EncryptedDataVisit(encrypted_data, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue( |
| + const sync_pb::AppListSpecifics& proto) { |
| + return AppListSpecificsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AppSettingsToValue( |
| + const sync_pb::AppNotificationSettings& app_notification_settings) { |
| + return AppSettingsVisit(app_notification_settings, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> LinkedAppIconInfoToValue( |
| + const sync_pb::LinkedAppIconInfo& linked_app_icon_info) { |
| + return LinkedAppIconInfoVisit(linked_app_icon_info, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SessionHeaderToValue( |
| + const sync_pb::SessionHeader& session_header) { |
| + return SessionHeaderVisit(session_header, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SessionTabToValue( |
| + const sync_pb::SessionTab& session_tab) { |
| + return SessionTabVisit(session_tab, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SessionWindowToValue( |
| + const sync_pb::SessionWindow& session_window) { |
| + return SessionWindowVisit(session_window, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> TabNavigationToValue( |
| + const sync_pb::TabNavigation& tab_navigation) { |
| + return TabNavigationVisit(tab_navigation, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> NavigationRedirectToValue( |
| + const sync_pb::NavigationRedirect& navigation_redirect) { |
| + return NavigationRedirectVisit(navigation_redirect, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( |
| + const sync_pb::PasswordSpecificsData& password_specifics_data) { |
| + return PasswordSpecificsDataVisit(password_specifics_data, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> GlobalIdDirectiveToValue( |
| + const sync_pb::GlobalIdDirective& global_id_directive) { |
| + return GlobalIdDirectiveVisit(global_id_directive, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> TimeRangeDirectiveToValue( |
| + const sync_pb::TimeRangeDirective& time_range_directive) { |
| + return TimeRangeDirectiveVisit(time_range_directive, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SessionSpecificsToValue( |
| + const sync_pb::SessionSpecifics& session_specifics) { |
| + return SessionSpecificsVisit(session_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ArcPackageSpecificsToValue( |
| + const sync_pb::ArcPackageSpecifics& proto) { |
| + return ArcPackageSpecificsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AppNotificationToValue( |
| + const sync_pb::AppNotification& app_notification_specifics) { |
| + return AppNotificationVisit(app_notification_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AppSettingSpecificsToValue( |
| + const sync_pb::AppSettingSpecifics& app_setting_specifics) { |
| + return AppSettingSpecificsVisit(app_setting_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AppSpecificsToValue( |
| + const sync_pb::AppSpecifics& app_specifics) { |
| + return AppSpecificsVisit(app_specifics, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ArticleSpecificsToValue( |
| + const sync_pb::ArticleSpecifics& article_specifics) { |
| + return ArticleSpecificsVisit(article_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AutofillSpecificsToValue( |
| + const sync_pb::AutofillSpecifics& autofill_specifics) { |
| + return AutofillSpecificsVisit(autofill_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( |
| + const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics) { |
| + return AutofillProfileSpecificsVisit(autofill_profile_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue( |
| + const sync_pb::WalletMetadataSpecifics& wallet_metadata_specifics) { |
| + return WalletMetadataSpecificsVisit(wallet_metadata_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( |
| + const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics) { |
| + return AutofillWalletSpecificsVisit(autofill_wallet_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> BookmarkSpecificsToValue( |
| + const sync_pb::BookmarkSpecifics& bookmark_specifics) { |
| + return BookmarkSpecificsVisit(bookmark_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue( |
| + const sync_pb::DeviceInfoSpecifics& device_info_specifics) { |
| + return DeviceInfoSpecificsVisit(device_info_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> DictionarySpecificsToValue( |
| + const sync_pb::DictionarySpecifics& dictionary_specifics) { |
| + return DictionarySpecificsVisit(dictionary_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ExperimentsSpecificsToValue( |
| + const sync_pb::ExperimentsSpecifics& proto) { |
| + return ExperimentsSpecificsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue( |
| + const sync_pb::PriorityPreferenceSpecifics& proto) { |
| + return PriorityPreferenceSpecificsVisit(proto, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ExtensionSettingSpecificsToValue( |
| + const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics) { |
| + return ExtensionSettingSpecificsVisit(extension_setting_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ExtensionSpecificsToValue( |
| + const sync_pb::ExtensionSpecifics& extension_specifics) { |
| + return ExtensionSpecificsVisit(extension_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> FaviconImageSpecificsToValue( |
| + const sync_pb::FaviconImageSpecifics& favicon_image_specifics) { |
| + return FaviconImageSpecificsVisit(favicon_image_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> FaviconTrackingSpecificsToValue( |
| + const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics) { |
| + return FaviconTrackingSpecificsVisit(favicon_tracking_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> HistoryDeleteDirectiveSpecificsToValue( |
| + const sync_pb::HistoryDeleteDirectiveSpecifics& |
| + history_delete_directive_specifics) { |
| + return HistoryDeleteDirectiveSpecificsVisit( |
| + history_delete_directive_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ManagedUserSettingSpecificsToValue( |
| + const sync_pb::ManagedUserSettingSpecifics& |
| + managed_user_setting_specifics) { |
| + return ManagedUserSettingSpecificsVisit(managed_user_setting_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ManagedUserSpecificsToValue( |
| + const sync_pb::ManagedUserSpecifics& managed_user_specifics) { |
| + return ManagedUserSpecificsVisit(managed_user_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ManagedUserSharedSettingSpecificsToValue( |
| + const sync_pb::ManagedUserSharedSettingSpecifics& |
| + managed_user_shared_setting_specifics) { |
| + return ManagedUserSharedSettingSpecificsVisit( |
| + managed_user_shared_setting_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ManagedUserWhitelistSpecificsToValue( |
| + const sync_pb::ManagedUserWhitelistSpecifics& |
| + managed_user_whitelist_specifics) { |
| + return ManagedUserWhitelistSpecificsVisit(managed_user_whitelist_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> NigoriSpecificsToValue( |
| + const sync_pb::NigoriSpecifics& nigori_specifics) { |
| + return NigoriSpecificsVisit(nigori_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> PasswordSpecificsToValue( |
| + const sync_pb::PasswordSpecifics& password_specifics) { |
| + return PasswordSpecificsVisit(password_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> PreferenceSpecificsToValue( |
| + const sync_pb::PreferenceSpecifics& password_specifics) { |
| + return PreferenceSpecificsVisit(password_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> |
| +SyncedNotificationAppInfoSpecificsToValue( |
| + const sync_pb::SyncedNotificationAppInfoSpecifics& |
| + synced_notification_specifics) { |
| + return SyncedNotificationAppInfoSpecificsVisit(synced_notification_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue( |
| + const sync_pb::SyncedNotificationSpecifics& synced_notification_specifics) { |
| + return SyncedNotificationSpecificsVisit(synced_notification_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( |
| + const sync_pb::SearchEngineSpecifics& search_engine_specifics) { |
| + return SearchEngineSpecificsVisit(search_engine_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ThemeSpecificsToValue( |
| + const sync_pb::ThemeSpecifics& theme_specifics) { |
| + return ThemeSpecificsVisit(theme_specifics, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> TypedUrlSpecificsToValue( |
| + const sync_pb::TypedUrlSpecifics& typed_url_specifics) { |
| + return TypedUrlSpecificsVisit(typed_url_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( |
| + const sync_pb::WalletMaskedCreditCard& wallet_masked_card) { |
| + return WalletMaskedCreditCardVisit(wallet_masked_card, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue( |
| + const sync_pb::WalletPostalAddress& wallet_postal_address) { |
| + return WalletPostalAddressVisit(wallet_postal_address, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue( |
| + const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics) { |
| + return WifiCredentialSpecificsVisit(wifi_credential_specifics, |
| + CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> EntitySpecificsToValue( |
| + const sync_pb::EntitySpecifics& specifics) { |
| + return EntitySpecificsVisit(specifics, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SyncEntityToValue( |
| + const sync_pb::SyncEntity& entity, |
| + bool include_specifics) { |
| + return SyncEntityVisit(entity, include_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ClientToServerMessageToValue( |
| + const sync_pb::ClientToServerMessage& proto, |
| + bool include_specifics) { |
| + return ClientToServerMessageVisit(proto, include_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue( |
| + const sync_pb::ClientToServerResponse& proto, |
| + bool include_specifics) { |
| + return ClientToServerResponseVisit(proto, include_specifics, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue( |
| + const sync_pb::DatatypeAssociationStats& proto) { |
| + return DatatypeAssociationStatsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue( |
| + const sync_pb::DebugEventInfo& proto) { |
| + return DebugEventInfoVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> DebugInfoToValue( |
| + const sync_pb::DebugInfo& proto) { |
| + return DebugInfoVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue( |
| + const sync_pb::SyncCycleCompletedEventInfo& proto) { |
| + return SyncCycleCompletedEventInfoVisit(proto, CONVERT_TO_VALUE) |
| + .TakeDictValue(); |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> ClientConfigParamsToValue( |
| + const sync_pb::ClientConfigParams& proto) { |
| + return ClientConfigParamsVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| } |
| std::unique_ptr<base::DictionaryValue> AttachmentIdProtoToValue( |
| const sync_pb::AttachmentIdProto& proto) { |
| - std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| - SET_STR(unique_id); |
| - return value; |
| + return AttachmentIdProtoVisit(proto, CONVERT_TO_VALUE).TakeDictValue(); |
| +} |
| + |
| +size_t GetEntitySpecificsSize(const sync_pb::EntitySpecifics& specifics) { |
| + return EntitySpecificsVisit(specifics, MEMORY_USAGE).memory_usage + |
| + sizeof(specifics); |
| } |
| +#undef SET_WITH_EXPR |
| #undef SET_TYPE |
| #undef SET |
| #undef SET_REP |
| +#undef SET_ENUM |
| #undef SET_BOOL |
| #undef SET_BYTES |
| @@ -1096,8 +1932,10 @@ std::unique_ptr<base::DictionaryValue> AttachmentIdProtoToValue( |
| #undef SET_INT64 |
| #undef SET_INT64_REP |
| #undef SET_STR |
| +#undef SET_TIME_STR |
| #undef SET_STR_REP |
| +#undef SET_EXPERIMENT_ENABLED_FIELD |
| #undef SET_FIELD |
| } // namespace syncer |