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

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

Issue 24348002: Migrate DBus service constants from flimflam namespace to shill namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased to ToT Created 7 years, 2 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/policy_util.cc ('k') | chromeos/network/shill_property_handler_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/shill_property_handler.h" 5 #include "chromeos/network/shill_property_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 base::Bind(&network_handler::ShillErrorCallbackFunction, 166 base::Bind(&network_handler::ShillErrorCallbackFunction,
167 "SetTechnologyEnabled Failed", 167 "SetTechnologyEnabled Failed",
168 technology, error_callback)); 168 technology, error_callback));
169 } 169 }
170 } 170 }
171 171
172 void ShillPropertyHandler::SetCheckPortalList( 172 void ShillPropertyHandler::SetCheckPortalList(
173 const std::string& check_portal_list) { 173 const std::string& check_portal_list) {
174 base::StringValue value(check_portal_list); 174 base::StringValue value(check_portal_list);
175 shill_manager_->SetProperty( 175 shill_manager_->SetProperty(
176 flimflam::kCheckPortalListProperty, 176 shill::kCheckPortalListProperty,
177 value, 177 value,
178 base::Bind(&base::DoNothing), 178 base::Bind(&base::DoNothing),
179 base::Bind(&network_handler::ShillErrorCallbackFunction, 179 base::Bind(&network_handler::ShillErrorCallbackFunction,
180 "SetCheckPortalList Failed", 180 "SetCheckPortalList Failed",
181 "", network_handler::ErrorCallback())); 181 "", network_handler::ErrorCallback()));
182 } 182 }
183 183
184 void ShillPropertyHandler::RequestScan() const { 184 void ShillPropertyHandler::RequestScan() const {
185 shill_manager_->RequestScan( 185 shill_manager_->RequestScan(
186 "", 186 "",
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 NET_LOG_ERROR("ManagerPropertiesCallback", 238 NET_LOG_ERROR("ManagerPropertiesCallback",
239 base::StringPrintf("Failed: %d", call_status)); 239 base::StringPrintf("Failed: %d", call_status));
240 return; 240 return;
241 } 241 }
242 NET_LOG_EVENT("ManagerPropertiesCallback", "Success"); 242 NET_LOG_EVENT("ManagerPropertiesCallback", "Success");
243 const base::Value* update_service_value = NULL; 243 const base::Value* update_service_value = NULL;
244 const base::Value* update_service_complete_value = NULL; 244 const base::Value* update_service_complete_value = NULL;
245 for (base::DictionaryValue::Iterator iter(properties); 245 for (base::DictionaryValue::Iterator iter(properties);
246 !iter.IsAtEnd(); iter.Advance()) { 246 !iter.IsAtEnd(); iter.Advance()) {
247 // Defer updating Services until all other properties have been updated. 247 // Defer updating Services until all other properties have been updated.
248 if (iter.key() == flimflam::kServicesProperty) 248 if (iter.key() == shill::kServicesProperty)
249 update_service_value = &iter.value(); 249 update_service_value = &iter.value();
250 else if (iter.key() == shill::kServiceCompleteListProperty) 250 else if (iter.key() == shill::kServiceCompleteListProperty)
251 update_service_complete_value = &iter.value(); 251 update_service_complete_value = &iter.value();
252 else 252 else
253 ManagerPropertyChanged(iter.key(), iter.value()); 253 ManagerPropertyChanged(iter.key(), iter.value());
254 } 254 }
255 // Update Services which can safely assume other properties have been set. 255 // Update Services which can safely assume other properties have been set.
256 if (update_service_value) 256 if (update_service_value)
257 ManagerPropertyChanged(flimflam::kServicesProperty, *update_service_value); 257 ManagerPropertyChanged(shill::kServicesProperty, *update_service_value);
258 // Update ServiceCompleteList which skips entries that have already been 258 // Update ServiceCompleteList which skips entries that have already been
259 // requested for Services. 259 // requested for Services.
260 if (update_service_complete_value) { 260 if (update_service_complete_value) {
261 ManagerPropertyChanged(shill::kServiceCompleteListProperty, 261 ManagerPropertyChanged(shill::kServiceCompleteListProperty,
262 *update_service_complete_value); 262 *update_service_complete_value);
263 } 263 }
264 264
265 CheckPendingStateListUpdates(""); 265 CheckPendingStateListUpdates("");
266 } 266 }
267 267
268 void ShillPropertyHandler::CheckPendingStateListUpdates( 268 void ShillPropertyHandler::CheckPendingStateListUpdates(
269 const std::string& key) { 269 const std::string& key) {
270 // Once there are no pending updates, signal the state list changed callbacks. 270 // Once there are no pending updates, signal the state list changed callbacks.
271 if ((key.empty() || key == flimflam::kServicesProperty) && 271 if ((key.empty() || key == shill::kServicesProperty) &&
272 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) { 272 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) {
273 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); 273 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK);
274 } 274 }
275 // Both Network update requests and Favorite update requests will affect 275 // Both Network update requests and Favorite update requests will affect
276 // the list of favorites, so wait for both to complete. 276 // the list of favorites, so wait for both to complete.
277 if ((key.empty() || key == shill::kServiceCompleteListProperty) && 277 if ((key.empty() || key == shill::kServiceCompleteListProperty) &&
278 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0 && 278 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0 &&
279 pending_updates_[ManagedState::MANAGED_TYPE_FAVORITE].size() == 0) { 279 pending_updates_[ManagedState::MANAGED_TYPE_FAVORITE].size() == 0) {
280 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE); 280 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE);
281 } 281 }
282 if ((key.empty() || key == flimflam::kDevicesProperty) && 282 if ((key.empty() || key == shill::kDevicesProperty) &&
283 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { 283 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) {
284 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); 284 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE);
285 } 285 }
286 } 286 }
287 287
288 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, 288 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key,
289 const base::Value& value) { 289 const base::Value& value) {
290 if (key == flimflam::kServicesProperty) { 290 if (key == shill::kServicesProperty) {
291 const base::ListValue* vlist = GetListValue(key, value); 291 const base::ListValue* vlist = GetListValue(key, value);
292 if (vlist) { 292 if (vlist) {
293 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); 293 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
294 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist); 294 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
295 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK, 295 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK,
296 // however that prevents us from receiving Strength updates from inactive 296 // however that prevents us from receiving Strength updates from inactive
297 // networks. The overhead for observing all services is not unreasonable 297 // networks. The overhead for observing all services is not unreasonable
298 // (and we limit the max number of observed services to kMaxObserved). 298 // (and we limit the max number of observed services to kMaxObserved).
299 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist); 299 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
300 } 300 }
301 } else if (key == shill::kServiceCompleteListProperty) { 301 } else if (key == shill::kServiceCompleteListProperty) {
302 const ListValue* vlist = GetListValue(key, value); 302 const ListValue* vlist = GetListValue(key, value);
303 if (vlist) { 303 if (vlist) {
304 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_FAVORITE, *vlist); 304 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_FAVORITE, *vlist);
305 UpdateProperties(ManagedState::MANAGED_TYPE_FAVORITE, *vlist); 305 UpdateProperties(ManagedState::MANAGED_TYPE_FAVORITE, *vlist);
306 } 306 }
307 } else if (key == flimflam::kDevicesProperty) { 307 } else if (key == shill::kDevicesProperty) {
308 const base::ListValue* vlist = GetListValue(key, value); 308 const base::ListValue* vlist = GetListValue(key, value);
309 if (vlist) { 309 if (vlist) {
310 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_DEVICE, *vlist); 310 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_DEVICE, *vlist);
311 UpdateProperties(ManagedState::MANAGED_TYPE_DEVICE, *vlist); 311 UpdateProperties(ManagedState::MANAGED_TYPE_DEVICE, *vlist);
312 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist); 312 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist);
313 } 313 }
314 } else if (key == flimflam::kAvailableTechnologiesProperty) { 314 } else if (key == shill::kAvailableTechnologiesProperty) {
315 const base::ListValue* vlist = GetListValue(key, value); 315 const base::ListValue* vlist = GetListValue(key, value);
316 if (vlist) 316 if (vlist)
317 UpdateAvailableTechnologies(*vlist); 317 UpdateAvailableTechnologies(*vlist);
318 } else if (key == flimflam::kEnabledTechnologiesProperty) { 318 } else if (key == shill::kEnabledTechnologiesProperty) {
319 const base::ListValue* vlist = GetListValue(key, value); 319 const base::ListValue* vlist = GetListValue(key, value);
320 if (vlist) 320 if (vlist)
321 UpdateEnabledTechnologies(*vlist); 321 UpdateEnabledTechnologies(*vlist);
322 } else if (key == shill::kUninitializedTechnologiesProperty) { 322 } else if (key == shill::kUninitializedTechnologiesProperty) {
323 const base::ListValue* vlist = GetListValue(key, value); 323 const base::ListValue* vlist = GetListValue(key, value);
324 if (vlist) 324 if (vlist)
325 UpdateUninitializedTechnologies(*vlist); 325 UpdateUninitializedTechnologies(*vlist);
326 } else if (key == flimflam::kProfilesProperty) { 326 } else if (key == shill::kProfilesProperty) {
327 listener_->ProfileListChanged(); 327 listener_->ProfileListChanged();
328 } else if (key == flimflam::kCheckPortalListProperty) { 328 } else if (key == shill::kCheckPortalListProperty) {
329 std::string check_portal_list; 329 std::string check_portal_list;
330 if (value.GetAsString(&check_portal_list)) 330 if (value.GetAsString(&check_portal_list))
331 listener_->CheckPortalListChanged(check_portal_list); 331 listener_->CheckPortalListChanged(check_portal_list);
332 } else { 332 } else {
333 VLOG(2) << "Ignored Manager Property: " << key; 333 VLOG(2) << "Ignored Manager Property: " << key;
334 } 334 }
335 } 335 }
336 336
337 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, 337 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type,
338 const base::ListValue& entries) { 338 const base::ListValue& entries) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 NET_LOG_DEBUG("Failed to get properties", 464 NET_LOG_DEBUG("Failed to get properties",
465 base::StringPrintf("%s: %d", path.c_str(), call_status)); 465 base::StringPrintf("%s: %d", path.c_str(), call_status));
466 return; 466 return;
467 } 467 }
468 listener_->UpdateManagedStateProperties(type, path, properties); 468 listener_->UpdateManagedStateProperties(type, path, properties);
469 // Update Favorite properties for networks in the Services list. 469 // Update Favorite properties for networks in the Services list.
470 if (type == ManagedState::MANAGED_TYPE_NETWORK) { 470 if (type == ManagedState::MANAGED_TYPE_NETWORK) {
471 // Only networks with a ProfilePath set are Favorites. 471 // Only networks with a ProfilePath set are Favorites.
472 std::string profile_path; 472 std::string profile_path;
473 properties.GetStringWithoutPathExpansion( 473 properties.GetStringWithoutPathExpansion(
474 flimflam::kProfileProperty, &profile_path); 474 shill::kProfileProperty, &profile_path);
475 if (!profile_path.empty()) { 475 if (!profile_path.empty()) {
476 listener_->UpdateManagedStateProperties( 476 listener_->UpdateManagedStateProperties(
477 ManagedState::MANAGED_TYPE_FAVORITE, path, properties); 477 ManagedState::MANAGED_TYPE_FAVORITE, path, properties);
478 } 478 }
479 } 479 }
480 // Request IPConfig parameters for networks. 480 // Request IPConfig parameters for networks.
481 if (type == ManagedState::MANAGED_TYPE_NETWORK && 481 if (type == ManagedState::MANAGED_TYPE_NETWORK &&
482 properties.HasKey(shill::kIPConfigProperty)) { 482 properties.HasKey(shill::kIPConfigProperty)) {
483 std::string ip_config_path; 483 std::string ip_config_path;
484 if (properties.GetString(shill::kIPConfigProperty, &ip_config_path)) { 484 if (properties.GetString(shill::kIPConfigProperty, &ip_config_path)) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 void ShillPropertyHandler::GetIPConfigCallback( 536 void ShillPropertyHandler::GetIPConfigCallback(
537 const std::string& service_path, 537 const std::string& service_path,
538 DBusMethodCallStatus call_status, 538 DBusMethodCallStatus call_status,
539 const base::DictionaryValue& properties) { 539 const base::DictionaryValue& properties) {
540 if (call_status != DBUS_METHOD_CALL_SUCCESS) { 540 if (call_status != DBUS_METHOD_CALL_SUCCESS) {
541 NET_LOG_ERROR("Failed to get IP Config properties", 541 NET_LOG_ERROR("Failed to get IP Config properties",
542 base::StringPrintf("%s: %d", 542 base::StringPrintf("%s: %d",
543 service_path.c_str(), call_status)); 543 service_path.c_str(), call_status));
544 return; 544 return;
545 } 545 }
546 UpdateIPConfigProperty(service_path, properties, 546 UpdateIPConfigProperty(service_path, properties, shill::kAddressProperty);
547 flimflam::kAddressProperty); 547 UpdateIPConfigProperty(service_path, properties, shill::kNameServersProperty);
548 UpdateIPConfigProperty(service_path, properties, 548 UpdateIPConfigProperty(service_path, properties, shill::kPrefixlenProperty);
549 flimflam::kNameServersProperty); 549 UpdateIPConfigProperty(service_path, properties, shill::kGatewayProperty);
550 UpdateIPConfigProperty(service_path, properties,
551 flimflam::kPrefixlenProperty);
552 UpdateIPConfigProperty(service_path, properties,
553 flimflam::kGatewayProperty);
554 UpdateIPConfigProperty(service_path, properties, 550 UpdateIPConfigProperty(service_path, properties,
555 shill::kWebProxyAutoDiscoveryUrlProperty); 551 shill::kWebProxyAutoDiscoveryUrlProperty);
556 } 552 }
557 553
558 void ShillPropertyHandler::UpdateIPConfigProperty( 554 void ShillPropertyHandler::UpdateIPConfigProperty(
559 const std::string& service_path, 555 const std::string& service_path,
560 const base::DictionaryValue& properties, 556 const base::DictionaryValue& properties,
561 const char* property) { 557 const char* property) {
562 const base::Value* value; 558 const base::Value* value;
563 if (!properties.GetWithoutPathExpansion(property, &value)) { 559 if (!properties.GetWithoutPathExpansion(property, &value)) {
564 LOG(ERROR) << "Failed to get IPConfig property: " << property 560 LOG(ERROR) << "Failed to get IPConfig property: " << property
565 << ", for: " << service_path; 561 << ", for: " << service_path;
566 return; 562 return;
567 } 563 }
568 listener_->UpdateNetworkServiceProperty( 564 listener_->UpdateNetworkServiceProperty(
569 service_path, NetworkState::IPConfigProperty(property), *value); 565 service_path, NetworkState::IPConfigProperty(property), *value);
570 } 566 }
571 567
572 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( 568 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback(
573 const std::string& path, 569 const std::string& path,
574 const std::string& key, 570 const std::string& key,
575 const base::Value& value) { 571 const base::Value& value) {
576 listener_->UpdateDeviceProperty(path, key, value); 572 listener_->UpdateDeviceProperty(path, key, value);
577 } 573 }
578 574
579 } // namespace internal 575 } // namespace internal
580 } // namespace chromeos 576 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/policy_util.cc ('k') | chromeos/network/shill_property_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698