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

Side by Side Diff: chromeos/dbus/shill_device_client.cc

Issue 722043004: Clean up wake on wifi handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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/dbus/shill_device_client.h" 5 #include "chromeos/dbus/shill_device_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chromeos/dbus/shill_property_changed_observer.h" 11 #include "chromeos/dbus/shill_property_changed_observer.h"
12 #include "dbus/bus.h" 12 #include "dbus/bus.h"
13 #include "dbus/message.h" 13 #include "dbus/message.h"
14 #include "dbus/object_path.h" 14 #include "dbus/object_path.h"
15 #include "dbus/object_proxy.h" 15 #include "dbus/object_proxy.h"
16 #include "dbus/values_util.h" 16 #include "dbus/values_util.h"
17 #include "net/base/ip_endpoint.h"
18 #include "net/base/net_util.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
18 20
19 namespace chromeos { 21 namespace chromeos {
20 22
21 namespace { 23 namespace {
22 24
23 // The ShillDeviceClient implementation. 25 // The ShillDeviceClient implementation.
24 class ShillDeviceClientImpl : public ShillDeviceClient { 26 class ShillDeviceClientImpl : public ShillDeviceClient {
25 public: 27 public:
26 explicit ShillDeviceClientImpl() 28 ShillDeviceClientImpl()
27 : bus_(NULL) { 29 : bus_(NULL) {
28 } 30 }
29 31
30 virtual ~ShillDeviceClientImpl() { 32 virtual ~ShillDeviceClientImpl() {
31 for (HelperMap::iterator iter = helpers_.begin(); 33 for (HelperMap::iterator iter = helpers_.begin();
32 iter != helpers_.end(); ++iter) { 34 iter != helpers_.end(); ++iter) {
33 // This *should* never happen, yet we're getting crash reports that 35 // This *should* never happen, yet we're getting crash reports that
34 // seem to imply that it does happen sometimes. Adding CHECKs here 36 // seem to imply that it does happen sometimes. Adding CHECKs here
35 // so we can determine more accurately where the problem lies. 37 // so we can determine more accurately where the problem lies.
36 // See: http://crbug.com/170541 38 // See: http://crbug.com/170541
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 const ErrorCallback& error_callback) override { 201 const ErrorCallback& error_callback) override {
200 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface, 202 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface,
201 shill::kPerformTDLSOperationFunction); 203 shill::kPerformTDLSOperationFunction);
202 dbus::MessageWriter writer(&method_call); 204 dbus::MessageWriter writer(&method_call);
203 writer.AppendString(operation); 205 writer.AppendString(operation);
204 writer.AppendString(peer); 206 writer.AppendString(peer);
205 GetHelper(device_path)->CallStringMethodWithErrorCallback( 207 GetHelper(device_path)->CallStringMethodWithErrorCallback(
206 &method_call, callback, error_callback); 208 &method_call, callback, error_callback);
207 } 209 }
208 210
211 void AddWakeOnPacketConnection(
212 const dbus::ObjectPath& device_path,
213 const net::IPEndPoint& ip_endpoint,
214 const base::Closure& callback,
215 const ErrorCallback& error_callback) override {
216 if (ip_endpoint.address().empty()) {
217 LOG(ERROR) << "AddWakeOnPacketConnection: null address";
218 return;
219 }
220 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface,
221 shill::kAddWakeOnPacketConnectionFunction);
222 dbus::MessageWriter writer(&method_call);
223 writer.AppendString(net::IPAddressToString(ip_endpoint.address()));
224 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call,
225 callback,
226 error_callback);
227 }
228
229 void RemoveWakeOnPacketConnection(
230 const dbus::ObjectPath& device_path,
231 const net::IPEndPoint& ip_endpoint,
232 const base::Closure& callback,
233 const ErrorCallback& error_callback) override {
234 if (ip_endpoint.address().empty()) {
235 LOG(ERROR) << "RemoveWakeOnPacketConnection: null address";
236 return;
237 }
238 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface,
239 shill::kRemoveWakeOnPacketConnectionFunction);
240 dbus::MessageWriter writer(&method_call);
241 writer.AppendString(net::IPAddressToString(ip_endpoint.address()));
242 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call,
243 callback,
244 error_callback);
245 }
246
247 void RemoveAllWakeOnPacketConnections(
248 const dbus::ObjectPath& device_path,
249 const base::Closure& callback,
250 const ErrorCallback& error_callback) override {
251 dbus::MethodCall method_call(
252 shill::kFlimflamDeviceInterface,
253 shill::kRemoveAllWakeOnPacketConnectionsFunction);
254 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call,
255 callback,
256 error_callback);
257 }
258
209 virtual TestInterface* GetTestInterface() override { 259 virtual TestInterface* GetTestInterface() override {
210 return NULL; 260 return NULL;
211 } 261 }
212 262
213 protected: 263 protected:
214 virtual void Init(dbus::Bus* bus) override { 264 virtual void Init(dbus::Bus* bus) override {
215 bus_ = bus; 265 bus_ = bus;
216 } 266 }
217 267
218 private: 268 private:
(...skipping 28 matching lines...) Expand all
247 ShillDeviceClient::ShillDeviceClient() {} 297 ShillDeviceClient::ShillDeviceClient() {}
248 298
249 ShillDeviceClient::~ShillDeviceClient() {} 299 ShillDeviceClient::~ShillDeviceClient() {}
250 300
251 // static 301 // static
252 ShillDeviceClient* ShillDeviceClient::Create() { 302 ShillDeviceClient* ShillDeviceClient::Create() {
253 return new ShillDeviceClientImpl(); 303 return new ShillDeviceClientImpl();
254 } 304 }
255 305
256 } // namespace chromeos 306 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698