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 #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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 out->Append(new base::StringValue(from)); | 153 out->Append(new base::StringValue(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->DeepCopy()); | 163 out->Append(from->CreateDeepCopy()); |
164 } | 164 } |
165 | 165 |
166 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from, | 166 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from, |
167 base::ListValue* out) { | 167 base::ListValue* out) { |
168 out->Append(static_cast<base::Value*>(from->DeepCopy())); | 168 out->Append(from->CreateDeepCopy()); |
169 } | 169 } |
170 | 170 |
171 std::string ValueTypeToString(base::Value::Type type) { | 171 std::string ValueTypeToString(base::Value::Type type) { |
172 switch (type) { | 172 switch (type) { |
173 case base::Value::TYPE_NULL: | 173 case base::Value::TYPE_NULL: |
174 return "null"; | 174 return "null"; |
175 case base::Value::TYPE_BOOLEAN: | 175 case base::Value::TYPE_BOOLEAN: |
176 return "boolean"; | 176 return "boolean"; |
177 case base::Value::TYPE_INTEGER: | 177 case base::Value::TYPE_INTEGER: |
178 return "integer"; | 178 return "integer"; |
179 case base::Value::TYPE_DOUBLE: | 179 case base::Value::TYPE_DOUBLE: |
180 return "number"; | 180 return "number"; |
181 case base::Value::TYPE_STRING: | 181 case base::Value::TYPE_STRING: |
182 return "string"; | 182 return "string"; |
183 case base::Value::TYPE_BINARY: | 183 case base::Value::TYPE_BINARY: |
184 return "binary"; | 184 return "binary"; |
185 case base::Value::TYPE_DICTIONARY: | 185 case base::Value::TYPE_DICTIONARY: |
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 |
OLD | NEW |