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 "chrome/browser/chromeos/cros/network_library_impl_cros.h" | 5 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_writer.h" // for debug output only. | 9 #include "base/json/json_writer.h" // for debug output only. |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/chromeos/cros/cros_library.h" | 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
14 #include "chrome/browser/chromeos/cros/native_network_constants.h" | 14 #include "chrome/browser/chromeos/cros/native_network_constants.h" |
15 #include "chrome/browser/chromeos/cros/native_network_parser.h" | 15 #include "chrome/browser/chromeos/cros/native_network_parser.h" |
16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chromeos/network/cros_network_functions.h" |
| 19 #include "chromeos/network/network_util.h" |
18 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
19 #include "third_party/cros_system_api/dbus/service_constants.h" | 21 #include "third_party/cros_system_api/dbus/service_constants.h" |
20 | 22 |
21 using content::BrowserThread; | 23 using content::BrowserThread; |
22 | 24 |
23 namespace chromeos { | 25 namespace chromeos { |
24 | 26 |
25 // Structure used to pass IP parameter info to a DoSetIPParameters callback, | 27 // Structure used to pass IP parameter info to a DoSetIPParameters callback, |
26 // since Bind only takes up to six parameters. | 28 // since Bind only takes up to six parameters. |
27 struct NetworkLibraryImplCros::IPParameterInfo { | 29 struct NetworkLibraryImplCros::IPParameterInfo { |
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 } | 1307 } |
1306 | 1308 |
1307 if (info.dhcp_usage_mask & USE_DHCP_NETMASK) { | 1309 if (info.dhcp_usage_mask & USE_DHCP_NETMASK) { |
1308 if (prefixlen_exists) { | 1310 if (prefixlen_exists) { |
1309 something_changed = true; | 1311 something_changed = true; |
1310 CrosClearNetworkServiceProperty(service_path, | 1312 CrosClearNetworkServiceProperty(service_path, |
1311 shill::kStaticIPPrefixlenProperty); | 1313 shill::kStaticIPPrefixlenProperty); |
1312 VLOG(2) << "Clearing " << shill::kStaticIPPrefixlenProperty; | 1314 VLOG(2) << "Clearing " << shill::kStaticIPPrefixlenProperty; |
1313 } | 1315 } |
1314 } else { | 1316 } else { |
1315 int prefixlen = CrosNetmaskToPrefixLength(info.netmask); | 1317 int prefixlen = network_util::NetmaskToPrefixLength(info.netmask); |
1316 if (prefixlen == -1) { | 1318 if (prefixlen == -1) { |
1317 VLOG(1) << "IPConfig prefix length is invalid for netmask " | 1319 VLOG(1) << "IPConfig prefix length is invalid for netmask " |
1318 << info.netmask; | 1320 << info.netmask; |
1319 } else if (current_prefixlen != prefixlen) { | 1321 } else if (current_prefixlen != prefixlen) { |
1320 base::FundamentalValue value(prefixlen); | 1322 base::FundamentalValue value(prefixlen); |
1321 VLOG(2) << "Setting " << shill::kStaticIPPrefixlenProperty | 1323 VLOG(2) << "Setting " << shill::kStaticIPPrefixlenProperty |
1322 << " to " << prefixlen; | 1324 << " to " << prefixlen; |
1323 something_changed = true; | 1325 something_changed = true; |
1324 CrosSetNetworkServiceProperty(service_path, | 1326 CrosSetNetworkServiceProperty(service_path, |
1325 shill::kStaticIPPrefixlenProperty, | 1327 shill::kStaticIPPrefixlenProperty, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 RefreshIPConfig(network); | 1380 RefreshIPConfig(network); |
1379 } | 1381 } |
1380 | 1382 |
1381 // static | 1383 // static |
1382 bool NetworkLibraryImplCros::AreProfilePathsEqual(const NetworkProfile& a, | 1384 bool NetworkLibraryImplCros::AreProfilePathsEqual(const NetworkProfile& a, |
1383 const NetworkProfile& b) { | 1385 const NetworkProfile& b) { |
1384 return a.path == b.path; | 1386 return a.path == b.path; |
1385 } | 1387 } |
1386 | 1388 |
1387 } // namespace chromeos | 1389 } // namespace chromeos |
OLD | NEW |