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

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

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge 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
« 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/flimflam_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"
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"
(...skipping 17 matching lines...) Expand all
33 dbus::MessageWriter* writer, 33 dbus::MessageWriter* writer,
34 const base::DictionaryValue& dictionary) { 34 const base::DictionaryValue& dictionary) {
35 dbus::MessageWriter array_writer(NULL); 35 dbus::MessageWriter array_writer(NULL);
36 writer->OpenArray("{sv}", &array_writer); 36 writer->OpenArray("{sv}", &array_writer);
37 for (base::DictionaryValue::Iterator it(dictionary); 37 for (base::DictionaryValue::Iterator it(dictionary);
38 it.HasNext(); 38 it.HasNext();
39 it.Advance()) { 39 it.Advance()) {
40 dbus::MessageWriter entry_writer(NULL); 40 dbus::MessageWriter entry_writer(NULL);
41 array_writer.OpenDictEntry(&entry_writer); 41 array_writer.OpenDictEntry(&entry_writer);
42 entry_writer.AppendString(it.key()); 42 entry_writer.AppendString(it.key());
43 FlimflamClientHelper::AppendValueDataAsVariant(&entry_writer, it.value()); 43 ShillClientHelper::AppendValueDataAsVariant(&entry_writer, it.value());
44 array_writer.CloseContainer(&entry_writer); 44 array_writer.CloseContainer(&entry_writer);
45 } 45 }
46 writer->CloseContainer(&array_writer); 46 writer->CloseContainer(&array_writer);
47 } 47 }
48 48
49 // The FlimflamManagerClient implementation. 49 // The ShillManagerClient implementation.
50 class FlimflamManagerClientImpl : public FlimflamManagerClient { 50 class ShillManagerClientImpl : public ShillManagerClient {
51 public: 51 public:
52 explicit FlimflamManagerClientImpl(dbus::Bus* bus) 52 explicit ShillManagerClientImpl(dbus::Bus* bus)
53 : proxy_(bus->GetObjectProxy( 53 : proxy_(bus->GetObjectProxy(
54 flimflam::kFlimflamServiceName, 54 flimflam::kFlimflamServiceName,
55 dbus::ObjectPath(flimflam::kFlimflamServicePath))), 55 dbus::ObjectPath(flimflam::kFlimflamServicePath))),
56 helper_(bus, proxy_) { 56 helper_(bus, proxy_) {
57 helper_.MonitorPropertyChanged(flimflam::kFlimflamManagerInterface); 57 helper_.MonitorPropertyChanged(flimflam::kFlimflamManagerInterface);
58 } 58 }
59 59
60 // FlimflamManagerClient overrides: 60 // ShillManagerClient overrides:
61 virtual void SetPropertyChangedHandler( 61 virtual void SetPropertyChangedHandler(
62 const PropertyChangedHandler& handler) OVERRIDE { 62 const PropertyChangedHandler& handler) OVERRIDE {
63 helper_.SetPropertyChangedHandler(handler); 63 helper_.SetPropertyChangedHandler(handler);
64 } 64 }
65 65
66 virtual void ResetPropertyChangedHandler() OVERRIDE { 66 virtual void ResetPropertyChangedHandler() OVERRIDE {
67 helper_.ResetPropertyChangedHandler(); 67 helper_.ResetPropertyChangedHandler();
68 } 68 }
69 69
70 virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE { 70 virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE {
71 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 71 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
72 flimflam::kGetPropertiesFunction); 72 flimflam::kGetPropertiesFunction);
73 helper_.CallDictionaryValueMethod(&method_call, callback); 73 helper_.CallDictionaryValueMethod(&method_call, callback);
74 } 74 }
75 75
76 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE { 76 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE {
77 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 77 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
78 flimflam::kGetPropertiesFunction); 78 flimflam::kGetPropertiesFunction);
79 return helper_.CallDictionaryValueMethodAndBlock(&method_call); 79 return helper_.CallDictionaryValueMethodAndBlock(&method_call);
80 } 80 }
81 81
82 virtual void SetProperty(const std::string& name, 82 virtual void SetProperty(const std::string& name,
83 const base::Value& value, 83 const base::Value& value,
84 const VoidDBusMethodCallback& callback) OVERRIDE { 84 const VoidDBusMethodCallback& callback) OVERRIDE {
85 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 85 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
86 flimflam::kSetPropertyFunction); 86 flimflam::kSetPropertyFunction);
87 dbus::MessageWriter writer(&method_call); 87 dbus::MessageWriter writer(&method_call);
88 writer.AppendString(name); 88 writer.AppendString(name);
89 FlimflamClientHelper::AppendValueDataAsVariant(&writer, value); 89 ShillClientHelper::AppendValueDataAsVariant(&writer, value);
90 helper_.CallVoidMethod(&method_call, callback); 90 helper_.CallVoidMethod(&method_call, callback);
91 } 91 }
92 92
93 virtual void RequestScan(const std::string& type, 93 virtual void RequestScan(const std::string& type,
94 const VoidDBusMethodCallback& callback) OVERRIDE { 94 const VoidDBusMethodCallback& callback) OVERRIDE {
95 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 95 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
96 flimflam::kRequestScanFunction); 96 flimflam::kRequestScanFunction);
97 dbus::MessageWriter writer(&method_call); 97 dbus::MessageWriter writer(&method_call);
98 writer.AppendString(type); 98 writer.AppendString(type);
99 helper_.CallVoidMethod(&method_call, callback); 99 helper_.CallVoidMethod(&method_call, callback);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const ObjectPathDBusMethodCallback& callback) OVERRIDE { 135 const ObjectPathDBusMethodCallback& callback) OVERRIDE {
136 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 136 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
137 flimflam::kGetServiceFunction); 137 flimflam::kGetServiceFunction);
138 dbus::MessageWriter writer(&method_call); 138 dbus::MessageWriter writer(&method_call);
139 AppendServicePropertiesDictionary(&writer, properties); 139 AppendServicePropertiesDictionary(&writer, properties);
140 helper_.CallObjectPathMethod(&method_call, callback); 140 helper_.CallObjectPathMethod(&method_call, callback);
141 } 141 }
142 142
143 private: 143 private:
144 dbus::ObjectProxy* proxy_; 144 dbus::ObjectProxy* proxy_;
145 FlimflamClientHelper helper_; 145 ShillClientHelper helper_;
146 146
147 DISALLOW_COPY_AND_ASSIGN(FlimflamManagerClientImpl); 147 DISALLOW_COPY_AND_ASSIGN(ShillManagerClientImpl);
148 }; 148 };
149 149
150 // A stub implementation of FlimflamManagerClient. 150 // A stub implementation of ShillManagerClient.
151 // Implemented: Stub cellular DeviceList entry for SMS testing. 151 // Implemented: Stub cellular DeviceList entry for SMS testing.
152 class FlimflamManagerClientStubImpl : public FlimflamManagerClient { 152 class ShillManagerClientStubImpl : public ShillManagerClient {
153 public: 153 public:
154 FlimflamManagerClientStubImpl() : weak_ptr_factory_(this) { 154 ShillManagerClientStubImpl() : weak_ptr_factory_(this) {
155 base::ListValue* device_list = new base::ListValue; 155 base::ListValue* device_list = new base::ListValue;
156 // Note: names match Device stub map. 156 // Note: names match Device stub map.
157 const char kStubCellular1[] = "stub_cellular1"; 157 const char kStubCellular1[] = "stub_cellular1";
158 const char kStubCellular2[] = "stub_cellular2"; 158 const char kStubCellular2[] = "stub_cellular2";
159 device_list->Append(base::Value::CreateStringValue(kStubCellular1)); 159 device_list->Append(base::Value::CreateStringValue(kStubCellular1));
160 device_list->Append(base::Value::CreateStringValue(kStubCellular2)); 160 device_list->Append(base::Value::CreateStringValue(kStubCellular2));
161 stub_properties_.Set(flimflam::kDevicesProperty, device_list); 161 stub_properties_.Set(flimflam::kDevicesProperty, device_list);
162 } 162 }
163 163
164 virtual ~FlimflamManagerClientStubImpl() {} 164 virtual ~ShillManagerClientStubImpl() {}
165 165
166 // FlimflamManagerClient override. 166 // ShillManagerClient override.
167 virtual void SetPropertyChangedHandler( 167 virtual void SetPropertyChangedHandler(
168 const PropertyChangedHandler& handler) OVERRIDE {} 168 const PropertyChangedHandler& handler) OVERRIDE {}
169 169
170 // FlimflamManagerClient override. 170 // ShillManagerClient override.
171 virtual void ResetPropertyChangedHandler() OVERRIDE {} 171 virtual void ResetPropertyChangedHandler() OVERRIDE {}
172 172
173 // FlimflamManagerClient override. 173 // ShillManagerClient override.
174 virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE { 174 virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE {
175 MessageLoop::current()->PostTask( 175 MessageLoop::current()->PostTask(
176 FROM_HERE, base::Bind( 176 FROM_HERE, base::Bind(
177 &FlimflamManagerClientStubImpl::PassStubProperties, 177 &ShillManagerClientStubImpl::PassStubProperties,
178 weak_ptr_factory_.GetWeakPtr(), 178 weak_ptr_factory_.GetWeakPtr(),
179 callback)); 179 callback));
180 } 180 }
181 181
182 // FlimflamManagerClient override. 182 // ShillManagerClient override.
183 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE { 183 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE {
184 return new base::DictionaryValue; 184 return new base::DictionaryValue;
185 } 185 }
186 186
187 // FlimflamManagerClient override. 187 // ShillManagerClient override.
188 virtual void SetProperty(const std::string& name, 188 virtual void SetProperty(const std::string& name,
189 const base::Value& value, 189 const base::Value& value,
190 const VoidDBusMethodCallback& callback) OVERRIDE { 190 const VoidDBusMethodCallback& callback) OVERRIDE {
191 stub_properties_.Set(name, value.DeepCopy()); 191 stub_properties_.Set(name, value.DeepCopy());
192 MessageLoop::current()->PostTask(FROM_HERE, 192 MessageLoop::current()->PostTask(FROM_HERE,
193 base::Bind(callback, 193 base::Bind(callback,
194 DBUS_METHOD_CALL_SUCCESS)); 194 DBUS_METHOD_CALL_SUCCESS));
195 } 195 }
196 196
197 // FlimflamManagerClient override. 197 // ShillManagerClient override.
198 virtual void RequestScan(const std::string& type, 198 virtual void RequestScan(const std::string& type,
199 const VoidDBusMethodCallback& callback) OVERRIDE { 199 const VoidDBusMethodCallback& callback) OVERRIDE {
200 MessageLoop::current()->PostTask(FROM_HERE, 200 MessageLoop::current()->PostTask(FROM_HERE,
201 base::Bind(callback, 201 base::Bind(callback,
202 DBUS_METHOD_CALL_SUCCESS)); 202 DBUS_METHOD_CALL_SUCCESS));
203 } 203 }
204 204
205 // FlimflamManagerClient override. 205 // ShillManagerClient override.
206 virtual void EnableTechnology( 206 virtual void EnableTechnology(
207 const std::string& type, 207 const std::string& type,
208 const VoidDBusMethodCallback& callback) OVERRIDE { 208 const VoidDBusMethodCallback& callback) OVERRIDE {
209 MessageLoop::current()->PostTask(FROM_HERE, 209 MessageLoop::current()->PostTask(FROM_HERE,
210 base::Bind(callback, 210 base::Bind(callback,
211 DBUS_METHOD_CALL_SUCCESS)); 211 DBUS_METHOD_CALL_SUCCESS));
212 } 212 }
213 213
214 // FlimflamManagerClient override. 214 // ShillManagerClient override.
215 virtual void DisableTechnology( 215 virtual void DisableTechnology(
216 const std::string& type, 216 const std::string& type,
217 const VoidDBusMethodCallback& callback) OVERRIDE { 217 const VoidDBusMethodCallback& callback) OVERRIDE {
218 MessageLoop::current()->PostTask(FROM_HERE, 218 MessageLoop::current()->PostTask(FROM_HERE,
219 base::Bind(callback, 219 base::Bind(callback,
220 DBUS_METHOD_CALL_SUCCESS)); 220 DBUS_METHOD_CALL_SUCCESS));
221 } 221 }
222 222
223 // FlimflamManagerClient override. 223 // ShillManagerClient override.
224 virtual void ConfigureService( 224 virtual void ConfigureService(
225 const base::DictionaryValue& properties, 225 const base::DictionaryValue& properties,
226 const VoidDBusMethodCallback& callback) OVERRIDE { 226 const VoidDBusMethodCallback& callback) OVERRIDE {
227 MessageLoop::current()->PostTask(FROM_HERE, 227 MessageLoop::current()->PostTask(FROM_HERE,
228 base::Bind(callback, 228 base::Bind(callback,
229 DBUS_METHOD_CALL_SUCCESS)); 229 DBUS_METHOD_CALL_SUCCESS));
230 } 230 }
231 231
232 // FlimflamManagerClient override. 232 // ShillManagerClient override.
233 virtual void GetService( 233 virtual void GetService(
234 const base::DictionaryValue& properties, 234 const base::DictionaryValue& properties,
235 const ObjectPathDBusMethodCallback& callback) OVERRIDE { 235 const ObjectPathDBusMethodCallback& callback) OVERRIDE {
236 MessageLoop::current()->PostTask(FROM_HERE, 236 MessageLoop::current()->PostTask(FROM_HERE,
237 base::Bind(callback, 237 base::Bind(callback,
238 DBUS_METHOD_CALL_SUCCESS, 238 DBUS_METHOD_CALL_SUCCESS,
239 dbus::ObjectPath())); 239 dbus::ObjectPath()));
240 } 240 }
241 241
242 private: 242 private:
243 void PassStubProperties(const DictionaryValueCallback& callback) const { 243 void PassStubProperties(const DictionaryValueCallback& callback) const {
244 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_properties_); 244 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_properties_);
245 } 245 }
246 246
247 base::DictionaryValue stub_properties_; 247 base::DictionaryValue stub_properties_;
248 248
249 // Note: This should remain the last member so it'll be destroyed and 249 // Note: This should remain the last member so it'll be destroyed and
250 // invalidate its weak pointers before any other members are destroyed. 250 // invalidate its weak pointers before any other members are destroyed.
251 base::WeakPtrFactory<FlimflamManagerClientStubImpl> weak_ptr_factory_; 251 base::WeakPtrFactory<ShillManagerClientStubImpl> weak_ptr_factory_;
252 252
253 DISALLOW_COPY_AND_ASSIGN(FlimflamManagerClientStubImpl); 253 DISALLOW_COPY_AND_ASSIGN(ShillManagerClientStubImpl);
254 }; 254 };
255 255
256 } // namespace 256 } // namespace
257 257
258 FlimflamManagerClient::FlimflamManagerClient() {} 258 ShillManagerClient::ShillManagerClient() {}
259 259
260 FlimflamManagerClient::~FlimflamManagerClient() {} 260 ShillManagerClient::~ShillManagerClient() {}
261 261
262 // static 262 // static
263 FlimflamManagerClient* FlimflamManagerClient::Create( 263 ShillManagerClient* ShillManagerClient::Create(
264 DBusClientImplementationType type, 264 DBusClientImplementationType type,
265 dbus::Bus* bus) { 265 dbus::Bus* bus) {
266 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 266 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
267 return new FlimflamManagerClientImpl(bus); 267 return new ShillManagerClientImpl(bus);
268 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 268 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
269 return new FlimflamManagerClientStubImpl(); 269 return new ShillManagerClientStubImpl();
270 } 270 }
271 271
272 } // namespace chromeos 272 } // 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