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

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

Issue 10824242: This adds Cros API for calling the "Refresh" function on shill's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed indentation nit Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/flimflam_ipconfig_client.h ('k') | chromeos/dbus/mock_flimflam_ipconfig_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/flimflam_ipconfig_client.h" 5 #include "chromeos/dbus/flimflam_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"
(...skipping 12 matching lines...) Expand all
23 class FlimflamIPConfigClientImpl : public FlimflamIPConfigClient { 23 class FlimflamIPConfigClientImpl : public FlimflamIPConfigClient {
24 public: 24 public:
25 explicit FlimflamIPConfigClientImpl(dbus::Bus* bus); 25 explicit FlimflamIPConfigClientImpl(dbus::Bus* bus);
26 26
27 // FlimflamIPConfigClient overrides: 27 // FlimflamIPConfigClient overrides:
28 virtual void SetPropertyChangedHandler( 28 virtual void SetPropertyChangedHandler(
29 const dbus::ObjectPath& ipconfig_path, 29 const dbus::ObjectPath& ipconfig_path,
30 const PropertyChangedHandler& handler) OVERRIDE; 30 const PropertyChangedHandler& handler) OVERRIDE;
31 virtual void ResetPropertyChangedHandler( 31 virtual void ResetPropertyChangedHandler(
32 const dbus::ObjectPath& ipconfig_path) OVERRIDE; 32 const dbus::ObjectPath& ipconfig_path) OVERRIDE;
33 virtual void Refresh(const dbus::ObjectPath& ipconfig_path,
34 const VoidDBusMethodCallback& callback) OVERRIDE;
33 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 35 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path,
34 const DictionaryValueCallback& callback) OVERRIDE; 36 const DictionaryValueCallback& callback) OVERRIDE;
35 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 37 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
36 const dbus::ObjectPath& ipconfig_path) OVERRIDE; 38 const dbus::ObjectPath& ipconfig_path) OVERRIDE;
37 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path, 39 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path,
38 const std::string& name, 40 const std::string& name,
39 const base::Value& value, 41 const base::Value& value,
40 const VoidDBusMethodCallback& callback) OVERRIDE; 42 const VoidDBusMethodCallback& callback) OVERRIDE;
41 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path, 43 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path,
42 const std::string& name, 44 const std::string& name,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 98 }
97 99
98 base::DictionaryValue* FlimflamIPConfigClientImpl::CallGetPropertiesAndBlock( 100 base::DictionaryValue* FlimflamIPConfigClientImpl::CallGetPropertiesAndBlock(
99 const dbus::ObjectPath& ipconfig_path) { 101 const dbus::ObjectPath& ipconfig_path) {
100 dbus::MethodCall method_call(flimflam::kFlimflamIPConfigInterface, 102 dbus::MethodCall method_call(flimflam::kFlimflamIPConfigInterface,
101 flimflam::kGetPropertiesFunction); 103 flimflam::kGetPropertiesFunction);
102 return GetHelper(ipconfig_path)->CallDictionaryValueMethodAndBlock( 104 return GetHelper(ipconfig_path)->CallDictionaryValueMethodAndBlock(
103 &method_call); 105 &method_call);
104 } 106 }
105 107
108 void FlimflamIPConfigClientImpl::Refresh(
109 const dbus::ObjectPath& ipconfig_path,
110 const VoidDBusMethodCallback& callback) {
111 dbus::MethodCall method_call(flimflam::kFlimflamIPConfigInterface,
112 shill::kRefreshFunction);
113 GetHelper(ipconfig_path)->CallVoidMethod(&method_call, callback);
114 }
115
106 void FlimflamIPConfigClientImpl::SetProperty( 116 void FlimflamIPConfigClientImpl::SetProperty(
107 const dbus::ObjectPath& ipconfig_path, 117 const dbus::ObjectPath& ipconfig_path,
108 const std::string& name, 118 const std::string& name,
109 const base::Value& value, 119 const base::Value& value,
110 const VoidDBusMethodCallback& callback) { 120 const VoidDBusMethodCallback& callback) {
111 dbus::MethodCall method_call(flimflam::kFlimflamIPConfigInterface, 121 dbus::MethodCall method_call(flimflam::kFlimflamIPConfigInterface,
112 flimflam::kSetPropertyFunction); 122 flimflam::kSetPropertyFunction);
113 dbus::MessageWriter writer(&method_call); 123 dbus::MessageWriter writer(&method_call);
114 writer.AppendString(name); 124 writer.AppendString(name);
115 // IPConfig supports writing basic type and string array properties. 125 // IPConfig supports writing basic type and string array properties.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return GetHelper(ipconfig_path)->CallVoidMethodAndBlock(&method_call); 181 return GetHelper(ipconfig_path)->CallVoidMethodAndBlock(&method_call);
172 } 182 }
173 183
174 // A stub implementation of FlimflamIPConfigClient. 184 // A stub implementation of FlimflamIPConfigClient.
175 class FlimflamIPConfigClientStubImpl : public FlimflamIPConfigClient { 185 class FlimflamIPConfigClientStubImpl : public FlimflamIPConfigClient {
176 public: 186 public:
177 FlimflamIPConfigClientStubImpl() : weak_ptr_factory_(this) {} 187 FlimflamIPConfigClientStubImpl() : weak_ptr_factory_(this) {}
178 188
179 virtual ~FlimflamIPConfigClientStubImpl() {} 189 virtual ~FlimflamIPConfigClientStubImpl() {}
180 190
181 // FlimflamIPConfigClient override. 191 ///////////////////////////////////////////////
192 // FlimflamIPConfigClient overrides:
182 virtual void SetPropertyChangedHandler( 193 virtual void SetPropertyChangedHandler(
183 const dbus::ObjectPath& ipconfig_path, 194 const dbus::ObjectPath& ipconfig_path,
184 const PropertyChangedHandler& handler) OVERRIDE {} 195 const PropertyChangedHandler& handler) OVERRIDE {}
185 196
186 // FlimflamIPConfigClient override.
187 virtual void ResetPropertyChangedHandler( 197 virtual void ResetPropertyChangedHandler(
188 const dbus::ObjectPath& ipconfig_path) OVERRIDE {} 198 const dbus::ObjectPath& ipconfig_path) OVERRIDE {}
189 199
190 // FlimflamIPConfigClient override. 200 virtual void Refresh(const dbus::ObjectPath& ipconfig_path,
201 const VoidDBusMethodCallback& callback) OVERRIDE {}
202
191 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 203 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path,
192 const DictionaryValueCallback& callback) OVERRIDE { 204 const DictionaryValueCallback& callback) OVERRIDE {
193 MessageLoop::current()->PostTask( 205 MessageLoop::current()->PostTask(
194 FROM_HERE, base::Bind(&FlimflamIPConfigClientStubImpl::PassProperties, 206 FROM_HERE, base::Bind(&FlimflamIPConfigClientStubImpl::PassProperties,
195 weak_ptr_factory_.GetWeakPtr(), 207 weak_ptr_factory_.GetWeakPtr(),
196 callback)); 208 callback));
197 } 209 }
198 210
199 // FlimflamIPConfigClient override.
200 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 211 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
201 const dbus::ObjectPath& ipconfig_path) OVERRIDE { 212 const dbus::ObjectPath& ipconfig_path) OVERRIDE {
202 return new base::DictionaryValue; 213 return new base::DictionaryValue;
203 } 214 }
204 215
205 // FlimflamIPConfigClient override.
206 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path, 216 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path,
207 const std::string& name, 217 const std::string& name,
208 const base::Value& value, 218 const base::Value& value,
209 const VoidDBusMethodCallback& callback) OVERRIDE { 219 const VoidDBusMethodCallback& callback) OVERRIDE {
210 MessageLoop::current()->PostTask( 220 MessageLoop::current()->PostTask(
211 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 221 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
212 } 222 }
213 223
214 // FlimflamIPConfigClient override.
215 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path, 224 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path,
216 const std::string& name, 225 const std::string& name,
217 const VoidDBusMethodCallback& callback) OVERRIDE { 226 const VoidDBusMethodCallback& callback) OVERRIDE {
218 MessageLoop::current()->PostTask( 227 MessageLoop::current()->PostTask(
219 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 228 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
220 } 229 }
221 230
222 // FlimflamIPConfigClient override.
223 virtual void Remove(const dbus::ObjectPath& ipconfig_path, 231 virtual void Remove(const dbus::ObjectPath& ipconfig_path,
224 const VoidDBusMethodCallback& callback) OVERRIDE { 232 const VoidDBusMethodCallback& callback) OVERRIDE {
225 MessageLoop::current()->PostTask( 233 MessageLoop::current()->PostTask(
226 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 234 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
227 } 235 }
228 236
229 // FlimflamIPConfigClient override.
230 virtual bool CallRemoveAndBlock( 237 virtual bool CallRemoveAndBlock(
231 const dbus::ObjectPath& ipconfig_path) OVERRIDE { 238 const dbus::ObjectPath& ipconfig_path) OVERRIDE {
232 return true; 239 return true;
233 } 240 }
234 241
235 private: 242 private:
236 // Runs callback with |properties_|. 243 // Runs callback with |properties_|.
237 void PassProperties(const DictionaryValueCallback& callback) const { 244 void PassProperties(const DictionaryValueCallback& callback) const {
238 callback.Run(DBUS_METHOD_CALL_SUCCESS, properties_); 245 callback.Run(DBUS_METHOD_CALL_SUCCESS, properties_);
239 } 246 }
(...skipping 14 matching lines...) Expand all
254 FlimflamIPConfigClient* FlimflamIPConfigClient::Create( 261 FlimflamIPConfigClient* FlimflamIPConfigClient::Create(
255 DBusClientImplementationType type, 262 DBusClientImplementationType type,
256 dbus::Bus* bus) { 263 dbus::Bus* bus) {
257 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 264 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
258 return new FlimflamIPConfigClientImpl(bus); 265 return new FlimflamIPConfigClientImpl(bus);
259 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 266 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
260 return new FlimflamIPConfigClientStubImpl(); 267 return new FlimflamIPConfigClientStubImpl();
261 } 268 }
262 269
263 } // namespace chromeos 270 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/flimflam_ipconfig_client.h ('k') | chromeos/dbus/mock_flimflam_ipconfig_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698