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

Side by Side Diff: chromeos/network/network_util.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 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 "chromeos/network/network_util.h" 5 #include "chromeos/network/network_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility>
11
10 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_tokenizer.h" 13 #include "base/strings/string_tokenizer.h"
12 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
13 #include "chromeos/login/login_state.h" 15 #include "chromeos/login/login_state.h"
14 #include "chromeos/network/device_state.h" 16 #include "chromeos/network/device_state.h"
15 #include "chromeos/network/managed_network_configuration_handler.h" 17 #include "chromeos/network/managed_network_configuration_handler.h"
16 #include "chromeos/network/network_state.h" 18 #include "chromeos/network/network_state.h"
17 #include "chromeos/network/network_state_handler.h" 19 #include "chromeos/network/network_state_handler.h"
18 #include "chromeos/network/network_ui_data.h" 20 #include "chromeos/network/network_ui_data.h"
19 #include "chromeos/network/onc/onc_signature.h" 21 #include "chromeos/network/onc/onc_signature.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 bool visible_only, 199 bool visible_only,
198 int limit) { 200 int limit) {
199 NetworkStateHandler::NetworkStateList network_states; 201 NetworkStateHandler::NetworkStateList network_states;
200 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( 202 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
201 pattern, configured_only, visible_only, limit, &network_states); 203 pattern, configured_only, visible_only, limit, &network_states);
202 204
203 std::unique_ptr<base::ListValue> network_properties_list(new base::ListValue); 205 std::unique_ptr<base::ListValue> network_properties_list(new base::ListValue);
204 for (const NetworkState* state : network_states) { 206 for (const NetworkState* state : network_states) {
205 std::unique_ptr<base::DictionaryValue> onc_dictionary = 207 std::unique_ptr<base::DictionaryValue> onc_dictionary =
206 TranslateNetworkStateToONC(state); 208 TranslateNetworkStateToONC(state);
207 network_properties_list->Append(onc_dictionary.release()); 209 network_properties_list->Append(std::move(onc_dictionary));
208 } 210 }
209 return network_properties_list; 211 return network_properties_list;
210 } 212 }
211 213
212 std::string TranslateONCTypeToShill(const std::string& onc_type) { 214 std::string TranslateONCTypeToShill(const std::string& onc_type) {
213 if (onc_type == ::onc::network_type::kEthernet) 215 if (onc_type == ::onc::network_type::kEthernet)
214 return shill::kTypeEthernet; 216 return shill::kTypeEthernet;
215 std::string shill_type; 217 std::string shill_type;
216 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type); 218 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type);
217 return shill_type; 219 return shill_type;
218 } 220 }
219 221
220 std::string TranslateShillTypeToONC(const std::string& shill_type) { 222 std::string TranslateShillTypeToONC(const std::string& shill_type) {
221 if (shill_type == shill::kTypeEthernet) 223 if (shill_type == shill::kTypeEthernet)
222 return ::onc::network_type::kEthernet; 224 return ::onc::network_type::kEthernet;
223 std::string onc_type; 225 std::string onc_type;
224 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); 226 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type);
225 return onc_type; 227 return onc_type;
226 } 228 }
227 229
228 } // namespace network_util 230 } // namespace network_util
229 } // namespace chromeos 231 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_state_handler_unittest.cc ('k') | chromeos/network/network_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698