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

Unified Diff: components/sync/protocol/proto_old_value_conversions.cc

Issue 2433563002: [Sync] Reimplement proto value conversions on top of field visitors. (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync/protocol/proto_old_value_conversions.cc
diff --git a/components/sync/protocol/proto_value_conversions.cc b/components/sync/protocol/proto_old_value_conversions.cc
similarity index 96%
copy from components/sync/protocol/proto_value_conversions.cc
copy to components/sync/protocol/proto_old_value_conversions.cc
index 33cea696f520ef5c6cd1a7505806c85a3df6b2b6..7f251acf90a7b0216d175842071379ed2fa25f24 100644
--- a/components/sync/protocol/proto_value_conversions.cc
+++ b/components/sync/protocol/proto_old_value_conversions.cc
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/sync/protocol/proto_value_conversions.h"
+// Keep this file in sync with the .proto files in this directory.
+
+#include "components/sync/protocol/proto_old_value_conversions.h"
#include <stdint.h>
@@ -49,6 +51,7 @@
#include "components/sync/protocol/unique_position.pb.h"
namespace syncer {
+namespace old {
namespace {
@@ -158,7 +161,7 @@ std::unique_ptr<base::DictionaryValue> SessionHeaderToValue(
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_REP(window, SessionWindowToValue);
SET_STR(client_name);
- SET_ENUM(device_type, GetDeviceTypeString);
+ SET_ENUM(device_type, ProtoEnumToString);
return value;
}
@@ -173,7 +176,7 @@ std::unique_ptr<base::DictionaryValue> SessionTabToValue(
SET_STR(extension_app_id);
SET_REP(navigation, TabNavigationToValue);
SET_BYTES(favicon);
- SET_ENUM(favicon_type, GetFaviconTypeString);
+ SET_ENUM(favicon_type, ProtoEnumToString);
SET_STR(favicon_source);
SET_REP(variation_id, MakeInt64Value);
return value;
@@ -185,7 +188,7 @@ std::unique_ptr<base::DictionaryValue> SessionWindowToValue(
SET_INT32(window_id);
SET_INT32(selected_tab_index);
SET_INT32_REP(tab);
- SET_ENUM(browser_type, GetBrowserTypeString);
+ SET_ENUM(browser_type, ProtoEnumToString);
return value;
}
@@ -195,8 +198,8 @@ std::unique_ptr<base::DictionaryValue> TabNavigationToValue(
SET_STR(virtual_url);
SET_STR(referrer);
SET_STR(title);
- SET_ENUM(page_transition, GetPageTransitionString);
- SET_ENUM(redirect_type, GetPageTransitionRedirectTypeString);
+ SET_ENUM(page_transition, ProtoEnumToString);
+ SET_ENUM(redirect_type, ProtoEnumToString);
SET_INT32(unique_id);
SET_INT64(timestamp_msec);
SET_BOOL(navigation_forward_back);
@@ -207,7 +210,7 @@ std::unique_ptr<base::DictionaryValue> TabNavigationToValue(
SET_INT64(global_id);
SET_STR(search_terms);
SET_STR(favicon_url);
- SET_ENUM(blocked_state, GetBlockedStateString);
+ SET_ENUM(blocked_state, ProtoEnumToString);
SET_STR_REP(content_pack_categories);
SET_INT32(http_status_code);
SET_INT32(obsolete_referrer_policy);
@@ -215,7 +218,7 @@ std::unique_ptr<base::DictionaryValue> TabNavigationToValue(
SET_REP(navigation_redirect, NavigationRedirectToValue);
SET_STR(last_navigation_redirect_url);
SET_INT32(correct_referrer_policy);
- SET_ENUM(password_state, GetPasswordStateString);
+ SET_ENUM(password_state, ProtoEnumToString);
return value;
}
@@ -269,7 +272,7 @@ std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue(
const sync_pb::AppListSpecifics& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(item_id);
- SET_ENUM(item_type, GetAppListItemTypeString);
+ SET_ENUM(item_type, ProtoEnumToString);
SET_STR(item_name);
SET_STR(parent_id);
SET_STR(item_ordinal);
@@ -308,7 +311,7 @@ std::unique_ptr<base::DictionaryValue> ReadingListSpecificsToValue(
SET_STR(url);
SET_INT64(creation_time_us);
SET_INT64(update_time_us);
- SET_ENUM(status, GetReadingListEntryStatusString);
+ SET_ENUM(status, ProtoEnumToString);
return value;
}
@@ -348,7 +351,7 @@ std::unique_ptr<base::DictionaryValue> AppSpecificsToValue(
SET(notification_settings, AppSettingsToValue);
SET_STR(app_launch_ordinal);
SET_STR(page_ordinal);
- SET_ENUM(launch_type, GetLaunchTypeString);
+ SET_ENUM(launch_type, ProtoEnumToString);
SET_STR(bookmark_app_url);
SET_STR(bookmark_app_description);
SET_STR(bookmark_app_icon_color);
@@ -401,7 +404,7 @@ std::unique_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue(
std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue(
const sync_pb::WalletMetadataSpecifics& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- SET_ENUM(type, GetWalletMetadataTypeString);
+ SET_ENUM(type, ProtoEnumToString);
SET_STR(id);
SET_INT64(use_count);
SET_INT64(use_date);
@@ -412,7 +415,7 @@ std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue(
const sync_pb::AutofillWalletSpecifics& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- SET_ENUM(type, GetWalletInfoTypeString);
+ SET_ENUM(type, ProtoEnumToString);
if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) {
value->Set("masked_card",
WalletMaskedCreditCardToValue(proto.masked_card()));
@@ -447,7 +450,7 @@ std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue(
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(cache_guid);
SET_STR(client_name);
- SET_ENUM(device_type, GetDeviceTypeString);
+ SET_ENUM(device_type, ProtoEnumToString);
SET_STR(sync_user_agent);
SET_STR(chrome_version);
SET_STR(signin_scoped_device_id);
@@ -613,7 +616,7 @@ std::unique_ptr<base::DictionaryValue> NigoriSpecificsToValue(
SET_BOOL(encrypt_everything);
SET_BOOL(server_only_was_missing_keystore_migration_time);
SET_BOOL(sync_tab_favicons);
- SET_ENUM(passphrase_type, PassphraseTypeString);
+ SET_ENUM(passphrase_type, ProtoEnumToString);
SET(keystore_decryptor_token, EncryptedDataToValue);
SET_INT64(keystore_migration_time);
SET_INT64(custom_passphrase_time);
@@ -750,9 +753,9 @@ std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue(
const sync_pb::WalletMaskedCreditCard& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(id);
- SET_ENUM(status, GetWalletCardStatusString);
+ SET_ENUM(status, ProtoEnumToString);
SET_STR(name_on_card);
- SET_ENUM(type, GetWalletCardTypeString);
+ SET_ENUM(type, ProtoEnumToString);
SET_STR(last_four);
SET_INT32(exp_month);
SET_INT32(exp_year);
@@ -783,7 +786,7 @@ std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue(
const sync_pb::WifiCredentialSpecifics& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_BYTES(ssid);
- SET_ENUM(security_class, GetWifiCredentialSecurityClassString);
+ SET_ENUM(security_class, ProtoEnumToString);
SET_BYTES(passphrase);
return value;
}
@@ -938,7 +941,7 @@ std::unique_ptr<base::DictionaryValue> DataTypeContextToValue(
std::unique_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue(
const sync_pb::GetUpdatesCallerInfo& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- SET_ENUM(source, GetUpdatesSourceString);
+ SET_ENUM(source, ProtoEnumToString);
SET_BOOL(notifications_enabled);
return value;
}
@@ -953,7 +956,7 @@ std::unique_ptr<base::DictionaryValue> GetUpdatesMessageToValue(
SET_BOOL(streaming);
SET_BOOL(need_encryption_key);
SET_BOOL(create_mobile_bookmarks_folder);
- SET_ENUM(get_updates_origin, GetUpdatesOriginString);
+ SET_ENUM(get_updates_origin, ProtoEnumToString);
SET_REP(client_contexts, DataTypeContextToValue);
return value;
}
@@ -968,7 +971,7 @@ std::unique_ptr<base::DictionaryValue> ClientStatusToValue(
std::unique_ptr<base::DictionaryValue> EntryResponseToValue(
const sync_pb::CommitResponse::EntryResponse& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- SET_ENUM(response_type, GetResponseTypeString);
+ SET_ENUM(response_type, ProtoEnumToString);
SET_STR(id_string);
SET_STR(parent_id_string);
SET_INT64(position_in_parent);
@@ -1013,10 +1016,10 @@ std::unique_ptr<base::DictionaryValue> ClientCommandToValue(
std::unique_ptr<base::DictionaryValue> ErrorToValue(
const sync_pb::ClientToServerResponse::Error& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- SET_ENUM(error_type, GetErrorTypeString);
+ SET_ENUM(error_type, ProtoEnumToString);
SET_STR(error_description);
SET_STR(url);
- SET_ENUM(action, GetActionString);
+ SET_ENUM(action, ProtoEnumToString);
return value;
}
@@ -1033,7 +1036,7 @@ std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue(
}
SET(error, ErrorToValue);
- SET_ENUM(error_code, GetErrorTypeString);
+ SET_ENUM(error_code, ProtoEnumToString);
SET_STR(error_message);
SET_STR(store_birthday);
SET(client_command, ClientCommandToValue);
@@ -1087,7 +1090,7 @@ std::unique_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue(
std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue(
const sync_pb::DebugEventInfo& proto) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- SET_ENUM(singleton_event, SingletonDebugEventTypeString);
+ SET_ENUM(singleton_event, ProtoEnumToString);
SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue);
SET_INT32(nudging_datatype);
SET_INT32_REP(datatypes_notified_from_server);
@@ -1163,4 +1166,5 @@ std::unique_ptr<base::DictionaryValue> EntityMetadataToValue(
#undef SET_FIELD
+} // namespace old
} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698