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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 error_callback.Run(kErrorDeviceMissing, error_data.Pass()); | 430 error_callback.Run(kErrorDeviceMissing, error_data.Pass()); |
| 431 return; | 431 return; |
| 432 } | 432 } |
| 433 TDLSOperationParams params; | 433 TDLSOperationParams params; |
| 434 params.operation = shill::kTDLSStatusOperation; | 434 params.operation = shill::kTDLSStatusOperation; |
| 435 params.ip_or_mac_address = ip_or_mac_address; | 435 params.ip_or_mac_address = ip_or_mac_address; |
| 436 CallPerformTDLSOperation( | 436 CallPerformTDLSOperation( |
| 437 device_state->path(), params, callback, error_callback); | 437 device_state->path(), params, callback, error_callback); |
| 438 } | 438 } |
| 439 | 439 |
| 440 void NetworkDeviceHandlerImpl::AddWifiWakeOnPacketConnection( | |
| 441 const net::IPEndPoint& ip_endpoint, | |
| 442 const base::Closure& callback, | |
| 443 const network_handler::ErrorCallback& error_callback) { | |
| 444 const DeviceState* device_state = | |
| 445 network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi()); | |
| 446 if (!device_state) { | |
| 447 if (error_callback.is_null()) | |
| 448 return; | |
| 449 scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue); | |
| 450 error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing); | |
| 451 error_callback.Run(kErrorDeviceMissing, error_data.Pass()); | |
| 452 return; | |
| 453 } | |
|
stevenjb
2014/11/13 22:20:17
This entire clause should be moved to a file local
Chirantan Ekbote
2014/11/14 02:47:43
Done.
| |
| 454 | |
| 455 DBusThreadManager::Get()->GetShillDeviceClient()->AddWakeOnPacketConnection( | |
| 456 dbus::ObjectPath(device_state->path()), | |
| 457 ip_endpoint, | |
| 458 callback, | |
| 459 base::Bind(&HandleShillCallFailure, | |
| 460 device_state->path(), | |
| 461 error_callback)); | |
| 462 } | |
| 463 | |
| 464 void NetworkDeviceHandlerImpl::RemoveWifiWakeOnPacketConnection( | |
| 465 const net::IPEndPoint& ip_endpoint, | |
| 466 const base::Closure& callback, | |
| 467 const network_handler::ErrorCallback& error_callback) { | |
| 468 const DeviceState* device_state = | |
| 469 network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi()); | |
| 470 if (!device_state) { | |
| 471 if (error_callback.is_null()) | |
| 472 return; | |
| 473 scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue); | |
| 474 error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing); | |
| 475 error_callback.Run(kErrorDeviceMissing, error_data.Pass()); | |
| 476 return; | |
| 477 } | |
| 478 | |
| 479 DBusThreadManager::Get() | |
| 480 ->GetShillDeviceClient() | |
| 481 ->RemoveWakeOnPacketConnection(dbus::ObjectPath(device_state->path()), | |
| 482 ip_endpoint, | |
| 483 callback, | |
| 484 base::Bind(&HandleShillCallFailure, | |
| 485 device_state->path(), | |
| 486 error_callback)); | |
| 487 } | |
| 488 | |
| 489 void NetworkDeviceHandlerImpl::RemoveAllWifiWakeOnPacketConnections( | |
| 490 const base::Closure& callback, | |
| 491 const network_handler::ErrorCallback& error_callback) { | |
| 492 const DeviceState* device_state = | |
| 493 network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi()); | |
| 494 if (!device_state) { | |
| 495 if (error_callback.is_null()) | |
| 496 return; | |
| 497 scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue); | |
| 498 error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing); | |
| 499 error_callback.Run(kErrorDeviceMissing, error_data.Pass()); | |
| 500 return; | |
| 501 } | |
| 502 | |
| 503 DBusThreadManager::Get() | |
| 504 ->GetShillDeviceClient() | |
| 505 ->RemoveAllWakeOnPacketConnections(dbus::ObjectPath(device_state->path()), | |
| 506 callback, | |
| 507 base::Bind(&HandleShillCallFailure, | |
| 508 device_state->path(), | |
| 509 error_callback)); | |
| 510 } | |
| 511 | |
| 440 void NetworkDeviceHandlerImpl::DeviceListChanged() { | 512 void NetworkDeviceHandlerImpl::DeviceListChanged() { |
| 441 ApplyCellularAllowRoamingToShill(); | 513 ApplyCellularAllowRoamingToShill(); |
| 442 } | 514 } |
| 443 | 515 |
| 444 NetworkDeviceHandlerImpl::NetworkDeviceHandlerImpl() | 516 NetworkDeviceHandlerImpl::NetworkDeviceHandlerImpl() |
| 445 : network_state_handler_(NULL), | 517 : network_state_handler_(NULL), |
| 446 cellular_allow_roaming_(false) {} | 518 cellular_allow_roaming_(false) {} |
| 447 | 519 |
| 448 void NetworkDeviceHandlerImpl::Init( | 520 void NetworkDeviceHandlerImpl::Init( |
| 449 NetworkStateHandler* network_state_handler) { | 521 NetworkStateHandler* network_state_handler) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 477 | 549 |
| 478 SetDevicePropertyInternal(device_state->path(), | 550 SetDevicePropertyInternal(device_state->path(), |
| 479 shill::kCellularAllowRoamingProperty, | 551 shill::kCellularAllowRoamingProperty, |
| 480 base::FundamentalValue(new_device_value), | 552 base::FundamentalValue(new_device_value), |
| 481 base::Bind(&base::DoNothing), | 553 base::Bind(&base::DoNothing), |
| 482 network_handler::ErrorCallback()); | 554 network_handler::ErrorCallback()); |
| 483 } | 555 } |
| 484 } | 556 } |
| 485 | 557 |
| 486 } // namespace chromeos | 558 } // namespace chromeos |
| OLD | NEW |