Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Keep this file in sync with the .proto files in this directory. | 5 // Keep this file in sync with the .proto files in this directory. |
| 6 | 6 |
| 7 #include "sync/protocol/proto_value_conversions.h" | 7 #include "sync/protocol/proto_value_conversions.h" |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "sync/protocol/app_notification_specifics.pb.h" | 14 #include "sync/protocol/app_notification_specifics.pb.h" |
| 15 #include "sync/protocol/app_setting_specifics.pb.h" | 15 #include "sync/protocol/app_setting_specifics.pb.h" |
| 16 #include "sync/protocol/app_specifics.pb.h" | 16 #include "sync/protocol/app_specifics.pb.h" |
| 17 #include "sync/protocol/autofill_specifics.pb.h" | 17 #include "sync/protocol/autofill_specifics.pb.h" |
| 18 #include "sync/protocol/bookmark_specifics.pb.h" | 18 #include "sync/protocol/bookmark_specifics.pb.h" |
| 19 #include "sync/protocol/encryption.pb.h" | 19 #include "sync/protocol/encryption.pb.h" |
| 20 #include "sync/protocol/experiments_specifics.pb.h" | 20 #include "sync/protocol/experiments_specifics.pb.h" |
| 21 #include "sync/protocol/extension_setting_specifics.pb.h" | 21 #include "sync/protocol/extension_setting_specifics.pb.h" |
| 22 #include "sync/protocol/extension_specifics.pb.h" | 22 #include "sync/protocol/extension_specifics.pb.h" |
| 23 #include "sync/protocol/history_delete_directive_specifics.pb.h" | 23 #include "sync/protocol/history_delete_directive_specifics.pb.h" |
| 24 #include "sync/protocol/nigori_specifics.pb.h" | 24 #include "sync/protocol/nigori_specifics.pb.h" |
| 25 #include "sync/protocol/password_specifics.pb.h" | 25 #include "sync/protocol/password_specifics.pb.h" |
| 26 #include "sync/protocol/preference_specifics.pb.h" | 26 #include "sync/protocol/preference_specifics.pb.h" |
| 27 #include "sync/protocol/proto_enum_conversions.h" | 27 #include "sync/protocol/proto_enum_conversions.h" |
| 28 #include "sync/protocol/push_notifications_specifics.pb.h" | |
| 28 #include "sync/protocol/search_engine_specifics.pb.h" | 29 #include "sync/protocol/search_engine_specifics.pb.h" |
| 29 #include "sync/protocol/session_specifics.pb.h" | 30 #include "sync/protocol/session_specifics.pb.h" |
| 30 #include "sync/protocol/sync.pb.h" | 31 #include "sync/protocol/sync.pb.h" |
| 31 #include "sync/protocol/theme_specifics.pb.h" | 32 #include "sync/protocol/theme_specifics.pb.h" |
| 32 #include "sync/protocol/typed_url_specifics.pb.h" | 33 #include "sync/protocol/typed_url_specifics.pb.h" |
| 33 | 34 |
| 34 namespace syncer { | 35 namespace syncer { |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 } | 213 } |
| 213 | 214 |
| 214 base::DictionaryValue* TimeRangeDirectiveToValue( | 215 base::DictionaryValue* TimeRangeDirectiveToValue( |
| 215 const sync_pb::TimeRangeDirective& proto) { | 216 const sync_pb::TimeRangeDirective& proto) { |
| 216 DictionaryValue* value = new DictionaryValue(); | 217 DictionaryValue* value = new DictionaryValue(); |
| 217 SET_INT64(start_time_usec); | 218 SET_INT64(start_time_usec); |
| 218 SET_INT64(end_time_usec); | 219 SET_INT64(end_time_usec); |
| 219 return value; | 220 return value; |
| 220 } | 221 } |
| 221 | 222 |
| 223 // TODO: I will need new functions here for the PushNotifications subtypes | |
|
akalin
2012/12/06 23:34:55
put your name as part of the TODO. also, append p
Pete Williamson
2012/12/11 18:05:26
Done.
| |
| 224 | |
| 222 DictionaryValue* AppNotificationToValue( | 225 DictionaryValue* AppNotificationToValue( |
| 223 const sync_pb::AppNotification& proto) { | 226 const sync_pb::AppNotification& proto) { |
| 224 DictionaryValue* value = new DictionaryValue(); | 227 DictionaryValue* value = new DictionaryValue(); |
| 225 SET_STR(guid); | 228 SET_STR(guid); |
| 226 SET_STR(app_id); | 229 SET_STR(app_id); |
| 227 SET_INT64(creation_timestamp_ms); | 230 SET_INT64(creation_timestamp_ms); |
| 228 SET_STR(title); | 231 SET_STR(title); |
| 229 SET_STR(body_text); | 232 SET_STR(body_text); |
| 230 SET_STR(link_url); | 233 SET_STR(link_url); |
| 231 SET_STR(link_text); | 234 SET_STR(link_text); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 } | 378 } |
| 376 | 379 |
| 377 DictionaryValue* PreferenceSpecificsToValue( | 380 DictionaryValue* PreferenceSpecificsToValue( |
| 378 const sync_pb::PreferenceSpecifics& proto) { | 381 const sync_pb::PreferenceSpecifics& proto) { |
| 379 DictionaryValue* value = new DictionaryValue(); | 382 DictionaryValue* value = new DictionaryValue(); |
| 380 SET_STR(name); | 383 SET_STR(name); |
| 381 SET_STR(value); | 384 SET_STR(value); |
| 382 return value; | 385 return value; |
| 383 } | 386 } |
| 384 | 387 |
| 388 | |
| 389 DictionaryValue* PushNotificationsSpecificsToValue( | |
| 390 const sync_pb::PushNotificationsSpecifics& proto) { | |
| 391 DictionaryValue* value = new DictionaryValue(); | |
| 392 // TODO: Adjust this for the actual types in PN protobuf | |
|
akalin
2012/12/06 23:34:55
here too
Pete Williamson
2012/12/11 18:05:26
Done.
| |
| 393 SET_STR(name); | |
| 394 SET_STR(value); | |
| 395 return value; | |
| 396 } | |
| 397 | |
| 398 | |
| 385 DictionaryValue* SearchEngineSpecificsToValue( | 399 DictionaryValue* SearchEngineSpecificsToValue( |
| 386 const sync_pb::SearchEngineSpecifics& proto) { | 400 const sync_pb::SearchEngineSpecifics& proto) { |
| 387 DictionaryValue* value = new DictionaryValue(); | 401 DictionaryValue* value = new DictionaryValue(); |
| 388 SET_STR(short_name); | 402 SET_STR(short_name); |
| 389 SET_STR(keyword); | 403 SET_STR(keyword); |
| 390 SET_STR(favicon_url); | 404 SET_STR(favicon_url); |
| 391 SET_STR(url); | 405 SET_STR(url); |
| 392 SET_BOOL(safe_for_autoreplace); | 406 SET_BOOL(safe_for_autoreplace); |
| 393 SET_STR(originating_url); | 407 SET_STR(originating_url); |
| 394 SET_INT64(date_created); | 408 SET_INT64(date_created); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); | 460 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); |
| 447 SET_FIELD(bookmark, BookmarkSpecificsToValue); | 461 SET_FIELD(bookmark, BookmarkSpecificsToValue); |
| 448 SET_FIELD(device_info, DeviceInfoSpecificsToValue); | 462 SET_FIELD(device_info, DeviceInfoSpecificsToValue); |
| 449 SET_FIELD(experiments, ExperimentsSpecificsToValue); | 463 SET_FIELD(experiments, ExperimentsSpecificsToValue); |
| 450 SET_FIELD(extension, ExtensionSpecificsToValue); | 464 SET_FIELD(extension, ExtensionSpecificsToValue); |
| 451 SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); | 465 SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); |
| 452 SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); | 466 SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); |
| 453 SET_FIELD(nigori, NigoriSpecificsToValue); | 467 SET_FIELD(nigori, NigoriSpecificsToValue); |
| 454 SET_FIELD(password, PasswordSpecificsToValue); | 468 SET_FIELD(password, PasswordSpecificsToValue); |
| 455 SET_FIELD(preference, PreferenceSpecificsToValue); | 469 SET_FIELD(preference, PreferenceSpecificsToValue); |
| 470 SET_FIELD(push_notifications, PushNotificationsSpecificsToValue); | |
| 456 SET_FIELD(search_engine, SearchEngineSpecificsToValue); | 471 SET_FIELD(search_engine, SearchEngineSpecificsToValue); |
| 457 SET_FIELD(session, SessionSpecificsToValue); | 472 SET_FIELD(session, SessionSpecificsToValue); |
| 458 SET_FIELD(theme, ThemeSpecificsToValue); | 473 SET_FIELD(theme, ThemeSpecificsToValue); |
| 459 SET_FIELD(typed_url, TypedUrlSpecificsToValue); | 474 SET_FIELD(typed_url, TypedUrlSpecificsToValue); |
| 460 return value; | 475 return value; |
| 461 } | 476 } |
| 462 | 477 |
| 463 namespace { | 478 namespace { |
| 464 | 479 |
| 465 DictionaryValue* SyncEntityToValue(const sync_pb::SyncEntity& proto, | 480 DictionaryValue* SyncEntityToValue(const sync_pb::SyncEntity& proto, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 #undef SET_BYTES | 719 #undef SET_BYTES |
| 705 #undef SET_INT32 | 720 #undef SET_INT32 |
| 706 #undef SET_INT64 | 721 #undef SET_INT64 |
| 707 #undef SET_INT64_REP | 722 #undef SET_INT64_REP |
| 708 #undef SET_STR | 723 #undef SET_STR |
| 709 #undef SET_STR_REP | 724 #undef SET_STR_REP |
| 710 | 725 |
| 711 #undef SET_FIELD | 726 #undef SET_FIELD |
| 712 | 727 |
| 713 } // namespace syncer | 728 } // namespace syncer |
| OLD | NEW |