Fix compilation error triggered with -Werror=sign-compare
[chromium-blink-merge.git] / chromeos / dbus / fake_shill_device_client.h
bloba168edd378eae493cb49fa8364a694fa187f60b0
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_FAKE_SHILL_DEVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_SHILL_DEVICE_CLIENT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/shill_device_client.h"
14 namespace chromeos {
16 // A fake implementation of ShillDeviceClient.
17 // Implemented: Stub cellular device for SMS testing.
18 class CHROMEOS_EXPORT FakeShillDeviceClient
19 : public ShillDeviceClient,
20 public ShillDeviceClient::TestInterface {
21 public:
22 FakeShillDeviceClient();
23 virtual ~FakeShillDeviceClient();
25 // ShillDeviceClient overrides
26 virtual void Init(dbus::Bus* bus) OVERRIDE;
27 virtual void AddPropertyChangedObserver(
28 const dbus::ObjectPath& device_path,
29 ShillPropertyChangedObserver* observer) OVERRIDE;
30 virtual void RemovePropertyChangedObserver(
31 const dbus::ObjectPath& device_path,
32 ShillPropertyChangedObserver* observer) OVERRIDE;
33 virtual void GetProperties(const dbus::ObjectPath& device_path,
34 const DictionaryValueCallback& callback) OVERRIDE;
35 virtual void ProposeScan(const dbus::ObjectPath& device_path,
36 const VoidDBusMethodCallback& callback) OVERRIDE;
37 virtual void SetProperty(const dbus::ObjectPath& device_path,
38 const std::string& name,
39 const base::Value& value,
40 const base::Closure& callback,
41 const ErrorCallback& error_callback) OVERRIDE;
42 virtual void ClearProperty(const dbus::ObjectPath& device_path,
43 const std::string& name,
44 const VoidDBusMethodCallback& callback) OVERRIDE;
45 virtual void AddIPConfig(
46 const dbus::ObjectPath& device_path,
47 const std::string& method,
48 const ObjectPathDBusMethodCallback& callback) OVERRIDE;
49 virtual void RequirePin(const dbus::ObjectPath& device_path,
50 const std::string& pin,
51 bool require,
52 const base::Closure& callback,
53 const ErrorCallback& error_callback) OVERRIDE;
54 virtual void EnterPin(const dbus::ObjectPath& device_path,
55 const std::string& pin,
56 const base::Closure& callback,
57 const ErrorCallback& error_callback) OVERRIDE;
58 virtual void UnblockPin(const dbus::ObjectPath& device_path,
59 const std::string& puk,
60 const std::string& pin,
61 const base::Closure& callback,
62 const ErrorCallback& error_callback) OVERRIDE;
63 virtual void ChangePin(const dbus::ObjectPath& device_path,
64 const std::string& old_pin,
65 const std::string& new_pin,
66 const base::Closure& callback,
67 const ErrorCallback& error_callback) OVERRIDE;
68 virtual void Register(const dbus::ObjectPath& device_path,
69 const std::string& network_id,
70 const base::Closure& callback,
71 const ErrorCallback& error_callback) OVERRIDE;
72 virtual void SetCarrier(const dbus::ObjectPath& device_path,
73 const std::string& carrier,
74 const base::Closure& callback,
75 const ErrorCallback& error_callback) OVERRIDE;
76 virtual void Reset(const dbus::ObjectPath& device_path,
77 const base::Closure& callback,
78 const ErrorCallback& error_callback) OVERRIDE;
79 virtual void PerformTDLSOperation(
80 const dbus::ObjectPath& device_path,
81 const std::string& operation,
82 const std::string& peer,
83 const StringCallback& callback,
84 const ErrorCallback& error_callback) OVERRIDE;
86 virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE;
88 // ShillDeviceClient::TestInterface overrides.
89 virtual void AddDevice(const std::string& device_path,
90 const std::string& type,
91 const std::string& name) OVERRIDE;
92 virtual void RemoveDevice(const std::string& device_path) OVERRIDE;
93 virtual void ClearDevices() OVERRIDE;
94 virtual void SetDeviceProperty(const std::string& device_path,
95 const std::string& name,
96 const base::Value& value) OVERRIDE;
97 virtual std::string GetDevicePathForType(const std::string& type) OVERRIDE;
99 void set_tdls_busy_count(int count) { tdls_busy_count_ = count; }
101 private:
102 typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
104 void SetDefaultProperties();
105 void PassStubDeviceProperties(const dbus::ObjectPath& device_path,
106 const DictionaryValueCallback& callback) const;
108 // Posts a task to run a void callback with status code |status|.
109 void PostVoidCallback(const VoidDBusMethodCallback& callback,
110 DBusMethodCallStatus status);
112 void NotifyObserversPropertyChanged(const dbus::ObjectPath& device_path,
113 const std::string& property);
114 base::DictionaryValue* GetDeviceProperties(const std::string& device_path);
115 PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
117 // Dictionary of <device_name, Dictionary>.
118 base::DictionaryValue stub_devices_;
119 // Observer list for each device.
120 std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_;
122 int tdls_busy_count_; // Number of times to return InProgress for TDLS.
124 // Note: This should remain the last member so it'll be destroyed and
125 // invalidate its weak pointers before any other members are destroyed.
126 base::WeakPtrFactory<FakeShillDeviceClient> weak_ptr_factory_;
128 DISALLOW_COPY_AND_ASSIGN(FakeShillDeviceClient);
131 } // namespace chromeos
133 #endif // CHROMEOS_DBUS_FAKE_SHILL_DEVICE_CLIENT_H_