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

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

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 months 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_ipconfig_client.h" 5 #include "chromeos/dbus/shill_ipconfig_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/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 "dbus/bus.h" 11 #include "dbus/bus.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 #include "dbus/object_path.h" 13 #include "dbus/object_path.h"
14 #include "dbus/object_proxy.h" 14 #include "dbus/object_proxy.h"
15 #include "dbus/values_util.h" 15 #include "dbus/values_util.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h" 16 #include "third_party/cros_system_api/dbus/service_constants.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 namespace { 20 namespace {
21 21
22 // The ShillIPConfigClient implementation. 22 // The ShillIPConfigClient implementation.
23 class ShillIPConfigClientImpl : public ShillIPConfigClient { 23 class ShillIPConfigClientImpl : public ShillIPConfigClient {
24 public: 24 public:
25 explicit ShillIPConfigClientImpl(dbus::Bus* bus); 25 explicit ShillIPConfigClientImpl(dbus::Bus* bus);
26 26
27 // ShillIPConfigClient overrides: 27 ////////////////////////////////////
28 virtual void SetPropertyChangedHandler( 28 // ShillIPConfigClient overrides.
29 virtual void AddPropertyChangedObserver(
29 const dbus::ObjectPath& ipconfig_path, 30 const dbus::ObjectPath& ipconfig_path,
30 const PropertyChangedHandler& handler) OVERRIDE; 31 PropertyChangedObserver* observer) OVERRIDE {
31 virtual void ResetPropertyChangedHandler( 32 GetHelper(ipconfig_path)->AddPropertyChangedObserver(observer);
32 const dbus::ObjectPath& ipconfig_path) OVERRIDE; 33 }
34
35 virtual void RemovePropertyChangedObserver(
36 const dbus::ObjectPath& ipconfig_path,
37 PropertyChangedObserver* observer) OVERRIDE {
38 GetHelper(ipconfig_path)->RemovePropertyChangedObserver(observer);
39 }
33 virtual void Refresh(const dbus::ObjectPath& ipconfig_path, 40 virtual void Refresh(const dbus::ObjectPath& ipconfig_path,
34 const VoidDBusMethodCallback& callback) OVERRIDE; 41 const VoidDBusMethodCallback& callback) OVERRIDE;
35 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 42 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path,
36 const DictionaryValueCallback& callback) OVERRIDE; 43 const DictionaryValueCallback& callback) OVERRIDE;
37 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 44 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
38 const dbus::ObjectPath& ipconfig_path) OVERRIDE; 45 const dbus::ObjectPath& ipconfig_path) OVERRIDE;
39 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path, 46 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path,
40 const std::string& name, 47 const std::string& name,
41 const base::Value& value, 48 const base::Value& value,
42 const VoidDBusMethodCallback& callback) OVERRIDE; 49 const VoidDBusMethodCallback& callback) OVERRIDE;
(...skipping 28 matching lines...) Expand all
71 STLValueDeleter<HelperMap> helpers_deleter_; 78 STLValueDeleter<HelperMap> helpers_deleter_;
72 79
73 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientImpl); 80 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientImpl);
74 }; 81 };
75 82
76 ShillIPConfigClientImpl::ShillIPConfigClientImpl(dbus::Bus* bus) 83 ShillIPConfigClientImpl::ShillIPConfigClientImpl(dbus::Bus* bus)
77 : bus_(bus), 84 : bus_(bus),
78 helpers_deleter_(&helpers_) { 85 helpers_deleter_(&helpers_) {
79 } 86 }
80 87
81 void ShillIPConfigClientImpl::SetPropertyChangedHandler(
82 const dbus::ObjectPath& ipconfig_path,
83 const PropertyChangedHandler& handler) {
84 GetHelper(ipconfig_path)->SetPropertyChangedHandler(handler);
85 }
86
87 void ShillIPConfigClientImpl::ResetPropertyChangedHandler(
88 const dbus::ObjectPath& ipconfig_path) {
89 GetHelper(ipconfig_path)->ResetPropertyChangedHandler();
90 }
91
92 void ShillIPConfigClientImpl::GetProperties( 88 void ShillIPConfigClientImpl::GetProperties(
93 const dbus::ObjectPath& ipconfig_path, 89 const dbus::ObjectPath& ipconfig_path,
94 const DictionaryValueCallback& callback) { 90 const DictionaryValueCallback& callback) {
95 dbus::MethodCall method_call(flimflam::kFlimflamIPConfigInterface, 91 dbus::MethodCall method_call(flimflam::kFlimflamIPConfigInterface,
96 flimflam::kGetPropertiesFunction); 92 flimflam::kGetPropertiesFunction);
97 GetHelper(ipconfig_path)->CallDictionaryValueMethod(&method_call, callback); 93 GetHelper(ipconfig_path)->CallDictionaryValueMethod(&method_call, callback);
98 } 94 }
99 95
100 base::DictionaryValue* ShillIPConfigClientImpl::CallGetPropertiesAndBlock( 96 base::DictionaryValue* ShillIPConfigClientImpl::CallGetPropertiesAndBlock(
101 const dbus::ObjectPath& ipconfig_path) { 97 const dbus::ObjectPath& ipconfig_path) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 179
184 // A stub implementation of ShillIPConfigClient. 180 // A stub implementation of ShillIPConfigClient.
185 class ShillIPConfigClientStubImpl : public ShillIPConfigClient { 181 class ShillIPConfigClientStubImpl : public ShillIPConfigClient {
186 public: 182 public:
187 ShillIPConfigClientStubImpl() : weak_ptr_factory_(this) {} 183 ShillIPConfigClientStubImpl() : weak_ptr_factory_(this) {}
188 184
189 virtual ~ShillIPConfigClientStubImpl() {} 185 virtual ~ShillIPConfigClientStubImpl() {}
190 186
191 /////////////////////////////////////////////// 187 ///////////////////////////////////////////////
192 // ShillIPConfigClient overrides: 188 // ShillIPConfigClient overrides:
193 virtual void SetPropertyChangedHandler( 189 virtual void AddPropertyChangedObserver(
194 const dbus::ObjectPath& ipconfig_path, 190 const dbus::ObjectPath& ipconfig_path,
195 const PropertyChangedHandler& handler) OVERRIDE {} 191 PropertyChangedObserver* observer) OVERRIDE {}
196 192 virtual void RemovePropertyChangedObserver(
197 virtual void ResetPropertyChangedHandler( 193 const dbus::ObjectPath& ipconfig_path,
198 const dbus::ObjectPath& ipconfig_path) OVERRIDE {} 194 PropertyChangedObserver* observer) OVERRIDE {}
199 195
200 virtual void Refresh(const dbus::ObjectPath& ipconfig_path, 196 virtual void Refresh(const dbus::ObjectPath& ipconfig_path,
201 const VoidDBusMethodCallback& callback) OVERRIDE {} 197 const VoidDBusMethodCallback& callback) OVERRIDE {}
202 198
203 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 199 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path,
204 const DictionaryValueCallback& callback) OVERRIDE { 200 const DictionaryValueCallback& callback) OVERRIDE {
205 MessageLoop::current()->PostTask( 201 MessageLoop::current()->PostTask(
206 FROM_HERE, base::Bind(&ShillIPConfigClientStubImpl::PassProperties, 202 FROM_HERE, base::Bind(&ShillIPConfigClientStubImpl::PassProperties,
207 weak_ptr_factory_.GetWeakPtr(), 203 weak_ptr_factory_.GetWeakPtr(),
208 callback)); 204 callback));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 ShillIPConfigClient* ShillIPConfigClient::Create( 260 ShillIPConfigClient* ShillIPConfigClient::Create(
265 DBusClientImplementationType type, 261 DBusClientImplementationType type,
266 dbus::Bus* bus) { 262 dbus::Bus* bus) {
267 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 263 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
268 return new ShillIPConfigClientImpl(bus); 264 return new ShillIPConfigClientImpl(bus);
269 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 265 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
270 return new ShillIPConfigClientStubImpl(); 266 return new ShillIPConfigClientStubImpl();
271 } 267 }
272 268
273 } // namespace chromeos 269 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698