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

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

Issue 19509002: Add support for Device.ProposeScan to NetworkDeviceHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed gauravsh@'s comments. Created 7 years, 5 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.h ('k') | chromeos/network/network_util_unittest.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/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 10
10 namespace chromeos { 11 namespace chromeos {
11 12
12 SMS::SMS() : validity(0), msgclass(0) { 13 SMS::SMS() : validity(0), msgclass(0) {
13 } 14 }
14 15
15 SMS::~SMS() { 16 SMS::~SMS() {
16 } 17 }
17 18
18 WifiAccessPoint::WifiAccessPoint() 19 WifiAccessPoint::WifiAccessPoint()
19 : signal_strength(0), 20 : signal_strength(0),
20 signal_to_noise(0), 21 signal_to_noise(0),
21 channel(0) { 22 channel(0) {
22 } 23 }
23 24
24 WifiAccessPoint::~WifiAccessPoint() { 25 WifiAccessPoint::~WifiAccessPoint() {
25 } 26 }
26 27
28 CellularScanResult::CellularScanResult() {
29 }
30
31 CellularScanResult::~CellularScanResult() {
32 }
33
27 namespace network_util { 34 namespace network_util {
28 35
29 std::string PrefixLengthToNetmask(int32 prefix_length) { 36 std::string PrefixLengthToNetmask(int32 prefix_length) {
30 std::string netmask; 37 std::string netmask;
31 // Return the empty string for invalid inputs. 38 // Return the empty string for invalid inputs.
32 if (prefix_length < 0 || prefix_length > 32) 39 if (prefix_length < 0 || prefix_length > 32)
33 return netmask; 40 return netmask;
34 for (int i = 0; i < 4; i++) { 41 for (int i = 0; i < 4; i++) {
35 int remainder = 8; 42 int remainder = 8;
36 if (prefix_length >= 8) { 43 if (prefix_length >= 8) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // mask is not a valid number. 92 // mask is not a valid number.
86 return -1; 93 return -1;
87 } 94 }
88 count++; 95 count++;
89 } 96 }
90 if (count < 4) 97 if (count < 4)
91 return -1; 98 return -1;
92 return prefix_length; 99 return prefix_length;
93 } 100 }
94 101
102 bool ParseCellularScanResults(
103 const ListValue& list, std::vector<CellularScanResult>* scan_results) {
104 scan_results->clear();
105 scan_results->reserve(list.GetSize());
106 for (ListValue::const_iterator it = list.begin(); it != list.end(); ++it) {
107 if (!(*it)->IsType(base::Value::TYPE_DICTIONARY))
108 return false;
109 CellularScanResult scan_result;
110 const DictionaryValue* dict = static_cast<const DictionaryValue*>(*it);
111 // If the network id property is not present then this network cannot be
112 // connected to so don't include it in the results.
113 if (!dict->GetStringWithoutPathExpansion(flimflam::kNetworkIdProperty,
114 &scan_result.network_id))
115 continue;
116 dict->GetStringWithoutPathExpansion(flimflam::kStatusProperty,
117 &scan_result.status);
118 dict->GetStringWithoutPathExpansion(flimflam::kLongNameProperty,
119 &scan_result.long_name);
120 dict->GetStringWithoutPathExpansion(flimflam::kShortNameProperty,
121 &scan_result.short_name);
122 dict->GetStringWithoutPathExpansion(flimflam::kTechnologyProperty,
123 &scan_result.technology);
124 scan_results->push_back(scan_result);
125 }
126 return true;
127 }
128
95 } // namespace network_util 129 } // namespace network_util
96 } // namespace chromeos 130 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_util.h ('k') | chromeos/network/network_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698