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

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

Issue 267433005: Provide IPConfigs in networkingPrivate.GetProperties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Elim DHCP ONC types Created 6 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 | Annotate | Revision Log
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/device_state.h" 5 #include "chromeos/network/device_state.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chromeos/network/network_event_log.h"
11 #include "third_party/cros_system_api/dbus/service_constants.h" 12 #include "third_party/cros_system_api/dbus/service_constants.h"
12 13
13 namespace chromeos { 14 namespace chromeos {
14 15
15 DeviceState::DeviceState(const std::string& path) 16 DeviceState::DeviceState(const std::string& path)
16 : ManagedState(MANAGED_TYPE_DEVICE, path), 17 : ManagedState(MANAGED_TYPE_DEVICE, path),
17 allow_roaming_(false), 18 allow_roaming_(false),
18 provider_requires_roaming_(false), 19 provider_requires_roaming_(false),
19 support_network_scan_(false), 20 support_network_scan_(false),
20 scanning_(false), 21 scanning_(false),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return false; 126 return false;
126 } 127 }
127 128
128 bool DeviceState::InitialPropertiesReceived( 129 bool DeviceState::InitialPropertiesReceived(
129 const base::DictionaryValue& properties) { 130 const base::DictionaryValue& properties) {
130 // Update UMA stats. 131 // Update UMA stats.
131 if (sim_present_) { 132 if (sim_present_) {
132 bool locked = !sim_lock_type_.empty(); 133 bool locked = !sim_lock_type_.empty();
133 UMA_HISTOGRAM_BOOLEAN("Cellular.SIMLocked", locked); 134 UMA_HISTOGRAM_BOOLEAN("Cellular.SIMLocked", locked);
134 } 135 }
136 // IP Configs will be added when they are received.
pneubeck (no reviews) 2014/05/05 21:09:28 the comment doesn't explain why you have to clear
stevenjb 2014/05/06 01:15:11 Moved this logic and added a better comment.
137 ip_configs_.Clear();
135 return false; 138 return false;
136 } 139 }
137 140
141 void DeviceState::IPConfigPropertiesChanged(
142 const std::string& ip_config_path,
143 const base::DictionaryValue& properties) {
144 base::DictionaryValue* ip_config;
pneubeck (no reviews) 2014/05/05 21:09:28 nit: initialize with NULL
stevenjb 2014/05/06 01:15:11 Done.
145 if (ip_configs_.GetDictionaryWithoutPathExpansion(
146 ip_config_path, &ip_config)) {
147 NET_LOG_EVENT("IPConfig Updated: " + ip_config_path, path());
148 ip_config->Clear();
149 } else {
150 NET_LOG_EVENT("IPConfig Added: " + ip_config_path, path());
151 ip_config = new base::DictionaryValue;
152 ip_configs_.SetWithoutPathExpansion(ip_config_path, ip_config);
153 }
154 ip_config->MergeDictionary(&properties);
155 }
156
138 std::string DeviceState::GetFormattedMacAddress() const { 157 std::string DeviceState::GetFormattedMacAddress() const {
139 if (mac_address_.size() % 2 != 0) 158 if (mac_address_.size() % 2 != 0)
140 return mac_address_; 159 return mac_address_;
141 std::string result; 160 std::string result;
142 for (size_t i = 0; i < mac_address_.size(); ++i) { 161 for (size_t i = 0; i < mac_address_.size(); ++i) {
143 if ((i != 0) && (i % 2 == 0)) 162 if ((i != 0) && (i % 2 == 0))
144 result.push_back(':'); 163 result.push_back(':');
145 result.push_back(mac_address_[i]); 164 result.push_back(mac_address_[i]);
146 } 165 }
147 return result; 166 return result;
148 } 167 }
149 168
150 bool DeviceState::IsSimAbsent() const { 169 bool DeviceState::IsSimAbsent() const {
151 return technology_family_ == shill::kTechnologyFamilyGsm && !sim_present_; 170 return technology_family_ == shill::kTechnologyFamilyGsm && !sim_present_;
152 } 171 }
153 172
154 } // namespace chromeos 173 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698