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

Side by Side Diff: chrome/browser/sync/protocol/proto_value_conversions.cc

Issue 9460047: sync: remove use of protobuf extensions in protocol to reduce static init overhead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fred's review Created 8 years, 9 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 | Annotate | Revision Log
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 // 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
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_FIELD(field, fn) \
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?
109 SET_BYTES(blob); 109 SET_BYTES(blob);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_FIELD(app, AppSpecificsToValue);
383 SET_EXTENSION(sync_pb, app_notification, AppNotificationToValue); 383 SET_FIELD(app_notification, AppNotificationToValue);
384 SET_EXTENSION(sync_pb, app_setting, AppSettingSpecificsToValue); 384 SET_FIELD(app_setting, AppSettingSpecificsToValue);
385 SET_EXTENSION(sync_pb, autofill, AutofillSpecificsToValue); 385 SET_FIELD(autofill, AutofillSpecificsToValue);
386 SET_EXTENSION(sync_pb, autofill_profile, AutofillProfileSpecificsToValue); 386 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue);
387 SET_EXTENSION(sync_pb, bookmark, BookmarkSpecificsToValue); 387 SET_FIELD(bookmark, BookmarkSpecificsToValue);
388 SET_EXTENSION(sync_pb, extension, ExtensionSpecificsToValue); 388 SET_FIELD(extension, ExtensionSpecificsToValue);
389 SET_EXTENSION(sync_pb, extension_setting, ExtensionSettingSpecificsToValue); 389 SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue);
390 SET_EXTENSION(sync_pb, nigori, NigoriSpecificsToValue); 390 SET_FIELD(nigori, NigoriSpecificsToValue);
391 SET_EXTENSION(sync_pb, password, PasswordSpecificsToValue); 391 SET_FIELD(password, PasswordSpecificsToValue);
392 SET_EXTENSION(sync_pb, preference, PreferenceSpecificsToValue); 392 SET_FIELD(preference, PreferenceSpecificsToValue);
393 SET_EXTENSION(sync_pb, search_engine, SearchEngineSpecificsToValue); 393 SET_FIELD(search_engine, SearchEngineSpecificsToValue);
394 SET_EXTENSION(sync_pb, session, SessionSpecificsToValue); 394 SET_FIELD(session, SessionSpecificsToValue);
395 SET_EXTENSION(sync_pb, theme, ThemeSpecificsToValue); 395 SET_FIELD(theme, ThemeSpecificsToValue);
396 SET_EXTENSION(sync_pb, typed_url, TypedUrlSpecificsToValue); 396 SET_FIELD(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_FIELD
412 412
413 } // namespace browser_sync 413 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698