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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/protocol/proto_value_conversions.h" 5 // Keep this file in sync with the .proto files in this directory.
6
7 #include "components/sync/protocol/proto_old_value_conversions.h"
6 8
7 #include <stdint.h> 9 #include <stdint.h>
8 10
9 #include <algorithm> 11 #include <algorithm>
10 #include <string> 12 #include <string>
11 13
12 #include "base/base64.h" 14 #include "base/base64.h"
13 #include "base/i18n/time_formatting.h" 15 #include "base/i18n/time_formatting.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
(...skipping 26 matching lines...) Expand all
42 #include "components/sync/protocol/proto_enum_conversions.h" 44 #include "components/sync/protocol/proto_enum_conversions.h"
43 #include "components/sync/protocol/reading_list_specifics.pb.h" 45 #include "components/sync/protocol/reading_list_specifics.pb.h"
44 #include "components/sync/protocol/search_engine_specifics.pb.h" 46 #include "components/sync/protocol/search_engine_specifics.pb.h"
45 #include "components/sync/protocol/session_specifics.pb.h" 47 #include "components/sync/protocol/session_specifics.pb.h"
46 #include "components/sync/protocol/sync.pb.h" 48 #include "components/sync/protocol/sync.pb.h"
47 #include "components/sync/protocol/theme_specifics.pb.h" 49 #include "components/sync/protocol/theme_specifics.pb.h"
48 #include "components/sync/protocol/typed_url_specifics.pb.h" 50 #include "components/sync/protocol/typed_url_specifics.pb.h"
49 #include "components/sync/protocol/unique_position.pb.h" 51 #include "components/sync/protocol/unique_position.pb.h"
50 52
51 namespace syncer { 53 namespace syncer {
54 namespace old {
52 55
53 namespace { 56 namespace {
54 57
55 // Basic Type -> Value functions. 58 // Basic Type -> Value functions.
56 59
57 std::unique_ptr<base::StringValue> MakeInt64Value(int64_t x) { 60 std::unique_ptr<base::StringValue> MakeInt64Value(int64_t x) {
58 return base::MakeUnique<base::StringValue>(base::Int64ToString(x)); 61 return base::MakeUnique<base::StringValue>(base::Int64ToString(x));
59 } 62 }
60 63
61 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use 64 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 SET_BOOL(disabled); 154 SET_BOOL(disabled);
152 SET_STR(oauth_client_id); 155 SET_STR(oauth_client_id);
153 return value; 156 return value;
154 } 157 }
155 158
156 std::unique_ptr<base::DictionaryValue> SessionHeaderToValue( 159 std::unique_ptr<base::DictionaryValue> SessionHeaderToValue(
157 const sync_pb::SessionHeader& proto) { 160 const sync_pb::SessionHeader& proto) {
158 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 161 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
159 SET_REP(window, SessionWindowToValue); 162 SET_REP(window, SessionWindowToValue);
160 SET_STR(client_name); 163 SET_STR(client_name);
161 SET_ENUM(device_type, GetDeviceTypeString); 164 SET_ENUM(device_type, ProtoEnumToString);
162 return value; 165 return value;
163 } 166 }
164 167
165 std::unique_ptr<base::DictionaryValue> SessionTabToValue( 168 std::unique_ptr<base::DictionaryValue> SessionTabToValue(
166 const sync_pb::SessionTab& proto) { 169 const sync_pb::SessionTab& proto) {
167 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 170 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
168 SET_INT32(tab_id); 171 SET_INT32(tab_id);
169 SET_INT32(window_id); 172 SET_INT32(window_id);
170 SET_INT32(tab_visual_index); 173 SET_INT32(tab_visual_index);
171 SET_INT32(current_navigation_index); 174 SET_INT32(current_navigation_index);
172 SET_BOOL(pinned); 175 SET_BOOL(pinned);
173 SET_STR(extension_app_id); 176 SET_STR(extension_app_id);
174 SET_REP(navigation, TabNavigationToValue); 177 SET_REP(navigation, TabNavigationToValue);
175 SET_BYTES(favicon); 178 SET_BYTES(favicon);
176 SET_ENUM(favicon_type, GetFaviconTypeString); 179 SET_ENUM(favicon_type, ProtoEnumToString);
177 SET_STR(favicon_source); 180 SET_STR(favicon_source);
178 SET_REP(variation_id, MakeInt64Value); 181 SET_REP(variation_id, MakeInt64Value);
179 return value; 182 return value;
180 } 183 }
181 184
182 std::unique_ptr<base::DictionaryValue> SessionWindowToValue( 185 std::unique_ptr<base::DictionaryValue> SessionWindowToValue(
183 const sync_pb::SessionWindow& proto) { 186 const sync_pb::SessionWindow& proto) {
184 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 187 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
185 SET_INT32(window_id); 188 SET_INT32(window_id);
186 SET_INT32(selected_tab_index); 189 SET_INT32(selected_tab_index);
187 SET_INT32_REP(tab); 190 SET_INT32_REP(tab);
188 SET_ENUM(browser_type, GetBrowserTypeString); 191 SET_ENUM(browser_type, ProtoEnumToString);
189 return value; 192 return value;
190 } 193 }
191 194
192 std::unique_ptr<base::DictionaryValue> TabNavigationToValue( 195 std::unique_ptr<base::DictionaryValue> TabNavigationToValue(
193 const sync_pb::TabNavigation& proto) { 196 const sync_pb::TabNavigation& proto) {
194 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 197 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
195 SET_STR(virtual_url); 198 SET_STR(virtual_url);
196 SET_STR(referrer); 199 SET_STR(referrer);
197 SET_STR(title); 200 SET_STR(title);
198 SET_ENUM(page_transition, GetPageTransitionString); 201 SET_ENUM(page_transition, ProtoEnumToString);
199 SET_ENUM(redirect_type, GetPageTransitionRedirectTypeString); 202 SET_ENUM(redirect_type, ProtoEnumToString);
200 SET_INT32(unique_id); 203 SET_INT32(unique_id);
201 SET_INT64(timestamp_msec); 204 SET_INT64(timestamp_msec);
202 SET_BOOL(navigation_forward_back); 205 SET_BOOL(navigation_forward_back);
203 SET_BOOL(navigation_from_address_bar); 206 SET_BOOL(navigation_from_address_bar);
204 SET_BOOL(navigation_home_page); 207 SET_BOOL(navigation_home_page);
205 SET_BOOL(navigation_chain_start); 208 SET_BOOL(navigation_chain_start);
206 SET_BOOL(navigation_chain_end); 209 SET_BOOL(navigation_chain_end);
207 SET_INT64(global_id); 210 SET_INT64(global_id);
208 SET_STR(search_terms); 211 SET_STR(search_terms);
209 SET_STR(favicon_url); 212 SET_STR(favicon_url);
210 SET_ENUM(blocked_state, GetBlockedStateString); 213 SET_ENUM(blocked_state, ProtoEnumToString);
211 SET_STR_REP(content_pack_categories); 214 SET_STR_REP(content_pack_categories);
212 SET_INT32(http_status_code); 215 SET_INT32(http_status_code);
213 SET_INT32(obsolete_referrer_policy); 216 SET_INT32(obsolete_referrer_policy);
214 SET_BOOL(is_restored); 217 SET_BOOL(is_restored);
215 SET_REP(navigation_redirect, NavigationRedirectToValue); 218 SET_REP(navigation_redirect, NavigationRedirectToValue);
216 SET_STR(last_navigation_redirect_url); 219 SET_STR(last_navigation_redirect_url);
217 SET_INT32(correct_referrer_policy); 220 SET_INT32(correct_referrer_policy);
218 SET_ENUM(password_state, GetPasswordStateString); 221 SET_ENUM(password_state, ProtoEnumToString);
219 return value; 222 return value;
220 } 223 }
221 224
222 std::unique_ptr<base::DictionaryValue> NavigationRedirectToValue( 225 std::unique_ptr<base::DictionaryValue> NavigationRedirectToValue(
223 const sync_pb::NavigationRedirect& proto) { 226 const sync_pb::NavigationRedirect& proto) {
224 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 227 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
225 SET_STR(url); 228 SET_STR(url);
226 return value; 229 return value;
227 } 230 }
228 231
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 265 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
263 SET_INT64(start_time_usec); 266 SET_INT64(start_time_usec);
264 SET_INT64(end_time_usec); 267 SET_INT64(end_time_usec);
265 return value; 268 return value;
266 } 269 }
267 270
268 std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue( 271 std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue(
269 const sync_pb::AppListSpecifics& proto) { 272 const sync_pb::AppListSpecifics& proto) {
270 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 273 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
271 SET_STR(item_id); 274 SET_STR(item_id);
272 SET_ENUM(item_type, GetAppListItemTypeString); 275 SET_ENUM(item_type, ProtoEnumToString);
273 SET_STR(item_name); 276 SET_STR(item_name);
274 SET_STR(parent_id); 277 SET_STR(parent_id);
275 SET_STR(item_ordinal); 278 SET_STR(item_ordinal);
276 SET_STR(item_pin_ordinal); 279 SET_STR(item_pin_ordinal);
277 280
278 return value; 281 return value;
279 } 282 }
280 283
281 std::unique_ptr<base::DictionaryValue> ArcPackageSpecificsToValue( 284 std::unique_ptr<base::DictionaryValue> ArcPackageSpecificsToValue(
282 const sync_pb::ArcPackageSpecifics& proto) { 285 const sync_pb::ArcPackageSpecifics& proto) {
(...skipping 18 matching lines...) Expand all
301 } 304 }
302 305
303 std::unique_ptr<base::DictionaryValue> ReadingListSpecificsToValue( 306 std::unique_ptr<base::DictionaryValue> ReadingListSpecificsToValue(
304 const sync_pb::ReadingListSpecifics& proto) { 307 const sync_pb::ReadingListSpecifics& proto) {
305 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 308 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
306 SET_STR(entry_id); 309 SET_STR(entry_id);
307 SET_STR(title); 310 SET_STR(title);
308 SET_STR(url); 311 SET_STR(url);
309 SET_INT64(creation_time_us); 312 SET_INT64(creation_time_us);
310 SET_INT64(update_time_us); 313 SET_INT64(update_time_us);
311 SET_ENUM(status, GetReadingListEntryStatusString); 314 SET_ENUM(status, ProtoEnumToString);
312 315
313 return value; 316 return value;
314 } 317 }
315 318
316 std::unique_ptr<base::DictionaryValue> AppNotificationToValue( 319 std::unique_ptr<base::DictionaryValue> AppNotificationToValue(
317 const sync_pb::AppNotification& proto) { 320 const sync_pb::AppNotification& proto) {
318 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 321 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
319 SET_STR(guid); 322 SET_STR(guid);
320 SET_STR(app_id); 323 SET_STR(app_id);
321 SET_INT64(creation_timestamp_ms); 324 SET_INT64(creation_timestamp_ms);
(...skipping 19 matching lines...) Expand all
341 return value; 344 return value;
342 } 345 }
343 346
344 std::unique_ptr<base::DictionaryValue> AppSpecificsToValue( 347 std::unique_ptr<base::DictionaryValue> AppSpecificsToValue(
345 const sync_pb::AppSpecifics& proto) { 348 const sync_pb::AppSpecifics& proto) {
346 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 349 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
347 SET(extension, ExtensionSpecificsToValue); 350 SET(extension, ExtensionSpecificsToValue);
348 SET(notification_settings, AppSettingsToValue); 351 SET(notification_settings, AppSettingsToValue);
349 SET_STR(app_launch_ordinal); 352 SET_STR(app_launch_ordinal);
350 SET_STR(page_ordinal); 353 SET_STR(page_ordinal);
351 SET_ENUM(launch_type, GetLaunchTypeString); 354 SET_ENUM(launch_type, ProtoEnumToString);
352 SET_STR(bookmark_app_url); 355 SET_STR(bookmark_app_url);
353 SET_STR(bookmark_app_description); 356 SET_STR(bookmark_app_description);
354 SET_STR(bookmark_app_icon_color); 357 SET_STR(bookmark_app_icon_color);
355 SET_REP(linked_app_icons, LinkedAppIconInfoToValue); 358 SET_REP(linked_app_icons, LinkedAppIconInfoToValue);
356 359
357 return value; 360 return value;
358 } 361 }
359 362
360 std::unique_ptr<base::DictionaryValue> AutofillSpecificsToValue( 363 std::unique_ptr<base::DictionaryValue> AutofillSpecificsToValue(
361 const sync_pb::AutofillSpecifics& proto) { 364 const sync_pb::AutofillSpecifics& proto) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 SET_STR(address_home_dependent_locality); 397 SET_STR(address_home_dependent_locality);
395 SET_STR(address_home_language_code); 398 SET_STR(address_home_language_code);
396 399
397 SET_STR_REP(phone_home_whole_number); 400 SET_STR_REP(phone_home_whole_number);
398 return value; 401 return value;
399 } 402 }
400 403
401 std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue( 404 std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue(
402 const sync_pb::WalletMetadataSpecifics& proto) { 405 const sync_pb::WalletMetadataSpecifics& proto) {
403 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 406 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
404 SET_ENUM(type, GetWalletMetadataTypeString); 407 SET_ENUM(type, ProtoEnumToString);
405 SET_STR(id); 408 SET_STR(id);
406 SET_INT64(use_count); 409 SET_INT64(use_count);
407 SET_INT64(use_date); 410 SET_INT64(use_date);
408 return value; 411 return value;
409 } 412 }
410 413
411 std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( 414 std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue(
412 const sync_pb::AutofillWalletSpecifics& proto) { 415 const sync_pb::AutofillWalletSpecifics& proto) {
413 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 416 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
414 417
415 SET_ENUM(type, GetWalletInfoTypeString); 418 SET_ENUM(type, ProtoEnumToString);
416 if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { 419 if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) {
417 value->Set("masked_card", 420 value->Set("masked_card",
418 WalletMaskedCreditCardToValue(proto.masked_card())); 421 WalletMaskedCreditCardToValue(proto.masked_card()));
419 } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) { 422 } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) {
420 value->Set("address", WalletPostalAddressToValue(proto.address())); 423 value->Set("address", WalletPostalAddressToValue(proto.address()));
421 } 424 }
422 return value; 425 return value;
423 } 426 }
424 427
425 std::unique_ptr<base::DictionaryValue> MetaInfoToValue( 428 std::unique_ptr<base::DictionaryValue> MetaInfoToValue(
(...skipping 14 matching lines...) Expand all
440 SET_STR(icon_url); 443 SET_STR(icon_url);
441 SET_REP(meta_info, &MetaInfoToValue); 444 SET_REP(meta_info, &MetaInfoToValue);
442 return value; 445 return value;
443 } 446 }
444 447
445 std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue( 448 std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue(
446 const sync_pb::DeviceInfoSpecifics& proto) { 449 const sync_pb::DeviceInfoSpecifics& proto) {
447 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 450 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
448 SET_STR(cache_guid); 451 SET_STR(cache_guid);
449 SET_STR(client_name); 452 SET_STR(client_name);
450 SET_ENUM(device_type, GetDeviceTypeString); 453 SET_ENUM(device_type, ProtoEnumToString);
451 SET_STR(sync_user_agent); 454 SET_STR(sync_user_agent);
452 SET_STR(chrome_version); 455 SET_STR(chrome_version);
453 SET_STR(signin_scoped_device_id); 456 SET_STR(signin_scoped_device_id);
454 return value; 457 return value;
455 } 458 }
456 459
457 std::unique_ptr<base::DictionaryValue> DictionarySpecificsToValue( 460 std::unique_ptr<base::DictionaryValue> DictionarySpecificsToValue(
458 const sync_pb::DictionarySpecifics& proto) { 461 const sync_pb::DictionarySpecifics& proto) {
459 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 462 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
460 SET_STR(word); 463 SET_STR(word);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 SET_BOOL(encrypt_apps); 609 SET_BOOL(encrypt_apps);
607 SET_BOOL(encrypt_search_engines); 610 SET_BOOL(encrypt_search_engines);
608 SET_BOOL(encrypt_dictionary); 611 SET_BOOL(encrypt_dictionary);
609 SET_BOOL(encrypt_articles); 612 SET_BOOL(encrypt_articles);
610 SET_BOOL(encrypt_app_list); 613 SET_BOOL(encrypt_app_list);
611 SET_BOOL(encrypt_arc_package); 614 SET_BOOL(encrypt_arc_package);
612 SET_BOOL(encrypt_reading_list); 615 SET_BOOL(encrypt_reading_list);
613 SET_BOOL(encrypt_everything); 616 SET_BOOL(encrypt_everything);
614 SET_BOOL(server_only_was_missing_keystore_migration_time); 617 SET_BOOL(server_only_was_missing_keystore_migration_time);
615 SET_BOOL(sync_tab_favicons); 618 SET_BOOL(sync_tab_favicons);
616 SET_ENUM(passphrase_type, PassphraseTypeString); 619 SET_ENUM(passphrase_type, ProtoEnumToString);
617 SET(keystore_decryptor_token, EncryptedDataToValue); 620 SET(keystore_decryptor_token, EncryptedDataToValue);
618 SET_INT64(keystore_migration_time); 621 SET_INT64(keystore_migration_time);
619 SET_INT64(custom_passphrase_time); 622 SET_INT64(custom_passphrase_time);
620 return value; 623 return value;
621 } 624 }
622 625
623 std::unique_ptr<base::DictionaryValue> ArticlePageToValue( 626 std::unique_ptr<base::DictionaryValue> ArticlePageToValue(
624 const sync_pb::ArticlePage& proto) { 627 const sync_pb::ArticlePage& proto) {
625 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 628 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
626 SET_STR(url); 629 SET_STR(url);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 SET_BOOL(hidden); 746 SET_BOOL(hidden);
744 SET_INT64_REP(visits); 747 SET_INT64_REP(visits);
745 SET_INT32_REP(visit_transitions); 748 SET_INT32_REP(visit_transitions);
746 return value; 749 return value;
747 } 750 }
748 751
749 std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( 752 std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue(
750 const sync_pb::WalletMaskedCreditCard& proto) { 753 const sync_pb::WalletMaskedCreditCard& proto) {
751 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 754 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
752 SET_STR(id); 755 SET_STR(id);
753 SET_ENUM(status, GetWalletCardStatusString); 756 SET_ENUM(status, ProtoEnumToString);
754 SET_STR(name_on_card); 757 SET_STR(name_on_card);
755 SET_ENUM(type, GetWalletCardTypeString); 758 SET_ENUM(type, ProtoEnumToString);
756 SET_STR(last_four); 759 SET_STR(last_four);
757 SET_INT32(exp_month); 760 SET_INT32(exp_month);
758 SET_INT32(exp_year); 761 SET_INT32(exp_year);
759 SET_STR(billing_address_id); 762 SET_STR(billing_address_id);
760 return value; 763 return value;
761 } 764 }
762 765
763 std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue( 766 std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue(
764 const sync_pb::WalletPostalAddress& proto) { 767 const sync_pb::WalletPostalAddress& proto) {
765 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 768 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
(...skipping 10 matching lines...) Expand all
776 SET_STR(country_code); 779 SET_STR(country_code);
777 SET_STR(phone_number); 780 SET_STR(phone_number);
778 SET_STR(language_code); 781 SET_STR(language_code);
779 return value; 782 return value;
780 } 783 }
781 784
782 std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue( 785 std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue(
783 const sync_pb::WifiCredentialSpecifics& proto) { 786 const sync_pb::WifiCredentialSpecifics& proto) {
784 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 787 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
785 SET_BYTES(ssid); 788 SET_BYTES(ssid);
786 SET_ENUM(security_class, GetWifiCredentialSecurityClassString); 789 SET_ENUM(security_class, ProtoEnumToString);
787 SET_BYTES(passphrase); 790 SET_BYTES(passphrase);
788 return value; 791 return value;
789 } 792 }
790 793
791 std::unique_ptr<base::DictionaryValue> EntitySpecificsToValue( 794 std::unique_ptr<base::DictionaryValue> EntitySpecificsToValue(
792 const sync_pb::EntitySpecifics& specifics) { 795 const sync_pb::EntitySpecifics& specifics) {
793 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 796 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
794 SET_FIELD(app, AppSpecificsToValue); 797 SET_FIELD(app, AppSpecificsToValue);
795 SET_FIELD(app_list, AppListSpecificsToValue); 798 SET_FIELD(app_list, AppListSpecificsToValue);
796 SET_FIELD(app_notification, AppNotificationToValue); 799 SET_FIELD(app_notification, AppNotificationToValue);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 934 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
932 SET_INT32(data_type_id); 935 SET_INT32(data_type_id);
933 SET_STR(context); 936 SET_STR(context);
934 SET_INT64(version); 937 SET_INT64(version);
935 return value; 938 return value;
936 } 939 }
937 940
938 std::unique_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue( 941 std::unique_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue(
939 const sync_pb::GetUpdatesCallerInfo& proto) { 942 const sync_pb::GetUpdatesCallerInfo& proto) {
940 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 943 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
941 SET_ENUM(source, GetUpdatesSourceString); 944 SET_ENUM(source, ProtoEnumToString);
942 SET_BOOL(notifications_enabled); 945 SET_BOOL(notifications_enabled);
943 return value; 946 return value;
944 } 947 }
945 948
946 std::unique_ptr<base::DictionaryValue> GetUpdatesMessageToValue( 949 std::unique_ptr<base::DictionaryValue> GetUpdatesMessageToValue(
947 const sync_pb::GetUpdatesMessage& proto) { 950 const sync_pb::GetUpdatesMessage& proto) {
948 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 951 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
949 SET(caller_info, GetUpdatesCallerInfoToValue); 952 SET(caller_info, GetUpdatesCallerInfoToValue);
950 SET_BOOL(fetch_folders); 953 SET_BOOL(fetch_folders);
951 SET_INT32(batch_size); 954 SET_INT32(batch_size);
952 SET_REP(from_progress_marker, DataTypeProgressMarkerToValue); 955 SET_REP(from_progress_marker, DataTypeProgressMarkerToValue);
953 SET_BOOL(streaming); 956 SET_BOOL(streaming);
954 SET_BOOL(need_encryption_key); 957 SET_BOOL(need_encryption_key);
955 SET_BOOL(create_mobile_bookmarks_folder); 958 SET_BOOL(create_mobile_bookmarks_folder);
956 SET_ENUM(get_updates_origin, GetUpdatesOriginString); 959 SET_ENUM(get_updates_origin, ProtoEnumToString);
957 SET_REP(client_contexts, DataTypeContextToValue); 960 SET_REP(client_contexts, DataTypeContextToValue);
958 return value; 961 return value;
959 } 962 }
960 963
961 std::unique_ptr<base::DictionaryValue> ClientStatusToValue( 964 std::unique_ptr<base::DictionaryValue> ClientStatusToValue(
962 const sync_pb::ClientStatus& proto) { 965 const sync_pb::ClientStatus& proto) {
963 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 966 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
964 SET_BOOL(hierarchy_conflict_detected); 967 SET_BOOL(hierarchy_conflict_detected);
965 return value; 968 return value;
966 } 969 }
967 970
968 std::unique_ptr<base::DictionaryValue> EntryResponseToValue( 971 std::unique_ptr<base::DictionaryValue> EntryResponseToValue(
969 const sync_pb::CommitResponse::EntryResponse& proto) { 972 const sync_pb::CommitResponse::EntryResponse& proto) {
970 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 973 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
971 SET_ENUM(response_type, GetResponseTypeString); 974 SET_ENUM(response_type, ProtoEnumToString);
972 SET_STR(id_string); 975 SET_STR(id_string);
973 SET_STR(parent_id_string); 976 SET_STR(parent_id_string);
974 SET_INT64(position_in_parent); 977 SET_INT64(position_in_parent);
975 SET_INT64(version); 978 SET_INT64(version);
976 SET_STR(name); 979 SET_STR(name);
977 SET_STR(error_message); 980 SET_STR(error_message);
978 SET_INT64(mtime); 981 SET_INT64(mtime);
979 return value; 982 return value;
980 } 983 }
981 984
(...skipping 24 matching lines...) Expand all
1006 SET_INT32(max_commit_batch_size); 1009 SET_INT32(max_commit_batch_size);
1007 SET_INT32(sessions_commit_delay_seconds); 1010 SET_INT32(sessions_commit_delay_seconds);
1008 SET_INT32(throttle_delay_seconds); 1011 SET_INT32(throttle_delay_seconds);
1009 SET_INT32(client_invalidation_hint_buffer_size); 1012 SET_INT32(client_invalidation_hint_buffer_size);
1010 return value; 1013 return value;
1011 } 1014 }
1012 1015
1013 std::unique_ptr<base::DictionaryValue> ErrorToValue( 1016 std::unique_ptr<base::DictionaryValue> ErrorToValue(
1014 const sync_pb::ClientToServerResponse::Error& proto) { 1017 const sync_pb::ClientToServerResponse::Error& proto) {
1015 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 1018 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
1016 SET_ENUM(error_type, GetErrorTypeString); 1019 SET_ENUM(error_type, ProtoEnumToString);
1017 SET_STR(error_description); 1020 SET_STR(error_description);
1018 SET_STR(url); 1021 SET_STR(url);
1019 SET_ENUM(action, GetActionString); 1022 SET_ENUM(action, ProtoEnumToString);
1020 return value; 1023 return value;
1021 } 1024 }
1022 1025
1023 } // namespace 1026 } // namespace
1024 1027
1025 std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue( 1028 std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue(
1026 const sync_pb::ClientToServerResponse& proto, 1029 const sync_pb::ClientToServerResponse& proto,
1027 bool include_specifics) { 1030 bool include_specifics) {
1028 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 1031 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
1029 SET(commit, CommitResponseToValue); 1032 SET(commit, CommitResponseToValue);
1030 if (proto.has_get_updates()) { 1033 if (proto.has_get_updates()) {
1031 value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(), 1034 value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(),
1032 include_specifics)); 1035 include_specifics));
1033 } 1036 }
1034 1037
1035 SET(error, ErrorToValue); 1038 SET(error, ErrorToValue);
1036 SET_ENUM(error_code, GetErrorTypeString); 1039 SET_ENUM(error_code, ProtoEnumToString);
1037 SET_STR(error_message); 1040 SET_STR(error_message);
1038 SET_STR(store_birthday); 1041 SET_STR(store_birthday);
1039 SET(client_command, ClientCommandToValue); 1042 SET(client_command, ClientCommandToValue);
1040 SET_INT32_REP(migrated_data_type_id); 1043 SET_INT32_REP(migrated_data_type_id);
1041 return value; 1044 return value;
1042 } 1045 }
1043 1046
1044 std::unique_ptr<base::DictionaryValue> ClientToServerMessageToValue( 1047 std::unique_ptr<base::DictionaryValue> ClientToServerMessageToValue(
1045 const sync_pb::ClientToServerMessage& proto, 1048 const sync_pb::ClientToServerMessage& proto,
1046 bool include_specifics) { 1049 bool include_specifics) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 SET_INT64(download_wait_time_us); 1083 SET_INT64(download_wait_time_us);
1081 SET_INT64(download_time_us); 1084 SET_INT64(download_time_us);
1082 SET_INT64(association_wait_time_for_high_priority_us); 1085 SET_INT64(association_wait_time_for_high_priority_us);
1083 SET_INT64(association_wait_time_for_same_priority_us); 1086 SET_INT64(association_wait_time_for_same_priority_us);
1084 return value; 1087 return value;
1085 } 1088 }
1086 1089
1087 std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue( 1090 std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue(
1088 const sync_pb::DebugEventInfo& proto) { 1091 const sync_pb::DebugEventInfo& proto) {
1089 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 1092 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
1090 SET_ENUM(singleton_event, SingletonDebugEventTypeString); 1093 SET_ENUM(singleton_event, ProtoEnumToString);
1091 SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue); 1094 SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue);
1092 SET_INT32(nudging_datatype); 1095 SET_INT32(nudging_datatype);
1093 SET_INT32_REP(datatypes_notified_from_server); 1096 SET_INT32_REP(datatypes_notified_from_server);
1094 SET(datatype_association_stats, DatatypeAssociationStatsToValue); 1097 SET(datatype_association_stats, DatatypeAssociationStatsToValue);
1095 return value; 1098 return value;
1096 } 1099 }
1097 1100
1098 std::unique_ptr<base::DictionaryValue> DebugInfoToValue( 1101 std::unique_ptr<base::DictionaryValue> DebugInfoToValue(
1099 const sync_pb::DebugInfo& proto) { 1102 const sync_pb::DebugInfo& proto) {
1100 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 1103 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 #undef SET_BOOL 1159 #undef SET_BOOL
1157 #undef SET_BYTES 1160 #undef SET_BYTES
1158 #undef SET_INT32 1161 #undef SET_INT32
1159 #undef SET_INT64 1162 #undef SET_INT64
1160 #undef SET_INT64_REP 1163 #undef SET_INT64_REP
1161 #undef SET_STR 1164 #undef SET_STR
1162 #undef SET_STR_REP 1165 #undef SET_STR_REP
1163 1166
1164 #undef SET_FIELD 1167 #undef SET_FIELD
1165 1168
1169 } // namespace old
1166 } // namespace syncer 1170 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698