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 "chrome/browser/sync/protocol/proto_value_conversions.h" | 7 #include "chrome/browser/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" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 #define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) | 85 #define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) |
| 86 #define SET_STR(field) SET(field, Value::CreateStringValue) | 86 #define SET_STR(field) SET(field, Value::CreateStringValue) |
| 87 #define SET_STR_REP(field) \ | 87 #define SET_STR_REP(field) \ |
| 88 value->Set(#field, \ | 88 value->Set(#field, \ |
| 89 MakeRepeatedValue<const std::string&, \ | 89 MakeRepeatedValue<const std::string&, \ |
| 90 google::protobuf::RepeatedPtrField< \ | 90 google::protobuf::RepeatedPtrField< \ |
| 91 std::string >, \ | 91 std::string >, \ |
| 92 StringValue>(proto.field(), \ | 92 StringValue>(proto.field(), \ |
| 93 Value::CreateStringValue)) | 93 Value::CreateStringValue)) |
| 94 | 94 |
| 95 #define SET_EXTENSION(ns, field, fn) \ | 95 #define SET_EXTENSION(field, fn) \ |
|
akalin
2012/03/02 23:56:49
line up \s
akalin
2012/03/02 23:56:49
SET_EXTENSION -> SET_SPECIFICS/SET_FIELD?
| |
| 96 do { \ | 96 do { \ |
| 97 if (specifics.HasExtension(ns::field)) { \ | 97 if (specifics.has_##field()) { \ |
| 98 value->Set(#field, fn(specifics.GetExtension(ns::field))); \ | 98 value->Set(#field, fn(specifics.field())); \ |
| 99 } \ | 99 } \ |
| 100 } while (0) | 100 } while (0) |
| 101 | 101 |
| 102 // If you add another macro, don't forget to add an #undef at the end | 102 // If you add another macro, don't forget to add an #undef at the end |
| 103 // of this file, too. | 103 // of this file, too. |
| 104 | 104 |
| 105 DictionaryValue* EncryptedDataToValue(const sync_pb::EncryptedData& proto) { | 105 DictionaryValue* EncryptedDataToValue(const sync_pb::EncryptedData& proto) { |
| 106 DictionaryValue* value = new DictionaryValue(); | 106 DictionaryValue* value = new DictionaryValue(); |
| 107 SET_STR(key_name); | 107 SET_STR(key_name); |
| 108 // TODO(akalin): Shouldn't blob be of type bytes instead of string? | 108 // TODO(akalin): Shouldn't blob be of type bytes instead of string? |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 SET_STR(title); | 372 SET_STR(title); |
| 373 SET_BOOL(hidden); | 373 SET_BOOL(hidden); |
| 374 SET_INT64_REP(visits); | 374 SET_INT64_REP(visits); |
| 375 SET_INT32_REP(visit_transitions); | 375 SET_INT32_REP(visit_transitions); |
| 376 return value; | 376 return value; |
| 377 } | 377 } |
| 378 | 378 |
| 379 DictionaryValue* EntitySpecificsToValue( | 379 DictionaryValue* EntitySpecificsToValue( |
| 380 const sync_pb::EntitySpecifics& specifics) { | 380 const sync_pb::EntitySpecifics& specifics) { |
| 381 DictionaryValue* value = new DictionaryValue(); | 381 DictionaryValue* value = new DictionaryValue(); |
| 382 SET_EXTENSION(sync_pb, app, AppSpecificsToValue); | 382 SET_EXTENSION(app, AppSpecificsToValue); |
| 383 SET_EXTENSION(sync_pb, app_notification, AppNotificationToValue); | 383 SET_EXTENSION(app_notification, AppNotificationToValue); |
| 384 SET_EXTENSION(sync_pb, app_setting, AppSettingSpecificsToValue); | 384 SET_EXTENSION(app_setting, AppSettingSpecificsToValue); |
| 385 SET_EXTENSION(sync_pb, autofill, AutofillSpecificsToValue); | 385 SET_EXTENSION(autofill, AutofillSpecificsToValue); |
| 386 SET_EXTENSION(sync_pb, autofill_profile, AutofillProfileSpecificsToValue); | 386 SET_EXTENSION(autofill_profile, AutofillProfileSpecificsToValue); |
| 387 SET_EXTENSION(sync_pb, bookmark, BookmarkSpecificsToValue); | 387 SET_EXTENSION(bookmark, BookmarkSpecificsToValue); |
| 388 SET_EXTENSION(sync_pb, extension, ExtensionSpecificsToValue); | 388 SET_EXTENSION(extension, ExtensionSpecificsToValue); |
| 389 SET_EXTENSION(sync_pb, extension_setting, ExtensionSettingSpecificsToValue); | 389 SET_EXTENSION(extension_setting, ExtensionSettingSpecificsToValue); |
| 390 SET_EXTENSION(sync_pb, nigori, NigoriSpecificsToValue); | 390 SET_EXTENSION(nigori, NigoriSpecificsToValue); |
| 391 SET_EXTENSION(sync_pb, password, PasswordSpecificsToValue); | 391 SET_EXTENSION(password, PasswordSpecificsToValue); |
| 392 SET_EXTENSION(sync_pb, preference, PreferenceSpecificsToValue); | 392 SET_EXTENSION(preference, PreferenceSpecificsToValue); |
| 393 SET_EXTENSION(sync_pb, search_engine, SearchEngineSpecificsToValue); | 393 SET_EXTENSION(search_engine, SearchEngineSpecificsToValue); |
| 394 SET_EXTENSION(sync_pb, session, SessionSpecificsToValue); | 394 SET_EXTENSION(session, SessionSpecificsToValue); |
| 395 SET_EXTENSION(sync_pb, theme, ThemeSpecificsToValue); | 395 SET_EXTENSION(theme, ThemeSpecificsToValue); |
| 396 SET_EXTENSION(sync_pb, typed_url, TypedUrlSpecificsToValue); | 396 SET_EXTENSION(typed_url, TypedUrlSpecificsToValue); |
| 397 return value; | 397 return value; |
| 398 } | 398 } |
| 399 | 399 |
| 400 #undef SET | 400 #undef SET |
| 401 #undef SET_REP | 401 #undef SET_REP |
| 402 | 402 |
| 403 #undef SET_BOOL | 403 #undef SET_BOOL |
| 404 #undef SET_BYTES | 404 #undef SET_BYTES |
| 405 #undef SET_INT32 | 405 #undef SET_INT32 |
| 406 #undef SET_INT64 | 406 #undef SET_INT64 |
| 407 #undef SET_INT64_REP | 407 #undef SET_INT64_REP |
| 408 #undef SET_STR | 408 #undef SET_STR |
| 409 #undef SET_STR_REP | 409 #undef SET_STR_REP |
| 410 | 410 |
| 411 #undef SET_EXTENSION | 411 #undef SET_EXTENSION |
| 412 | 412 |
| 413 } // namespace browser_sync | 413 } // namespace browser_sync |
| OLD | NEW |