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

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

Issue 24150004: Refactor the setup of Shill*Stubs' default environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed some includes. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.cc ('k') | chromeos/dbus/shill_manager_client_stub.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_stub.h" 5 #include "chromeos/dbus/shill_device_client_stub.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"
(...skipping 21 matching lines...) Expand all
32 ShillDeviceClientStub::ShillDeviceClientStub() : weak_ptr_factory_(this) { 32 ShillDeviceClientStub::ShillDeviceClientStub() : weak_ptr_factory_(this) {
33 } 33 }
34 34
35 ShillDeviceClientStub::~ShillDeviceClientStub() { 35 ShillDeviceClientStub::~ShillDeviceClientStub() {
36 STLDeleteContainerPairSecondPointers( 36 STLDeleteContainerPairSecondPointers(
37 observer_list_.begin(), observer_list_.end()); 37 observer_list_.begin(), observer_list_.end());
38 } 38 }
39 39
40 // ShillDeviceClient overrides. 40 // ShillDeviceClient overrides.
41 41
42 void ShillDeviceClientStub::Init(dbus::Bus* bus) { 42 void ShillDeviceClientStub::Init(dbus::Bus* bus) {}
43 SetDefaultProperties();
44 }
45 43
46 void ShillDeviceClientStub::AddPropertyChangedObserver( 44 void ShillDeviceClientStub::AddPropertyChangedObserver(
47 const dbus::ObjectPath& device_path, 45 const dbus::ObjectPath& device_path,
48 ShillPropertyChangedObserver* observer){ 46 ShillPropertyChangedObserver* observer){
49 GetObserverList(device_path).AddObserver(observer); 47 GetObserverList(device_path).AddObserver(observer);
50 } 48 }
51 49
52 void ShillDeviceClientStub::RemovePropertyChangedObserver( 50 void ShillDeviceClientStub::RemovePropertyChangedObserver(
53 const dbus::ObjectPath& device_path, 51 const dbus::ObjectPath& device_path,
54 ShillPropertyChangedObserver* observer){ 52 ShillPropertyChangedObserver* observer){
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 std::string prop_type; 225 std::string prop_type;
228 if (!properties->GetStringWithoutPathExpansion( 226 if (!properties->GetStringWithoutPathExpansion(
229 flimflam::kTypeProperty, &prop_type) || 227 flimflam::kTypeProperty, &prop_type) ||
230 prop_type != type) 228 prop_type != type)
231 continue; 229 continue;
232 return iter.key(); 230 return iter.key();
233 } 231 }
234 return std::string(); 232 return std::string();
235 } 233 }
236 234
237 void ShillDeviceClientStub::SetDefaultProperties() {
238 // Add a wifi device.
239 AddDevice("stub_wifi_device1", flimflam::kTypeWifi, "/device/wifi1");
240
241 // Add a cellular device. Used in SMS stub.
242 AddDevice("stub_cellular_device1", flimflam::kTypeCellular,
243 "/device/cellular1");
244 base::DictionaryValue* properties =
245 GetDeviceProperties("stub_cellular_device1");
246 properties->SetStringWithoutPathExpansion(flimflam::kCarrierProperty,
247 shill::kCarrierSprint);
248
249 // Add a wimax device.
250 AddDevice("stub_wimax_device1", flimflam::kTypeWimax,
251 "/device/wimax1");
252 }
253
254 void ShillDeviceClientStub::PassStubDeviceProperties( 235 void ShillDeviceClientStub::PassStubDeviceProperties(
255 const dbus::ObjectPath& device_path, 236 const dbus::ObjectPath& device_path,
256 const DictionaryValueCallback& callback) const { 237 const DictionaryValueCallback& callback) const {
257 const base::DictionaryValue* device_properties = NULL; 238 const base::DictionaryValue* device_properties = NULL;
258 if (!stub_devices_.GetDictionaryWithoutPathExpansion( 239 if (!stub_devices_.GetDictionaryWithoutPathExpansion(
259 device_path.value(), &device_properties)) { 240 device_path.value(), &device_properties)) {
260 base::DictionaryValue empty_dictionary; 241 base::DictionaryValue empty_dictionary;
261 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); 242 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary);
262 return; 243 return;
263 } 244 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = 289 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
309 observer_list_.find(device_path); 290 observer_list_.find(device_path);
310 if (iter != observer_list_.end()) 291 if (iter != observer_list_.end())
311 return *(iter->second); 292 return *(iter->second);
312 PropertyObserverList* observer_list = new PropertyObserverList(); 293 PropertyObserverList* observer_list = new PropertyObserverList();
313 observer_list_[device_path] = observer_list; 294 observer_list_[device_path] = observer_list;
314 return *observer_list; 295 return *observer_list;
315 } 296 }
316 297
317 } // namespace chromeos 298 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.cc ('k') | chromeos/dbus/shill_manager_client_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698