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

Side by Side Diff: dbus/values_util.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix various builds. 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
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 "dbus/values_util.h" 5 #include "dbus/values_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 array_writer.CloseContainer(&dict_entry_writer); 272 array_writer.CloseContainer(&dict_entry_writer);
273 } 273 }
274 writer->CloseContainer(&array_writer); 274 writer->CloseContainer(&array_writer);
275 break; 275 break;
276 } 276 }
277 case base::Value::TYPE_LIST: { 277 case base::Value::TYPE_LIST: {
278 const base::ListValue* list = NULL; 278 const base::ListValue* list = NULL;
279 value.GetAsList(&list); 279 value.GetAsList(&list);
280 dbus::MessageWriter array_writer(NULL); 280 dbus::MessageWriter array_writer(NULL);
281 writer->OpenArray("v", &array_writer); 281 writer->OpenArray("v", &array_writer);
282 for (base::ListValue::const_iterator iter = list->begin(); 282 for (const auto& value : *list) {
283 iter != list->end(); ++iter) {
284 const base::Value* value = *iter;
285 AppendValueDataAsVariant(&array_writer, *value); 283 AppendValueDataAsVariant(&array_writer, *value);
286 } 284 }
287 writer->CloseContainer(&array_writer); 285 writer->CloseContainer(&array_writer);
288 break; 286 break;
289 } 287 }
290 case base::Value::TYPE_BOOLEAN: 288 case base::Value::TYPE_BOOLEAN:
291 case base::Value::TYPE_INTEGER: 289 case base::Value::TYPE_INTEGER:
292 case base::Value::TYPE_DOUBLE: 290 case base::Value::TYPE_DOUBLE:
293 case base::Value::TYPE_STRING: 291 case base::Value::TYPE_STRING:
294 AppendBasicTypeValueData(writer, value); 292 AppendBasicTypeValueData(writer, value);
295 break; 293 break;
296 default: 294 default:
297 DLOG(ERROR) << "Unexpected type: " << value.GetType(); 295 DLOG(ERROR) << "Unexpected type: " << value.GetType();
298 } 296 }
299 } 297 }
300 298
301 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) { 299 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) {
302 MessageWriter variant_writer(NULL); 300 MessageWriter variant_writer(NULL);
303 writer->OpenVariant(GetTypeSignature(value), &variant_writer); 301 writer->OpenVariant(GetTypeSignature(value), &variant_writer);
304 AppendValueData(&variant_writer, value); 302 AppendValueData(&variant_writer, value);
305 writer->CloseContainer(&variant_writer); 303 writer->CloseContainer(&variant_writer);
306 } 304 }
307 305
308 } // namespace dbus 306 } // namespace dbus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698