| 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 "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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 bool ShillPropertyHandler::TechnologyAvailable( | 124 bool ShillPropertyHandler::TechnologyAvailable( |
| 125 const std::string& technology) const { | 125 const std::string& technology) const { |
| 126 return available_technologies_.count(technology) != 0; | 126 return available_technologies_.count(technology) != 0; |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool ShillPropertyHandler::TechnologyEnabled( | 129 bool ShillPropertyHandler::TechnologyEnabled( |
| 130 const std::string& technology) const { | 130 const std::string& technology) const { |
| 131 return enabled_technologies_.count(technology) != 0; | 131 return enabled_technologies_.count(technology) != 0; |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool ShillPropertyHandler::TechnologyEnabling( |
| 135 const std::string& technology) const { |
| 136 return enabling_technologies_.count(technology) != 0; |
| 137 } |
| 138 |
| 134 bool ShillPropertyHandler::TechnologyUninitialized( | 139 bool ShillPropertyHandler::TechnologyUninitialized( |
| 135 const std::string& technology) const { | 140 const std::string& technology) const { |
| 136 return uninitialized_technologies_.count(technology) != 0; | 141 return uninitialized_technologies_.count(technology) != 0; |
| 137 } | 142 } |
| 138 | 143 |
| 139 void ShillPropertyHandler::SetTechnologyEnabled( | 144 void ShillPropertyHandler::SetTechnologyEnabled( |
| 140 const std::string& technology, | 145 const std::string& technology, |
| 141 bool enabled, | 146 bool enabled, |
| 142 const network_handler::ErrorCallback& error_callback) { | 147 const network_handler::ErrorCallback& error_callback) { |
| 143 if (enabled) { | 148 if (enabled) { |
| 149 enabling_technologies_.insert(technology); |
| 144 shill_manager_->EnableTechnology( | 150 shill_manager_->EnableTechnology( |
| 145 technology, | 151 technology, |
| 146 base::Bind(&base::DoNothing), | 152 base::Bind(&base::DoNothing), |
| 147 base::Bind(&network_handler::ShillErrorCallbackFunction, | 153 base::Bind(&ShillPropertyHandler::EnableTechnologyFailed, |
| 148 kLogModule, technology, error_callback)); | 154 AsWeakPtr(), technology, error_callback)); |
| 149 } else { | 155 } else { |
| 156 // Imediately clear locally from enabled and enabling lists. |
| 157 enabled_technologies_.erase(technology); |
| 158 enabling_technologies_.erase(technology); |
| 150 shill_manager_->DisableTechnology( | 159 shill_manager_->DisableTechnology( |
| 151 technology, | 160 technology, |
| 152 base::Bind(&base::DoNothing), | 161 base::Bind(&base::DoNothing), |
| 153 base::Bind(&network_handler::ShillErrorCallbackFunction, | 162 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 154 kLogModule, technology, error_callback)); | 163 kLogModule, technology, error_callback)); |
| 155 } | 164 } |
| 156 } | 165 } |
| 157 | 166 |
| 158 void ShillPropertyHandler::RequestScan() const { | 167 void ShillPropertyHandler::RequestScan() const { |
| 159 shill_manager_->RequestScan( | 168 shill_manager_->RequestScan( |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 enabled_technologies_.clear(); | 351 enabled_technologies_.clear(); |
| 343 network_event_log::AddEntry( | 352 network_event_log::AddEntry( |
| 344 kLogModule, "EnabledTechnologiesChanged", | 353 kLogModule, "EnabledTechnologiesChanged", |
| 345 base::StringPrintf("Size: %"PRIuS, technologies.GetSize())); | 354 base::StringPrintf("Size: %"PRIuS, technologies.GetSize())); |
| 346 for (base::ListValue::const_iterator iter = technologies.begin(); | 355 for (base::ListValue::const_iterator iter = technologies.begin(); |
| 347 iter != technologies.end(); ++iter) { | 356 iter != technologies.end(); ++iter) { |
| 348 std::string technology; | 357 std::string technology; |
| 349 (*iter)->GetAsString(&technology); | 358 (*iter)->GetAsString(&technology); |
| 350 DCHECK(!technology.empty()); | 359 DCHECK(!technology.empty()); |
| 351 enabled_technologies_.insert(technology); | 360 enabled_technologies_.insert(technology); |
| 361 enabling_technologies_.erase(technology); |
| 352 } | 362 } |
| 353 } | 363 } |
| 354 | 364 |
| 355 void ShillPropertyHandler::UpdateUninitializedTechnologies( | 365 void ShillPropertyHandler::UpdateUninitializedTechnologies( |
| 356 const base::ListValue& technologies) { | 366 const base::ListValue& technologies) { |
| 357 uninitialized_technologies_.clear(); | 367 uninitialized_technologies_.clear(); |
| 358 network_event_log::AddEntry( | 368 network_event_log::AddEntry( |
| 359 kLogModule, "UninitializedTechnologiesChanged", | 369 kLogModule, "UninitializedTechnologiesChanged", |
| 360 base::StringPrintf("Size: %"PRIuS, technologies.GetSize())); | 370 base::StringPrintf("Size: %"PRIuS, technologies.GetSize())); |
| 361 for (base::ListValue::const_iterator iter = technologies.begin(); | 371 for (base::ListValue::const_iterator iter = technologies.begin(); |
| 362 iter != technologies.end(); ++iter) { | 372 iter != technologies.end(); ++iter) { |
| 363 std::string technology; | 373 std::string technology; |
| 364 (*iter)->GetAsString(&technology); | 374 (*iter)->GetAsString(&technology); |
| 365 DCHECK(!technology.empty()); | 375 DCHECK(!technology.empty()); |
| 366 uninitialized_technologies_.insert(technology); | 376 uninitialized_technologies_.insert(technology); |
| 367 } | 377 } |
| 368 } | 378 } |
| 369 | 379 |
| 380 void ShillPropertyHandler::EnableTechnologyFailed( |
| 381 const std::string& technology, |
| 382 const network_handler::ErrorCallback& error_callback, |
| 383 const std::string& error_name, |
| 384 const std::string& error_message) { |
| 385 enabling_technologies_.erase(technology); |
| 386 network_handler::ShillErrorCallbackFunction( |
| 387 kLogModule, technology, error_callback, error_name, error_message); |
| 388 } |
| 389 |
| 370 void ShillPropertyHandler::GetPropertiesCallback( | 390 void ShillPropertyHandler::GetPropertiesCallback( |
| 371 ManagedState::ManagedType type, | 391 ManagedState::ManagedType type, |
| 372 const std::string& path, | 392 const std::string& path, |
| 373 DBusMethodCallStatus call_status, | 393 DBusMethodCallStatus call_status, |
| 374 const base::DictionaryValue& properties) { | 394 const base::DictionaryValue& properties) { |
| 375 VLOG(2) << "GetPropertiesCallback: " << type << " : " << path; | 395 VLOG(2) << "GetPropertiesCallback: " << type << " : " << path; |
| 376 pending_updates_[type].erase(path); | 396 pending_updates_[type].erase(path); |
| 377 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 397 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
| 378 LOG(ERROR) << "Failed to get properties for: " << path | 398 LOG(ERROR) << "Failed to get properties for: " << path |
| 379 << ": " << call_status; | 399 << ": " << call_status; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 483 |
| 464 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( | 484 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( |
| 465 const std::string& path, | 485 const std::string& path, |
| 466 const std::string& key, | 486 const std::string& key, |
| 467 const base::Value& value) { | 487 const base::Value& value) { |
| 468 listener_->UpdateDeviceProperty(path, key, value); | 488 listener_->UpdateDeviceProperty(path, key, value); |
| 469 } | 489 } |
| 470 | 490 |
| 471 } // namespace internal | 491 } // namespace internal |
| 472 } // namespace chromeos | 492 } // namespace chromeos |
| OLD | NEW |