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

Side by Side Diff: components/sync/protocol/proto_value_conversions.cc

Issue 2256733004: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 // 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 "components/sync/protocol/proto_value_conversions.h" 7 #include "components/sync/protocol/proto_value_conversions.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "components/sync/protocol/typed_url_specifics.pb.h" 47 #include "components/sync/protocol/typed_url_specifics.pb.h"
48 #include "components/sync/protocol/unique_position.pb.h" 48 #include "components/sync/protocol/unique_position.pb.h"
49 49
50 namespace syncer { 50 namespace syncer {
51 51
52 namespace { 52 namespace {
53 53
54 // Basic Type -> Value functions. 54 // Basic Type -> Value functions.
55 55
56 std::unique_ptr<base::StringValue> MakeInt64Value(int64_t x) { 56 std::unique_ptr<base::StringValue> MakeInt64Value(int64_t x) {
57 return base::WrapUnique(new base::StringValue(base::Int64ToString(x))); 57 return base::MakeUnique<base::StringValue>(base::Int64ToString(x));
58 } 58 }
59 59
60 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use 60 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use
61 // that instead of a StringValue. 61 // that instead of a StringValue.
62 std::string Base64EncodeString(const std::string& bytes) { 62 std::string Base64EncodeString(const std::string& bytes) {
63 std::string bytes_base64; 63 std::string bytes_base64;
64 base::Base64Encode(bytes, &bytes_base64); 64 base::Base64Encode(bytes, &bytes_base64);
65 return bytes_base64; 65 return bytes_base64;
66 } 66 }
67 67
68 std::unique_ptr<base::StringValue> MakeStringValue(const std::string& str) { 68 std::unique_ptr<base::StringValue> MakeStringValue(const std::string& str) {
69 return base::WrapUnique(new base::StringValue(str)); 69 return base::MakeUnique<base::StringValue>(str);
70 } 70 }
71 71
72 // T is the field type, F is either RepeatedField or RepeatedPtrField, 72 // T is the field type, F is either RepeatedField or RepeatedPtrField,
73 // and V is a subclass of Value. 73 // and V is a subclass of Value.
74 template <class T, class F, class V> 74 template <class T, class F, class V>
75 std::unique_ptr<base::ListValue> MakeRepeatedValue(const F& fields, 75 std::unique_ptr<base::ListValue> MakeRepeatedValue(const F& fields,
76 V (*converter_fn)(T)) { 76 V (*converter_fn)(T)) {
77 std::unique_ptr<base::ListValue> list(new base::ListValue()); 77 std::unique_ptr<base::ListValue> list(new base::ListValue());
78 for (typename F::const_iterator it = fields.begin(); it != fields.end(); 78 for (typename F::const_iterator it = fields.begin(); it != fields.end();
79 ++it) { 79 ++it) {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 std::unique_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue( 620 std::unique_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue(
621 const sync_pb::PriorityPreferenceSpecifics& specifics) { 621 const sync_pb::PriorityPreferenceSpecifics& specifics) {
622 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 622 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
623 SET_FIELD(preference, PreferenceSpecificsToValue); 623 SET_FIELD(preference, PreferenceSpecificsToValue);
624 return value; 624 return value;
625 } 625 }
626 626
627 std::unique_ptr<base::DictionaryValue> 627 std::unique_ptr<base::DictionaryValue>
628 SyncedNotificationAppInfoSpecificsToValue( 628 SyncedNotificationAppInfoSpecificsToValue(
629 const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { 629 const sync_pb::SyncedNotificationAppInfoSpecifics& proto) {
630 return base::WrapUnique(new base::DictionaryValue()); 630 return base::MakeUnique<base::DictionaryValue>();
631 } 631 }
632 632
633 std::unique_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue( 633 std::unique_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue(
634 const sync_pb::SyncedNotificationSpecifics& proto) { 634 const sync_pb::SyncedNotificationSpecifics& proto) {
635 return base::WrapUnique(new base::DictionaryValue()); 635 return base::MakeUnique<base::DictionaryValue>();
636 } 636 }
637 637
638 std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( 638 std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue(
639 const sync_pb::SearchEngineSpecifics& proto) { 639 const sync_pb::SearchEngineSpecifics& proto) {
640 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 640 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
641 SET_STR(short_name); 641 SET_STR(short_name);
642 SET_STR(keyword); 642 SET_STR(keyword);
643 SET_STR(favicon_url); 643 SET_STR(favicon_url);
644 SET_STR(url); 644 SET_STR(url);
645 SET_BOOL(safe_for_autoreplace); 645 SET_BOOL(safe_for_autoreplace);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 #undef SET_BYTES 1089 #undef SET_BYTES
1090 #undef SET_INT32 1090 #undef SET_INT32
1091 #undef SET_INT64 1091 #undef SET_INT64
1092 #undef SET_INT64_REP 1092 #undef SET_INT64_REP
1093 #undef SET_STR 1093 #undef SET_STR
1094 #undef SET_STR_REP 1094 #undef SET_STR_REP
1095 1095
1096 #undef SET_FIELD 1096 #undef SET_FIELD
1097 1097
1098 } // namespace syncer 1098 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/model_type_worker_unittest.cc ('k') | components/sync/tools/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698