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.h" | 5 #include "chromeos/network/network_device_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/shill_device_client.h" | 10 #include "chromeos/dbus/shill_device_client.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 base::Bind(&IPConfigRefreshCallback, ipconfig_path)); | 92 base::Bind(&IPConfigRefreshCallback, ipconfig_path)); |
93 } | 93 } |
94 // It is safe to invoke |callback| here instead of waiting for the | 94 // It is safe to invoke |callback| here instead of waiting for the |
95 // IPConfig.Refresh callbacks to complete because the Refresh DBus calls will | 95 // IPConfig.Refresh callbacks to complete because the Refresh DBus calls will |
96 // be executed in order and thus before any further DBus requests that | 96 // be executed in order and thus before any further DBus requests that |
97 // |callback| may issue. | 97 // |callback| may issue. |
98 if (!callback.is_null()) | 98 if (!callback.is_null()) |
99 callback.Run(); | 99 callback.Run(); |
100 } | 100 } |
101 | 101 |
| 102 void ProposeScanCallback( |
| 103 const std::string& device_path, |
| 104 const base::Closure& callback, |
| 105 const network_handler::ErrorCallback& error_callback, |
| 106 DBusMethodCallStatus call_status) { |
| 107 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
| 108 NET_LOG_ERROR( |
| 109 base::StringPrintf("Device.ProposeScan failed: %d", call_status), |
| 110 device_path); |
| 111 network_handler::ShillErrorCallbackFunction( |
| 112 "Device.ProposeScan Failed", |
| 113 device_path, |
| 114 error_callback, |
| 115 base::StringPrintf("DBus call failed: %d", call_status), ""); |
| 116 return; |
| 117 } |
| 118 NET_LOG_EVENT("Device.ProposeScan succeeded.", device_path); |
| 119 if (!callback.is_null()) |
| 120 callback.Run(); |
| 121 } |
| 122 |
102 } // namespace | 123 } // namespace |
103 | 124 |
104 const char NetworkDeviceHandler::kErrorFailure[] = "failure"; | 125 const char NetworkDeviceHandler::kErrorFailure[] = "failure"; |
105 const char NetworkDeviceHandler::kErrorIncorrectPin[] = "incorrect-pin"; | 126 const char NetworkDeviceHandler::kErrorIncorrectPin[] = "incorrect-pin"; |
106 const char NetworkDeviceHandler::kErrorNotSupported[] = "not-supported"; | 127 const char NetworkDeviceHandler::kErrorNotSupported[] = "not-supported"; |
107 const char NetworkDeviceHandler::kErrorPinBlocked[] = "pin-blocked"; | 128 const char NetworkDeviceHandler::kErrorPinBlocked[] = "pin-blocked"; |
108 const char NetworkDeviceHandler::kErrorPinRequired[] = "pin-required"; | 129 const char NetworkDeviceHandler::kErrorPinRequired[] = "pin-required"; |
109 const char NetworkDeviceHandler::kErrorUnknown[] = "unknown"; | 130 const char NetworkDeviceHandler::kErrorUnknown[] = "unknown"; |
110 | 131 |
111 NetworkDeviceHandler::NetworkDeviceHandler() { | 132 NetworkDeviceHandler::NetworkDeviceHandler() { |
(...skipping 15 matching lines...) Expand all Loading... |
127 void NetworkDeviceHandler::RequestRefreshIPConfigs( | 148 void NetworkDeviceHandler::RequestRefreshIPConfigs( |
128 const std::string& device_path, | 149 const std::string& device_path, |
129 const base::Closure& callback, | 150 const base::Closure& callback, |
130 const network_handler::ErrorCallback& error_callback) { | 151 const network_handler::ErrorCallback& error_callback) { |
131 GetDeviceProperties(device_path, | 152 GetDeviceProperties(device_path, |
132 base::Bind(&RefreshIPConfigsCallback, | 153 base::Bind(&RefreshIPConfigsCallback, |
133 callback, error_callback), | 154 callback, error_callback), |
134 error_callback); | 155 error_callback); |
135 } | 156 } |
136 | 157 |
| 158 void NetworkDeviceHandler::ProposeScan( |
| 159 const std::string& device_path, |
| 160 const base::Closure& callback, |
| 161 const network_handler::ErrorCallback& error_callback) { |
| 162 DBusThreadManager::Get()->GetShillDeviceClient()->ProposeScan( |
| 163 dbus::ObjectPath(device_path), |
| 164 base::Bind(&ProposeScanCallback, device_path, callback, error_callback)); |
| 165 } |
| 166 |
137 void NetworkDeviceHandler::SetCarrier( | 167 void NetworkDeviceHandler::SetCarrier( |
138 const std::string& device_path, | 168 const std::string& device_path, |
139 const std::string& carrier, | 169 const std::string& carrier, |
140 const base::Closure& callback, | 170 const base::Closure& callback, |
141 const network_handler::ErrorCallback& error_callback) { | 171 const network_handler::ErrorCallback& error_callback) { |
142 DBusThreadManager::Get()->GetShillDeviceClient()->SetCarrier( | 172 DBusThreadManager::Get()->GetShillDeviceClient()->SetCarrier( |
143 dbus::ObjectPath(device_path), | 173 dbus::ObjectPath(device_path), |
144 carrier, | 174 carrier, |
145 callback, | 175 callback, |
146 base::Bind(&HandleShillCallFailure, device_path, error_callback)); | 176 base::Bind(&HandleShillCallFailure, device_path, error_callback)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 void NetworkDeviceHandler::HandleShillCallFailureForTest( | 233 void NetworkDeviceHandler::HandleShillCallFailureForTest( |
204 const std::string& device_path, | 234 const std::string& device_path, |
205 const network_handler::ErrorCallback& error_callback, | 235 const network_handler::ErrorCallback& error_callback, |
206 const std::string& shill_error_name, | 236 const std::string& shill_error_name, |
207 const std::string& shill_error_message) { | 237 const std::string& shill_error_message) { |
208 HandleShillCallFailure( | 238 HandleShillCallFailure( |
209 device_path, error_callback, shill_error_name, shill_error_message); | 239 device_path, error_callback, shill_error_name, shill_error_message); |
210 } | 240 } |
211 | 241 |
212 } // namespace chromeos | 242 } // namespace chromeos |
OLD | NEW |