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

Unified Diff: chromeos/network/network_device_handler_impl.cc

Issue 722043004: Clean up wake on wifi handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/network_device_handler_impl.h ('k') | components/gcm_driver/gcm_driver_desktop.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_device_handler_impl.cc
diff --git a/chromeos/network/network_device_handler_impl.cc b/chromeos/network/network_device_handler_impl.cc
index f7f285599a7d627db0a42240cad53376612842ce..fb66d903088bb97bf7673351704284fb0240c754 100644
--- a/chromeos/network/network_device_handler_impl.cc
+++ b/chromeos/network/network_device_handler_impl.cc
@@ -399,16 +399,10 @@ void NetworkDeviceHandlerImpl::SetWifiTDLSEnabled(
bool enabled,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {
- const DeviceState* device_state =
- network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi());
- if (!device_state) {
- if (error_callback.is_null())
- return;
- scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue);
- error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing);
- error_callback.Run(kErrorDeviceMissing, error_data.Pass());
+ const DeviceState* device_state = GetWifiDeviceState(error_callback);
+ if (!device_state)
return;
- }
+
TDLSOperationParams params;
params.operation = enabled ? shill::kTDLSSetupOperation
: shill::kTDLSTeardownOperation;
@@ -421,16 +415,10 @@ void NetworkDeviceHandlerImpl::GetWifiTDLSStatus(
const std::string& ip_or_mac_address,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {
- const DeviceState* device_state =
- network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi());
- if (!device_state) {
- if (error_callback.is_null())
- return;
- scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue);
- error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing);
- error_callback.Run(kErrorDeviceMissing, error_data.Pass());
+ const DeviceState* device_state = GetWifiDeviceState(error_callback);
+ if (!device_state)
return;
- }
+
TDLSOperationParams params;
params.operation = shill::kTDLSStatusOperation;
params.ip_or_mac_address = ip_or_mac_address;
@@ -438,6 +426,57 @@ void NetworkDeviceHandlerImpl::GetWifiTDLSStatus(
device_state->path(), params, callback, error_callback);
}
+void NetworkDeviceHandlerImpl::AddWifiWakeOnPacketConnection(
+ const net::IPEndPoint& ip_endpoint,
+ const base::Closure& callback,
+ const network_handler::ErrorCallback& error_callback) {
+ const DeviceState* device_state = GetWifiDeviceState(error_callback);
+ if (!device_state)
+ return;
+
+ DBusThreadManager::Get()->GetShillDeviceClient()->AddWakeOnPacketConnection(
+ dbus::ObjectPath(device_state->path()),
+ ip_endpoint,
+ callback,
+ base::Bind(&HandleShillCallFailure,
+ device_state->path(),
+ error_callback));
+}
+
+void NetworkDeviceHandlerImpl::RemoveWifiWakeOnPacketConnection(
+ const net::IPEndPoint& ip_endpoint,
+ const base::Closure& callback,
+ const network_handler::ErrorCallback& error_callback) {
+ const DeviceState* device_state = GetWifiDeviceState(error_callback);
+ if (!device_state)
+ return;
+
+ DBusThreadManager::Get()
+ ->GetShillDeviceClient()
+ ->RemoveWakeOnPacketConnection(dbus::ObjectPath(device_state->path()),
+ ip_endpoint,
+ callback,
+ base::Bind(&HandleShillCallFailure,
+ device_state->path(),
+ error_callback));
+}
+
+void NetworkDeviceHandlerImpl::RemoveAllWifiWakeOnPacketConnections(
+ const base::Closure& callback,
+ const network_handler::ErrorCallback& error_callback) {
+ const DeviceState* device_state = GetWifiDeviceState(error_callback);
+ if (!device_state)
+ return;
+
+ DBusThreadManager::Get()
+ ->GetShillDeviceClient()
+ ->RemoveAllWakeOnPacketConnections(dbus::ObjectPath(device_state->path()),
+ callback,
+ base::Bind(&HandleShillCallFailure,
+ device_state->path(),
+ error_callback));
+}
+
void NetworkDeviceHandlerImpl::DeviceListChanged() {
ApplyCellularAllowRoamingToShill();
}
@@ -484,4 +523,20 @@ void NetworkDeviceHandlerImpl::ApplyCellularAllowRoamingToShill() {
}
}
+const DeviceState* NetworkDeviceHandlerImpl::GetWifiDeviceState(
+ const network_handler::ErrorCallback& error_callback) {
+ const DeviceState* device_state =
+ network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi());
+ if (!device_state) {
+ if (error_callback.is_null())
+ return NULL;
+ scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue);
+ error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing);
+ error_callback.Run(kErrorDeviceMissing, error_data.Pass());
+ return NULL;
+ }
+
+ return device_state;
+}
+
} // namespace chromeos
« no previous file with comments | « chromeos/network/network_device_handler_impl.h ('k') | components/gcm_driver/gcm_driver_desktop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698