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

Side by Side Diff: chromeos/network/onc/onc_mapper.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: More fixes Created 4 years, 7 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 | « chromeos/network/network_util.cc ('k') | chromeos/network/onc/onc_utils.cc » ('j') | 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 "chromeos/network/onc/onc_mapper.h" 5 #include "chromeos/network/onc/onc_mapper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chromeos/network/onc/onc_signature.h" 10 #include "chromeos/network/onc/onc_signature.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 std::unique_ptr<base::ListValue> Mapper::MapArray( 110 std::unique_ptr<base::ListValue> Mapper::MapArray(
111 const OncValueSignature& array_signature, 111 const OncValueSignature& array_signature,
112 const base::ListValue& onc_array, 112 const base::ListValue& onc_array,
113 bool* nested_error) { 113 bool* nested_error) {
114 DCHECK(array_signature.onc_array_entry_signature != NULL) 114 DCHECK(array_signature.onc_array_entry_signature != NULL)
115 << "Found missing onc_array_entry_signature."; 115 << "Found missing onc_array_entry_signature.";
116 116
117 std::unique_ptr<base::ListValue> result_array(new base::ListValue); 117 std::unique_ptr<base::ListValue> result_array(new base::ListValue);
118 int original_index = 0; 118 int original_index = 0;
119 for (base::ListValue::const_iterator it = onc_array.begin(); 119 for (const auto& entry : onc_array) {
120 it != onc_array.end(); ++it, ++original_index) {
121 const base::Value* entry = *it;
122
123 std::unique_ptr<base::Value> result_entry; 120 std::unique_ptr<base::Value> result_entry;
124 result_entry = MapEntry(original_index, 121 result_entry = MapEntry(original_index,
125 *array_signature.onc_array_entry_signature, 122 *array_signature.onc_array_entry_signature,
126 *entry, 123 *entry,
127 nested_error); 124 nested_error);
128 if (result_entry.get() != NULL) 125 if (result_entry.get() != NULL)
129 result_array->Append(result_entry.release()); 126 result_array->Append(result_entry.release());
130 else 127 else
131 DCHECK(*nested_error); 128 DCHECK(*nested_error);
129 ++original_index;
132 } 130 }
133 return result_array; 131 return result_array;
134 } 132 }
135 133
136 std::unique_ptr<base::Value> Mapper::MapEntry( 134 std::unique_ptr<base::Value> Mapper::MapEntry(
137 int index, 135 int index,
138 const OncValueSignature& signature, 136 const OncValueSignature& signature,
139 const base::Value& onc_value, 137 const base::Value& onc_value,
140 bool* error) { 138 bool* error) {
141 return MapValue(signature, onc_value, error); 139 return MapValue(signature, onc_value, error);
142 } 140 }
143 141
144 } // namespace onc 142 } // namespace onc
145 } // namespace chromeos 143 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_util.cc ('k') | chromeos/network/onc/onc_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698