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 "chromeos/network/shill_property_handler.h" | 5 #include "chromeos/network/shill_property_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, | 359 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, |
360 const base::ListValue& entries) { | 360 const base::ListValue& entries) { |
361 std::set<std::string>& requested_updates = requested_updates_[type]; | 361 std::set<std::string>& requested_updates = requested_updates_[type]; |
362 std::set<std::string> new_requested_updates; | 362 std::set<std::string> new_requested_updates; |
363 NET_LOG(DEBUG) << "UpdateProperties: " << ManagedState::TypeToString(type) | 363 NET_LOG(DEBUG) << "UpdateProperties: " << ManagedState::TypeToString(type) |
364 << ": " << entries.GetSize(); | 364 << ": " << entries.GetSize(); |
365 for (base::ListValue::const_iterator iter = entries.begin(); | 365 for (base::ListValue::const_iterator iter = entries.begin(); |
366 iter != entries.end(); ++iter) { | 366 iter != entries.end(); ++iter) { |
367 std::string path; | 367 std::string path; |
368 (*iter)->GetAsString(&path); | 368 iter->GetAsString(&path); |
369 if (path.empty()) | 369 if (path.empty()) |
370 continue; | 370 continue; |
371 | 371 |
372 // We add a special case for devices here to work around an issue in shill | 372 // We add a special case for devices here to work around an issue in shill |
373 // that prevents it from sending property changed signals for cellular | 373 // that prevents it from sending property changed signals for cellular |
374 // devices (see crbug.com/321854). | 374 // devices (see crbug.com/321854). |
375 if (type == ManagedState::MANAGED_TYPE_DEVICE || | 375 if (type == ManagedState::MANAGED_TYPE_DEVICE || |
376 requested_updates.find(path) == requested_updates.end()) { | 376 requested_updates.find(path) == requested_updates.end()) { |
377 RequestProperties(type, path); | 377 RequestProperties(type, path); |
378 } | 378 } |
379 new_requested_updates.insert(path); | 379 new_requested_updates.insert(path); |
380 } | 380 } |
381 requested_updates.swap(new_requested_updates); | 381 requested_updates.swap(new_requested_updates); |
382 } | 382 } |
383 | 383 |
384 void ShillPropertyHandler::UpdateObserved(ManagedState::ManagedType type, | 384 void ShillPropertyHandler::UpdateObserved(ManagedState::ManagedType type, |
385 const base::ListValue& entries) { | 385 const base::ListValue& entries) { |
386 ShillPropertyObserverMap& observer_map = | 386 ShillPropertyObserverMap& observer_map = |
387 (type == ManagedState::MANAGED_TYPE_NETWORK) ? observed_networks_ | 387 (type == ManagedState::MANAGED_TYPE_NETWORK) ? observed_networks_ |
388 : observed_devices_; | 388 : observed_devices_; |
389 ShillPropertyObserverMap new_observed; | 389 ShillPropertyObserverMap new_observed; |
390 for (const auto& entry : entries) { | 390 for (const auto& entry : entries) { |
391 std::string path; | 391 std::string path; |
392 entry->GetAsString(&path); | 392 entry.GetAsString(&path); |
393 if (path.empty()) | 393 if (path.empty()) |
394 continue; | 394 continue; |
395 auto iter = observer_map.find(path); | 395 auto iter = observer_map.find(path); |
396 std::unique_ptr<ShillPropertyObserver> observer; | 396 std::unique_ptr<ShillPropertyObserver> observer; |
397 if (iter != observer_map.end()) { | 397 if (iter != observer_map.end()) { |
398 observer = std::move(iter->second); | 398 observer = std::move(iter->second); |
399 } else { | 399 } else { |
400 // Create an observer for future updates. | 400 // Create an observer for future updates. |
401 observer = base::MakeUnique<ShillPropertyObserver>( | 401 observer = base::MakeUnique<ShillPropertyObserver>( |
402 type, path, base::Bind(&ShillPropertyHandler::PropertyChangedCallback, | 402 type, path, base::Bind(&ShillPropertyHandler::PropertyChangedCallback, |
(...skipping 12 matching lines...) Expand all Loading... |
415 observer_map.swap(new_observed); | 415 observer_map.swap(new_observed); |
416 } | 416 } |
417 | 417 |
418 void ShillPropertyHandler::UpdateAvailableTechnologies( | 418 void ShillPropertyHandler::UpdateAvailableTechnologies( |
419 const base::ListValue& technologies) { | 419 const base::ListValue& technologies) { |
420 NET_LOG(EVENT) << "AvailableTechnologies:" << technologies; | 420 NET_LOG(EVENT) << "AvailableTechnologies:" << technologies; |
421 available_technologies_.clear(); | 421 available_technologies_.clear(); |
422 for (base::ListValue::const_iterator iter = technologies.begin(); | 422 for (base::ListValue::const_iterator iter = technologies.begin(); |
423 iter != technologies.end(); ++iter) { | 423 iter != technologies.end(); ++iter) { |
424 std::string technology; | 424 std::string technology; |
425 (*iter)->GetAsString(&technology); | 425 iter->GetAsString(&technology); |
426 DCHECK(!technology.empty()); | 426 DCHECK(!technology.empty()); |
427 available_technologies_.insert(technology); | 427 available_technologies_.insert(technology); |
428 } | 428 } |
429 listener_->TechnologyListChanged(); | 429 listener_->TechnologyListChanged(); |
430 } | 430 } |
431 | 431 |
432 void ShillPropertyHandler::UpdateEnabledTechnologies( | 432 void ShillPropertyHandler::UpdateEnabledTechnologies( |
433 const base::ListValue& technologies) { | 433 const base::ListValue& technologies) { |
434 NET_LOG(EVENT) << "EnabledTechnologies:" << technologies; | 434 NET_LOG(EVENT) << "EnabledTechnologies:" << technologies; |
435 enabled_technologies_.clear(); | 435 enabled_technologies_.clear(); |
436 for (base::ListValue::const_iterator iter = technologies.begin(); | 436 for (base::ListValue::const_iterator iter = technologies.begin(); |
437 iter != technologies.end(); ++iter) { | 437 iter != technologies.end(); ++iter) { |
438 std::string technology; | 438 std::string technology; |
439 (*iter)->GetAsString(&technology); | 439 iter->GetAsString(&technology); |
440 DCHECK(!technology.empty()); | 440 DCHECK(!technology.empty()); |
441 enabled_technologies_.insert(technology); | 441 enabled_technologies_.insert(technology); |
442 enabling_technologies_.erase(technology); | 442 enabling_technologies_.erase(technology); |
443 } | 443 } |
444 listener_->TechnologyListChanged(); | 444 listener_->TechnologyListChanged(); |
445 } | 445 } |
446 | 446 |
447 void ShillPropertyHandler::UpdateUninitializedTechnologies( | 447 void ShillPropertyHandler::UpdateUninitializedTechnologies( |
448 const base::ListValue& technologies) { | 448 const base::ListValue& technologies) { |
449 NET_LOG(EVENT) << "UninitializedTechnologies:" << technologies; | 449 NET_LOG(EVENT) << "UninitializedTechnologies:" << technologies; |
450 uninitialized_technologies_.clear(); | 450 uninitialized_technologies_.clear(); |
451 for (base::ListValue::const_iterator iter = technologies.begin(); | 451 for (base::ListValue::const_iterator iter = technologies.begin(); |
452 iter != technologies.end(); ++iter) { | 452 iter != technologies.end(); ++iter) { |
453 std::string technology; | 453 std::string technology; |
454 (*iter)->GetAsString(&technology); | 454 iter->GetAsString(&technology); |
455 DCHECK(!technology.empty()); | 455 DCHECK(!technology.empty()); |
456 uninitialized_technologies_.insert(technology); | 456 uninitialized_technologies_.insert(technology); |
457 } | 457 } |
458 listener_->TechnologyListChanged(); | 458 listener_->TechnologyListChanged(); |
459 } | 459 } |
460 | 460 |
461 void ShillPropertyHandler::EnableTechnologyFailed( | 461 void ShillPropertyHandler::EnableTechnologyFailed( |
462 const std::string& technology, | 462 const std::string& technology, |
463 const network_handler::ErrorCallback& error_callback, | 463 const network_handler::ErrorCallback& error_callback, |
464 const std::string& dbus_error_name, | 464 const std::string& dbus_error_name, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 542 |
543 void ShillPropertyHandler::RequestIPConfigsList( | 543 void ShillPropertyHandler::RequestIPConfigsList( |
544 ManagedState::ManagedType type, | 544 ManagedState::ManagedType type, |
545 const std::string& path, | 545 const std::string& path, |
546 const base::Value& ip_config_list_value) { | 546 const base::Value& ip_config_list_value) { |
547 const base::ListValue* ip_configs; | 547 const base::ListValue* ip_configs; |
548 if (!ip_config_list_value.GetAsList(&ip_configs)) | 548 if (!ip_config_list_value.GetAsList(&ip_configs)) |
549 return; | 549 return; |
550 for (base::ListValue::const_iterator iter = ip_configs->begin(); | 550 for (base::ListValue::const_iterator iter = ip_configs->begin(); |
551 iter != ip_configs->end(); ++iter) { | 551 iter != ip_configs->end(); ++iter) { |
552 RequestIPConfig(type, path, **iter); | 552 RequestIPConfig(type, path, *iter); |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 void ShillPropertyHandler::GetIPConfigCallback( | 556 void ShillPropertyHandler::GetIPConfigCallback( |
557 ManagedState::ManagedType type, | 557 ManagedState::ManagedType type, |
558 const std::string& path, | 558 const std::string& path, |
559 const std::string& ip_config_path, | 559 const std::string& ip_config_path, |
560 DBusMethodCallStatus call_status, | 560 DBusMethodCallStatus call_status, |
561 const base::DictionaryValue& properties) { | 561 const base::DictionaryValue& properties) { |
562 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 562 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
563 // IP Config properties not availabe. Shill will emit a property change | 563 // IP Config properties not availabe. Shill will emit a property change |
564 // when they are. | 564 // when they are. |
565 NET_LOG(EVENT) << "Failed to get IP Config properties: " << ip_config_path | 565 NET_LOG(EVENT) << "Failed to get IP Config properties: " << ip_config_path |
566 << ": " << call_status << ", For: " << path; | 566 << ": " << call_status << ", For: " << path; |
567 return; | 567 return; |
568 } | 568 } |
569 NET_LOG(EVENT) << "IP Config properties received: " << path; | 569 NET_LOG(EVENT) << "IP Config properties received: " << path; |
570 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); | 570 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); |
571 } | 571 } |
572 | 572 |
573 } // namespace internal | 573 } // namespace internal |
574 } // namespace chromeos | 574 } // namespace chromeos |
OLD | NEW |