Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/network_device_handler_impl.h" | 5 #include "chromeos/network/network_device_handler_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 if (!callback.is_null()) | 126 if (!callback.is_null()) |
| 127 callback.Run(); | 127 callback.Run(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void SetDevicePropertyInternal( | 130 void SetDevicePropertyInternal( |
| 131 const std::string& device_path, | 131 const std::string& device_path, |
| 132 const std::string& property_name, | 132 const std::string& property_name, |
| 133 const base::Value& value, | 133 const base::Value& value, |
| 134 const base::Closure& callback, | 134 const base::Closure& callback, |
| 135 const network_handler::ErrorCallback& error_callback) { | 135 const network_handler::ErrorCallback& error_callback) { |
| 136 NET_LOG(USER) << "Device.SetProperty: " << property_name; | 136 NET_LOG(USER) << "Device.SetProperty: " << property_name; |
|
Eric Caruso
2016/06/08 00:43:46
By which I mean this log line right here.
| |
| 137 DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty( | 137 DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty( |
| 138 dbus::ObjectPath(device_path), | 138 dbus::ObjectPath(device_path), |
| 139 property_name, | 139 property_name, |
| 140 value, | 140 value, |
| 141 callback, | 141 callback, |
| 142 base::Bind(&HandleShillCallFailure, device_path, error_callback)); | 142 base::Bind(&HandleShillCallFailure, device_path, error_callback)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Struct containing TDLS Operation parameters. | 145 // Struct containing TDLS Operation parameters. |
| 146 struct TDLSOperationParams { | 146 struct TDLSOperationParams { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 callback, | 425 callback, |
| 426 base::Bind(&HandleShillCallFailure, device_path, error_callback)); | 426 base::Bind(&HandleShillCallFailure, device_path, error_callback)); |
| 427 } | 427 } |
| 428 | 428 |
| 429 void NetworkDeviceHandlerImpl::SetCellularAllowRoaming( | 429 void NetworkDeviceHandlerImpl::SetCellularAllowRoaming( |
| 430 const bool allow_roaming) { | 430 const bool allow_roaming) { |
| 431 cellular_allow_roaming_ = allow_roaming; | 431 cellular_allow_roaming_ = allow_roaming; |
| 432 ApplyCellularAllowRoamingToShill(); | 432 ApplyCellularAllowRoamingToShill(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void NetworkDeviceHandlerImpl::SetMACAddressRandomizationEnabled( | |
| 436 const bool enabled) { | |
|
stevenjb
2016/06/08 00:35:27
Can you add a log entry, e.g.:
NET_LOG(USER) << "D
| |
| 437 mac_addr_randomization_ = enabled; | |
| 438 ApplyMACAddressRandomizationToShill(); | |
| 439 } | |
| 440 | |
| 435 void NetworkDeviceHandlerImpl::SetWifiTDLSEnabled( | 441 void NetworkDeviceHandlerImpl::SetWifiTDLSEnabled( |
| 436 const std::string& ip_or_mac_address, | 442 const std::string& ip_or_mac_address, |
| 437 bool enabled, | 443 bool enabled, |
| 438 const network_handler::StringResultCallback& callback, | 444 const network_handler::StringResultCallback& callback, |
| 439 const network_handler::ErrorCallback& error_callback) { | 445 const network_handler::ErrorCallback& error_callback) { |
| 440 const DeviceState* device_state = GetWifiDeviceState(error_callback); | 446 const DeviceState* device_state = GetWifiDeviceState(error_callback); |
| 441 if (!device_state) | 447 if (!device_state) |
| 442 return; | 448 return; |
| 443 | 449 |
| 444 TDLSOperationParams params; | 450 TDLSOperationParams params; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 ->GetShillDeviceClient() | 519 ->GetShillDeviceClient() |
| 514 ->RemoveAllWakeOnPacketConnections(dbus::ObjectPath(device_state->path()), | 520 ->RemoveAllWakeOnPacketConnections(dbus::ObjectPath(device_state->path()), |
| 515 callback, | 521 callback, |
| 516 base::Bind(&HandleShillCallFailure, | 522 base::Bind(&HandleShillCallFailure, |
| 517 device_state->path(), | 523 device_state->path(), |
| 518 error_callback)); | 524 error_callback)); |
| 519 } | 525 } |
| 520 | 526 |
| 521 void NetworkDeviceHandlerImpl::DeviceListChanged() { | 527 void NetworkDeviceHandlerImpl::DeviceListChanged() { |
| 522 ApplyCellularAllowRoamingToShill(); | 528 ApplyCellularAllowRoamingToShill(); |
| 529 ApplyMACAddressRandomizationToShill(); | |
| 523 } | 530 } |
| 524 | 531 |
| 525 NetworkDeviceHandlerImpl::NetworkDeviceHandlerImpl() | 532 NetworkDeviceHandlerImpl::NetworkDeviceHandlerImpl() |
| 526 : network_state_handler_(NULL), | 533 : network_state_handler_(NULL), |
| 527 cellular_allow_roaming_(false) {} | 534 cellular_allow_roaming_(false), |
| 535 mac_addr_randomization_(false) {} | |
| 528 | 536 |
| 529 void NetworkDeviceHandlerImpl::Init( | 537 void NetworkDeviceHandlerImpl::Init( |
| 530 NetworkStateHandler* network_state_handler) { | 538 NetworkStateHandler* network_state_handler) { |
| 531 DCHECK(network_state_handler); | 539 DCHECK(network_state_handler); |
| 532 network_state_handler_ = network_state_handler; | 540 network_state_handler_ = network_state_handler; |
| 533 network_state_handler_->AddObserver(this, FROM_HERE); | 541 network_state_handler_->AddObserver(this, FROM_HERE); |
| 534 } | 542 } |
| 535 | 543 |
| 536 void NetworkDeviceHandlerImpl::ApplyCellularAllowRoamingToShill() { | 544 void NetworkDeviceHandlerImpl::ApplyCellularAllowRoamingToShill() { |
| 537 NetworkStateHandler::DeviceStateList list; | 545 NetworkStateHandler::DeviceStateList list; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 557 continue; | 565 continue; |
| 558 | 566 |
| 559 SetDevicePropertyInternal(device_state->path(), | 567 SetDevicePropertyInternal(device_state->path(), |
| 560 shill::kCellularAllowRoamingProperty, | 568 shill::kCellularAllowRoamingProperty, |
| 561 base::FundamentalValue(new_device_value), | 569 base::FundamentalValue(new_device_value), |
| 562 base::Bind(&base::DoNothing), | 570 base::Bind(&base::DoNothing), |
| 563 network_handler::ErrorCallback()); | 571 network_handler::ErrorCallback()); |
| 564 } | 572 } |
| 565 } | 573 } |
| 566 | 574 |
| 575 void NetworkDeviceHandlerImpl::ApplyMACAddressRandomizationToShill() { | |
| 576 const DeviceState* device_state = | |
| 577 GetWifiDeviceState(network_handler::ErrorCallback()); | |
| 578 if (!device_state) | |
| 579 return; | |
| 580 | |
| 581 SetDevicePropertyInternal(device_state->path(), | |
| 582 shill::kMACAddressRandomizationProperty, | |
| 583 base::FundamentalValue(mac_addr_randomization_), | |
| 584 base::Bind(&base::DoNothing), | |
| 585 network_handler::ErrorCallback()); | |
| 586 } | |
| 587 | |
| 567 const DeviceState* NetworkDeviceHandlerImpl::GetWifiDeviceState( | 588 const DeviceState* NetworkDeviceHandlerImpl::GetWifiDeviceState( |
| 568 const network_handler::ErrorCallback& error_callback) { | 589 const network_handler::ErrorCallback& error_callback) { |
| 569 const DeviceState* device_state = | 590 const DeviceState* device_state = |
| 570 network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi()); | 591 network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi()); |
| 571 if (!device_state) { | 592 if (!device_state) { |
| 572 if (error_callback.is_null()) | 593 if (error_callback.is_null()) |
| 573 return NULL; | 594 return NULL; |
| 574 std::unique_ptr<base::DictionaryValue> error_data( | 595 std::unique_ptr<base::DictionaryValue> error_data( |
| 575 new base::DictionaryValue); | 596 new base::DictionaryValue); |
| 576 error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing); | 597 error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing); |
| 577 error_callback.Run(kErrorDeviceMissing, std::move(error_data)); | 598 error_callback.Run(kErrorDeviceMissing, std::move(error_data)); |
| 578 return NULL; | 599 return NULL; |
| 579 } | 600 } |
| 580 | 601 |
| 581 return device_state; | 602 return device_state; |
| 582 } | 603 } |
| 583 | 604 |
| 584 } // namespace chromeos | 605 } // namespace chromeos |
| OLD | NEW |