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

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 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } else if (key == shill::kImeiProperty) { 115 } else if (key == shill::kImeiProperty) {
115 return GetStringValue(key, value, &imei_); 116 return GetStringValue(key, value, &imei_);
116 } else if (key == shill::kIccidProperty) { 117 } else if (key == shill::kIccidProperty) {
117 return GetStringValue(key, value, &iccid_); 118 return GetStringValue(key, value, &iccid_);
118 } else if (key == shill::kMdnProperty) { 119 } else if (key == shill::kMdnProperty) {
119 return GetStringValue(key, value, &mdn_); 120 return GetStringValue(key, value, &mdn_);
120 } else if (key == shill::kSIMPresentProperty) { 121 } else if (key == shill::kSIMPresentProperty) {
121 return GetBooleanValue(key, value, &sim_present_); 122 return GetBooleanValue(key, value, &sim_present_);
122 } else if (key == shill::kEapAuthenticationCompletedProperty) { 123 } else if (key == shill::kEapAuthenticationCompletedProperty) {
123 return GetBooleanValue(key, value, &eap_authentication_completed_); 124 return GetBooleanValue(key, value, &eap_authentication_completed_);
125 } else if (key == shill::kIPConfigsProperty) {
126 // If kIPConfigsProperty changes, clear any previous ip_configs_.
127 // ShillPropertyhandler will request the IPConfig objects which will trigger
128 // calls to IPConfigPropertiesChanged.
129 ip_configs_.Clear();
130 return false; // No actual state change.
124 } 131 }
125 return false; 132 return false;
126 } 133 }
127 134
128 bool DeviceState::InitialPropertiesReceived( 135 bool DeviceState::InitialPropertiesReceived(
129 const base::DictionaryValue& properties) { 136 const base::DictionaryValue& properties) {
130 // Update UMA stats. 137 // Update UMA stats.
131 if (sim_present_) { 138 if (sim_present_) {
132 bool locked = !sim_lock_type_.empty(); 139 bool locked = !sim_lock_type_.empty();
133 UMA_HISTOGRAM_BOOLEAN("Cellular.SIMLocked", locked); 140 UMA_HISTOGRAM_BOOLEAN("Cellular.SIMLocked", locked);
134 } 141 }
135 return false; 142 return false;
136 } 143 }
137 144
145 void DeviceState::IPConfigPropertiesChanged(
146 const std::string& ip_config_path,
147 const base::DictionaryValue& properties) {
148 base::DictionaryValue* ip_config = NULL;
149 if (ip_configs_.GetDictionaryWithoutPathExpansion(
150 ip_config_path, &ip_config)) {
151 NET_LOG_EVENT("IPConfig Updated: " + ip_config_path, path());
152 ip_config->Clear();
153 } else {
154 NET_LOG_EVENT("IPConfig Added: " + ip_config_path, path());
155 ip_config = new base::DictionaryValue;
156 ip_configs_.SetWithoutPathExpansion(ip_config_path, ip_config);
157 }
158 ip_config->MergeDictionary(&properties);
159 }
160
138 std::string DeviceState::GetFormattedMacAddress() const { 161 std::string DeviceState::GetFormattedMacAddress() const {
139 if (mac_address_.size() % 2 != 0) 162 if (mac_address_.size() % 2 != 0)
140 return mac_address_; 163 return mac_address_;
141 std::string result; 164 std::string result;
142 for (size_t i = 0; i < mac_address_.size(); ++i) { 165 for (size_t i = 0; i < mac_address_.size(); ++i) {
143 if ((i != 0) && (i % 2 == 0)) 166 if ((i != 0) && (i % 2 == 0))
144 result.push_back(':'); 167 result.push_back(':');
145 result.push_back(mac_address_[i]); 168 result.push_back(mac_address_[i]);
146 } 169 }
147 return result; 170 return result;
148 } 171 }
149 172
150 bool DeviceState::IsSimAbsent() const { 173 bool DeviceState::IsSimAbsent() const {
151 return technology_family_ == shill::kTechnologyFamilyGsm && !sim_present_; 174 return technology_family_ == shill::kTechnologyFamilyGsm && !sim_present_;
152 } 175 }
153 176
154 } // namespace chromeos 177 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/device_state.h ('k') | chromeos/network/managed_network_configuration_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698