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 "chromeos/network/network_util.h" | 5 #include "chromeos/network/network_util.h" |
6 | 6 |
7 #include "base/strings/string_tokenizer.h" | 7 #include "base/strings/string_tokenizer.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "third_party/cros_system_api/dbus/service_constants.h" | 9 #include "third_party/cros_system_api/dbus/service_constants.h" |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // mask is not a valid number. | 86 // mask is not a valid number. |
87 return -1; | 87 return -1; |
88 } | 88 } |
89 count++; | 89 count++; |
90 } | 90 } |
91 if (count < 4) | 91 if (count < 4) |
92 return -1; | 92 return -1; |
93 return prefix_length; | 93 return prefix_length; |
94 } | 94 } |
95 | 95 |
96 bool ParseCellularScanResults( | 96 bool ParseCellularScanResults(const base::ListValue& list, |
97 const ListValue& list, std::vector<CellularScanResult>* scan_results) { | 97 std::vector<CellularScanResult>* scan_results) { |
98 scan_results->clear(); | 98 scan_results->clear(); |
99 scan_results->reserve(list.GetSize()); | 99 scan_results->reserve(list.GetSize()); |
100 for (ListValue::const_iterator it = list.begin(); it != list.end(); ++it) { | 100 for (base::ListValue::const_iterator it = list.begin(); |
| 101 it != list.end(); ++it) { |
101 if (!(*it)->IsType(base::Value::TYPE_DICTIONARY)) | 102 if (!(*it)->IsType(base::Value::TYPE_DICTIONARY)) |
102 return false; | 103 return false; |
103 CellularScanResult scan_result; | 104 CellularScanResult scan_result; |
104 const DictionaryValue* dict = static_cast<const DictionaryValue*>(*it); | 105 const base::DictionaryValue* dict = |
| 106 static_cast<const base::DictionaryValue*>(*it); |
105 // If the network id property is not present then this network cannot be | 107 // If the network id property is not present then this network cannot be |
106 // connected to so don't include it in the results. | 108 // connected to so don't include it in the results. |
107 if (!dict->GetStringWithoutPathExpansion(shill::kNetworkIdProperty, | 109 if (!dict->GetStringWithoutPathExpansion(shill::kNetworkIdProperty, |
108 &scan_result.network_id)) | 110 &scan_result.network_id)) |
109 continue; | 111 continue; |
110 dict->GetStringWithoutPathExpansion(shill::kStatusProperty, | 112 dict->GetStringWithoutPathExpansion(shill::kStatusProperty, |
111 &scan_result.status); | 113 &scan_result.status); |
112 dict->GetStringWithoutPathExpansion(shill::kLongNameProperty, | 114 dict->GetStringWithoutPathExpansion(shill::kLongNameProperty, |
113 &scan_result.long_name); | 115 &scan_result.long_name); |
114 dict->GetStringWithoutPathExpansion(shill::kShortNameProperty, | 116 dict->GetStringWithoutPathExpansion(shill::kShortNameProperty, |
115 &scan_result.short_name); | 117 &scan_result.short_name); |
116 dict->GetStringWithoutPathExpansion(shill::kTechnologyProperty, | 118 dict->GetStringWithoutPathExpansion(shill::kTechnologyProperty, |
117 &scan_result.technology); | 119 &scan_result.technology); |
118 scan_results->push_back(scan_result); | 120 scan_results->push_back(scan_result); |
119 } | 121 } |
120 return true; | 122 return true; |
121 } | 123 } |
122 | 124 |
123 } // namespace network_util | 125 } // namespace network_util |
124 } // namespace chromeos | 126 } // namespace chromeos |
OLD | NEW |