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

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: 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 unified diff | Download patch
« no previous file with comments | « chromeos/dbus/shill_device_client.h ('k') | chromeos/dbus/shill_manager_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 namespace { 22 namespace {
22 23
23 // The ShillDeviceClient implementation. 24 // The ShillDeviceClient implementation.
24 class ShillDeviceClientImpl : public ShillDeviceClient { 25 class ShillDeviceClientImpl : public ShillDeviceClient {
25 public: 26 public:
26 explicit ShillDeviceClientImpl() 27 ShillDeviceClientImpl()
27 : bus_(NULL) { 28 : bus_(NULL) {
28 } 29 }
29 30
30 virtual ~ShillDeviceClientImpl() { 31 virtual ~ShillDeviceClientImpl() {
31 for (HelperMap::iterator iter = helpers_.begin(); 32 for (HelperMap::iterator iter = helpers_.begin();
32 iter != helpers_.end(); ++iter) { 33 iter != helpers_.end(); ++iter) {
33 // This *should* never happen, yet we're getting crash reports that 34 // This *should* never happen, yet we're getting crash reports that
34 // seem to imply that it does happen sometimes. Adding CHECKs here 35 // seem to imply that it does happen sometimes. Adding CHECKs here
35 // so we can determine more accurately where the problem lies. 36 // so we can determine more accurately where the problem lies.
36 // See: http://crbug.com/170541 37 // See: http://crbug.com/170541
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 const ErrorCallback& error_callback) override { 200 const ErrorCallback& error_callback) override {
200 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface, 201 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface,
201 shill::kPerformTDLSOperationFunction); 202 shill::kPerformTDLSOperationFunction);
202 dbus::MessageWriter writer(&method_call); 203 dbus::MessageWriter writer(&method_call);
203 writer.AppendString(operation); 204 writer.AppendString(operation);
204 writer.AppendString(peer); 205 writer.AppendString(peer);
205 GetHelper(device_path)->CallStringMethodWithErrorCallback( 206 GetHelper(device_path)->CallStringMethodWithErrorCallback(
206 &method_call, callback, error_callback); 207 &method_call, callback, error_callback);
207 } 208 }
208 209
210 void AddWakeOnPacketConnection(
211 const dbus::ObjectPath& device_path,
212 const net::IPEndPoint& ip_endpoint,
213 const base::Closure& callback,
214 const ErrorCallback& error_callback) override {
215 if (ip_endpoint.address().empty()) {
216 LOG(ERROR) << "AddWakeOnPacketConnection: null address";
217 return;
218 }
219 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface,
220 shill::kAddWakeOnPacketConnectionFunction);
221 dbus::MessageWriter writer(&method_call);
222 writer.AppendString(ip_endpoint.ToStringWithoutPort());
223 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call,
224 callback,
225 error_callback);
226 }
227
228 void RemoveWakeOnPacketConnection(
229 const dbus::ObjectPath& device_path,
230 const net::IPEndPoint& ip_endpoint,
231 const base::Closure& callback,
232 const ErrorCallback& error_callback) override {
233 if (ip_endpoint.address().empty()) {
234 LOG(ERROR) << "RemoveWakeOnPacketConnection: null address";
235 return;
236 }
237 dbus::MethodCall method_call(shill::kFlimflamDeviceInterface,
238 shill::kRemoveWakeOnPacketConnectionFunction);
239 dbus::MessageWriter writer(&method_call);
240 writer.AppendString(ip_endpoint.ToStringWithoutPort());
241 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call,
242 callback,
243 error_callback);
244 }
245
246 void RemoveAllWakeOnPacketConnections(
247 const dbus::ObjectPath& device_path,
248 const base::Closure& callback,
249 const ErrorCallback& error_callback) override {
250 dbus::MethodCall method_call(
251 shill::kFlimflamDeviceInterface,
252 shill::kRemoveAllWakeOnPacketConnectionsFunction);
253 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call,
254 callback,
255 error_callback);
256 }
257
209 virtual TestInterface* GetTestInterface() override { 258 virtual TestInterface* GetTestInterface() override {
210 return NULL; 259 return NULL;
211 } 260 }
212 261
213 protected: 262 protected:
214 virtual void Init(dbus::Bus* bus) override { 263 virtual void Init(dbus::Bus* bus) override {
215 bus_ = bus; 264 bus_ = bus;
216 } 265 }
217 266
218 private: 267 private:
(...skipping 28 matching lines...) Expand all
247 ShillDeviceClient::ShillDeviceClient() {} 296 ShillDeviceClient::ShillDeviceClient() {}
248 297
249 ShillDeviceClient::~ShillDeviceClient() {} 298 ShillDeviceClient::~ShillDeviceClient() {}
250 299
251 // static 300 // static
252 ShillDeviceClient* ShillDeviceClient::Create() { 301 ShillDeviceClient* ShillDeviceClient::Create() {
253 return new ShillDeviceClientImpl(); 302 return new ShillDeviceClientImpl();
254 } 303 }
255 304
256 } // namespace chromeos 305 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_device_client.h ('k') | chromeos/dbus/shill_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698