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

Side by Side Diff: tools/json_schema_compiler/util.cc

Issue 2036013002: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « tools/json_schema_compiler/test/simple_api_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "tools/json_schema_compiler/util.h" 5 #include "tools/json_schema_compiler/util.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 9
10 namespace json_schema_compiler { 10 namespace json_schema_compiler {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 error->append(base::UTF8ToUTF16("expected dictionary, got " + 132 error->append(base::UTF8ToUTF16("expected dictionary, got " +
133 ValueTypeToString(from.GetType()))); 133 ValueTypeToString(from.GetType())));
134 return false; 134 return false;
135 } 135 }
136 *out = dict->CreateDeepCopy(); 136 *out = dict->CreateDeepCopy();
137 return true; 137 return true;
138 } 138 }
139 139
140 void AddItemToList(const int from, base::ListValue* out) { 140 void AddItemToList(const int from, base::ListValue* out) {
141 out->Append(new base::FundamentalValue(from)); 141 out->AppendInteger(from);
142 } 142 }
143 143
144 void AddItemToList(const bool from, base::ListValue* out) { 144 void AddItemToList(const bool from, base::ListValue* out) {
145 out->Append(new base::FundamentalValue(from)); 145 out->AppendBoolean(from);
146 } 146 }
147 147
148 void AddItemToList(const double from, base::ListValue* out) { 148 void AddItemToList(const double from, base::ListValue* out) {
149 out->Append(new base::FundamentalValue(from)); 149 out->AppendDouble(from);
150 } 150 }
151 151
152 void AddItemToList(const std::string& from, base::ListValue* out) { 152 void AddItemToList(const std::string& from, base::ListValue* out) {
153 out->Append(new base::StringValue(from)); 153 out->AppendString(from);
154 } 154 }
155 155
156 void AddItemToList(const std::vector<char>& from, base::ListValue* out) { 156 void AddItemToList(const std::vector<char>& from, base::ListValue* out) {
157 out->Append( 157 out->Append(
158 base::BinaryValue::CreateWithCopiedBuffer(from.data(), from.size())); 158 base::BinaryValue::CreateWithCopiedBuffer(from.data(), from.size()));
159 } 159 }
160 160
161 void AddItemToList(const std::unique_ptr<base::Value>& from, 161 void AddItemToList(const std::unique_ptr<base::Value>& from,
162 base::ListValue* out) { 162 base::ListValue* out) {
163 out->Append(from->CreateDeepCopy()); 163 out->Append(from->CreateDeepCopy());
(...skipping 22 matching lines...) Expand all
186 return "dictionary"; 186 return "dictionary";
187 case base::Value::TYPE_LIST: 187 case base::Value::TYPE_LIST:
188 return "list"; 188 return "list";
189 } 189 }
190 NOTREACHED(); 190 NOTREACHED();
191 return ""; 191 return "";
192 } 192 }
193 193
194 } // namespace util 194 } // namespace util
195 } // namespace json_schema_compiler 195 } // namespace json_schema_compiler
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/simple_api_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698