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

Side by Side Diff: chromeos/dbus/shill_manager_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: Fix bad merge Created 8 years, 2 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
« no previous file with comments | « chromeos/dbus/shill_manager_client.h ('k') | chromeos/dbus/shill_manager_client_unittest.cc » ('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_manager_client.h" 5 #include "chromeos/dbus/shill_manager_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/chromeos/chromeos_version.h" 8 #include "base/chromeos/chromeos_version.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE { 79 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE {
80 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 80 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
81 flimflam::kGetPropertiesFunction); 81 flimflam::kGetPropertiesFunction);
82 return helper_.CallDictionaryValueMethodAndBlock(&method_call); 82 return helper_.CallDictionaryValueMethodAndBlock(&method_call);
83 } 83 }
84 84
85 virtual void SetProperty(const std::string& name, 85 virtual void SetProperty(const std::string& name,
86 const base::Value& value, 86 const base::Value& value,
87 const VoidDBusMethodCallback& callback) OVERRIDE { 87 const base::Closure& callback,
88 const ErrorCallback& error_callback) OVERRIDE {
88 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 89 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
89 flimflam::kSetPropertyFunction); 90 flimflam::kSetPropertyFunction);
90 dbus::MessageWriter writer(&method_call); 91 dbus::MessageWriter writer(&method_call);
91 writer.AppendString(name); 92 writer.AppendString(name);
92 ShillClientHelper::AppendValueDataAsVariant(&writer, value); 93 ShillClientHelper::AppendValueDataAsVariant(&writer, value);
93 helper_.CallVoidMethod(&method_call, callback); 94 helper_.CallVoidMethodWithErrorCallback(&method_call,
95 callback,
96 error_callback);
94 } 97 }
95 98
96 virtual void RequestScan(const std::string& type, 99 virtual void RequestScan(const std::string& type,
97 const VoidDBusMethodCallback& callback) OVERRIDE { 100 const base::Closure& callback,
101 const ErrorCallback& error_callback) OVERRIDE {
98 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 102 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
99 flimflam::kRequestScanFunction); 103 flimflam::kRequestScanFunction);
100 dbus::MessageWriter writer(&method_call); 104 dbus::MessageWriter writer(&method_call);
101 writer.AppendString(type); 105 writer.AppendString(type);
102 helper_.CallVoidMethod(&method_call, callback); 106 helper_.CallVoidMethodWithErrorCallback(&method_call,
107 callback,
108 error_callback);
103 } 109 }
104 110
105 virtual void EnableTechnology( 111 virtual void EnableTechnology(
106 const std::string& type, 112 const std::string& type,
107 const VoidDBusMethodCallback& callback) OVERRIDE { 113 const base::Closure& callback,
114 const ErrorCallback& error_callback) OVERRIDE {
108 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 115 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
109 flimflam::kEnableTechnologyFunction); 116 flimflam::kEnableTechnologyFunction);
110 dbus::MessageWriter writer(&method_call); 117 dbus::MessageWriter writer(&method_call);
111 writer.AppendString(type); 118 writer.AppendString(type);
112 helper_.CallVoidMethod(&method_call, callback); 119 helper_.CallVoidMethodWithErrorCallback(&method_call,
120 callback,
121 error_callback);
113 } 122 }
114 123
115 virtual void DisableTechnology( 124 virtual void DisableTechnology(
116 const std::string& type, 125 const std::string& type,
117 const VoidDBusMethodCallback& callback) OVERRIDE { 126 const base::Closure& callback,
127 const ErrorCallback& error_callback) OVERRIDE {
118 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 128 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
119 flimflam::kDisableTechnologyFunction); 129 flimflam::kDisableTechnologyFunction);
120 dbus::MessageWriter writer(&method_call); 130 dbus::MessageWriter writer(&method_call);
121 writer.AppendString(type); 131 writer.AppendString(type);
122 helper_.CallVoidMethod(&method_call, callback); 132 helper_.CallVoidMethodWithErrorCallback(&method_call,
133 callback,
134 error_callback);
123 } 135 }
124 136
125 virtual void ConfigureService( 137 virtual void ConfigureService(
126 const base::DictionaryValue& properties, 138 const base::DictionaryValue& properties,
127 const VoidDBusMethodCallback& callback) OVERRIDE { 139 const base::Closure& callback,
140 const ErrorCallback& error_callback) OVERRIDE {
128 DCHECK(AreServicePropertiesValid(properties)); 141 DCHECK(AreServicePropertiesValid(properties));
129 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 142 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
130 flimflam::kConfigureServiceFunction); 143 flimflam::kConfigureServiceFunction);
131 dbus::MessageWriter writer(&method_call); 144 dbus::MessageWriter writer(&method_call);
132 AppendServicePropertiesDictionary(&writer, properties); 145 AppendServicePropertiesDictionary(&writer, properties);
133 helper_.CallVoidMethod(&method_call, callback); 146 helper_.CallVoidMethodWithErrorCallback(&method_call,
147 callback,
148 error_callback);
134 } 149 }
135 150
136 virtual void GetService( 151 virtual void GetService(
137 const base::DictionaryValue& properties, 152 const base::DictionaryValue& properties,
138 const ObjectPathDBusMethodCallback& callback) OVERRIDE { 153 const ObjectPathCallback& callback,
154 const ErrorCallback& error_callback) OVERRIDE {
139 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 155 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
140 flimflam::kGetServiceFunction); 156 flimflam::kGetServiceFunction);
141 dbus::MessageWriter writer(&method_call); 157 dbus::MessageWriter writer(&method_call);
142 AppendServicePropertiesDictionary(&writer, properties); 158 AppendServicePropertiesDictionary(&writer, properties);
143 helper_.CallObjectPathMethod(&method_call, callback); 159 helper_.CallObjectPathMethodWithErrorCallback(&method_call,
160 callback,
161 error_callback);
144 } 162 }
145 163
146 private: 164 private:
147 dbus::ObjectProxy* proxy_; 165 dbus::ObjectProxy* proxy_;
148 ShillClientHelper helper_; 166 ShillClientHelper helper_;
149 167
150 DISALLOW_COPY_AND_ASSIGN(ShillManagerClientImpl); 168 DISALLOW_COPY_AND_ASSIGN(ShillManagerClientImpl);
151 }; 169 };
152 170
153 // A stub implementation of ShillManagerClient. 171 // A stub implementation of ShillManagerClient.
(...skipping 30 matching lines...) Expand all
184 } 202 }
185 203
186 // ShillManagerClient override. 204 // ShillManagerClient override.
187 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE { 205 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE {
188 return new base::DictionaryValue; 206 return new base::DictionaryValue;
189 } 207 }
190 208
191 // ShillManagerClient override. 209 // ShillManagerClient override.
192 virtual void SetProperty(const std::string& name, 210 virtual void SetProperty(const std::string& name,
193 const base::Value& value, 211 const base::Value& value,
194 const VoidDBusMethodCallback& callback) OVERRIDE { 212 const base::Closure& callback,
213 const ErrorCallback& error_callback) OVERRIDE {
195 stub_properties_.Set(name, value.DeepCopy()); 214 stub_properties_.Set(name, value.DeepCopy());
196 MessageLoop::current()->PostTask(FROM_HERE, 215 MessageLoop::current()->PostTask(FROM_HERE, callback);
197 base::Bind(callback,
198 DBUS_METHOD_CALL_SUCCESS));
199 } 216 }
200 217
201 // ShillManagerClient override. 218 // ShillManagerClient override.
202 virtual void RequestScan(const std::string& type, 219 virtual void RequestScan(const std::string& type,
203 const VoidDBusMethodCallback& callback) OVERRIDE { 220 const base::Closure& callback,
204 MessageLoop::current()->PostTask(FROM_HERE, 221 const ErrorCallback& error_callback) OVERRIDE {
205 base::Bind(callback, 222 MessageLoop::current()->PostTask(FROM_HERE, callback);
206 DBUS_METHOD_CALL_SUCCESS));
207 } 223 }
208 224
209 // ShillManagerClient override. 225 // ShillManagerClient override.
210 virtual void EnableTechnology( 226 virtual void EnableTechnology(
211 const std::string& type, 227 const std::string& type,
212 const VoidDBusMethodCallback& callback) OVERRIDE { 228 const base::Closure& callback,
213 MessageLoop::current()->PostTask(FROM_HERE, 229 const ErrorCallback& error_callback) OVERRIDE {
214 base::Bind(callback, 230 MessageLoop::current()->PostTask(FROM_HERE, callback);
215 DBUS_METHOD_CALL_SUCCESS));
216 } 231 }
217 232
218 // ShillManagerClient override. 233 // ShillManagerClient override.
219 virtual void DisableTechnology( 234 virtual void DisableTechnology(
220 const std::string& type, 235 const std::string& type,
221 const VoidDBusMethodCallback& callback) OVERRIDE { 236 const base::Closure& callback,
222 MessageLoop::current()->PostTask(FROM_HERE, 237 const ErrorCallback& error_callback) OVERRIDE {
223 base::Bind(callback, 238 MessageLoop::current()->PostTask(FROM_HERE, callback);
224 DBUS_METHOD_CALL_SUCCESS));
225 } 239 }
226 240
227 // ShillManagerClient override. 241 // ShillManagerClient override.
228 virtual void ConfigureService( 242 virtual void ConfigureService(
229 const base::DictionaryValue& properties, 243 const base::DictionaryValue& properties,
230 const VoidDBusMethodCallback& callback) OVERRIDE { 244 const base::Closure& callback,
231 MessageLoop::current()->PostTask(FROM_HERE, 245 const ErrorCallback& error_callback) OVERRIDE {
232 base::Bind(callback, 246 MessageLoop::current()->PostTask(FROM_HERE, callback);
233 DBUS_METHOD_CALL_SUCCESS));
234 } 247 }
235 248
236 // ShillManagerClient override. 249 // ShillManagerClient override.
237 virtual void GetService( 250 virtual void GetService(
238 const base::DictionaryValue& properties, 251 const base::DictionaryValue& properties,
239 const ObjectPathDBusMethodCallback& callback) OVERRIDE { 252 const ObjectPathCallback& callback,
253 const ErrorCallback& error_callback) OVERRIDE {
240 MessageLoop::current()->PostTask(FROM_HERE, 254 MessageLoop::current()->PostTask(FROM_HERE,
241 base::Bind(callback, 255 base::Bind(callback,
242 DBUS_METHOD_CALL_SUCCESS,
243 dbus::ObjectPath())); 256 dbus::ObjectPath()));
244 } 257 }
245 258
246 private: 259 private:
247 void PassStubProperties(const DictionaryValueCallback& callback) const { 260 void PassStubProperties(const DictionaryValueCallback& callback) const {
248 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_properties_); 261 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_properties_);
249 } 262 }
250 263
251 base::DictionaryValue stub_properties_; 264 base::DictionaryValue stub_properties_;
252 265
(...skipping 14 matching lines...) Expand all
267 ShillManagerClient* ShillManagerClient::Create( 280 ShillManagerClient* ShillManagerClient::Create(
268 DBusClientImplementationType type, 281 DBusClientImplementationType type,
269 dbus::Bus* bus) { 282 dbus::Bus* bus) {
270 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 283 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
271 return new ShillManagerClientImpl(bus); 284 return new ShillManagerClientImpl(bus);
272 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 285 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
273 return new ShillManagerClientStubImpl(); 286 return new ShillManagerClientStubImpl();
274 } 287 }
275 288
276 } // namespace chromeos 289 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_manager_client.h ('k') | chromeos/dbus/shill_manager_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698