[ServiceWorker] Implement WebServiceWorkerContextClient::openWindow().
[chromium-blink-merge.git] / chromeos / dbus / fake_shill_device_client.h
blob57bd453f705f8c6b030df0d1bf25df7616527a9c
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 <map>
9 #include <set>
10 #include <string>
12 #include "base/basictypes.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/shill_device_client.h"
16 namespace chromeos {
18 // A fake implementation of ShillDeviceClient.
19 // Implemented: Stub cellular device for SMS testing.
20 class CHROMEOS_EXPORT FakeShillDeviceClient
21 : public ShillDeviceClient,
22 public ShillDeviceClient::TestInterface {
23 public:
24 FakeShillDeviceClient();
25 ~FakeShillDeviceClient() override;
27 // ShillDeviceClient overrides
28 void Init(dbus::Bus* bus) override;
29 void AddPropertyChangedObserver(
30 const dbus::ObjectPath& device_path,
31 ShillPropertyChangedObserver* observer) override;
32 void RemovePropertyChangedObserver(
33 const dbus::ObjectPath& device_path,
34 ShillPropertyChangedObserver* observer) override;
35 void GetProperties(const dbus::ObjectPath& device_path,
36 const DictionaryValueCallback& callback) override;
37 void ProposeScan(const dbus::ObjectPath& device_path,
38 const VoidDBusMethodCallback& callback) override;
39 void SetProperty(const dbus::ObjectPath& device_path,
40 const std::string& name,
41 const base::Value& value,
42 const base::Closure& callback,
43 const ErrorCallback& error_callback) override;
44 void ClearProperty(const dbus::ObjectPath& device_path,
45 const std::string& name,
46 const VoidDBusMethodCallback& callback) override;
47 void AddIPConfig(const dbus::ObjectPath& device_path,
48 const std::string& method,
49 const ObjectPathDBusMethodCallback& callback) override;
50 void RequirePin(const dbus::ObjectPath& device_path,
51 const std::string& pin,
52 bool require,
53 const base::Closure& callback,
54 const ErrorCallback& error_callback) override;
55 void EnterPin(const dbus::ObjectPath& device_path,
56 const std::string& pin,
57 const base::Closure& callback,
58 const ErrorCallback& error_callback) override;
59 void UnblockPin(const dbus::ObjectPath& device_path,
60 const std::string& puk,
61 const std::string& pin,
62 const base::Closure& callback,
63 const ErrorCallback& error_callback) override;
64 void ChangePin(const dbus::ObjectPath& device_path,
65 const std::string& old_pin,
66 const std::string& new_pin,
67 const base::Closure& callback,
68 const ErrorCallback& error_callback) override;
69 void Register(const dbus::ObjectPath& device_path,
70 const std::string& network_id,
71 const base::Closure& callback,
72 const ErrorCallback& error_callback) override;
73 void SetCarrier(const dbus::ObjectPath& device_path,
74 const std::string& carrier,
75 const base::Closure& callback,
76 const ErrorCallback& error_callback) override;
77 void Reset(const dbus::ObjectPath& device_path,
78 const base::Closure& callback,
79 const ErrorCallback& error_callback) override;
80 void PerformTDLSOperation(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;
85 void AddWakeOnPacketConnection(
86 const dbus::ObjectPath& device_path,
87 const net::IPEndPoint& ip_endpoint,
88 const base::Closure& callback,
89 const ErrorCallback& error_callback) override;
90 void RemoveWakeOnPacketConnection(
91 const dbus::ObjectPath& device_path,
92 const net::IPEndPoint& ip_endpoint,
93 const base::Closure& callback,
94 const ErrorCallback& error_callback) override;
95 void RemoveAllWakeOnPacketConnections(
96 const dbus::ObjectPath& device_path,
97 const base::Closure& callback,
98 const ErrorCallback& error_callback) override;
100 ShillDeviceClient::TestInterface* GetTestInterface() override;
102 // ShillDeviceClient::TestInterface overrides.
103 void AddDevice(const std::string& device_path,
104 const std::string& type,
105 const std::string& name) override;
106 void RemoveDevice(const std::string& device_path) override;
107 void ClearDevices() override;
108 void SetDeviceProperty(const std::string& device_path,
109 const std::string& name,
110 const base::Value& value) override;
111 std::string GetDevicePathForType(const std::string& type) override;
113 void set_tdls_busy_count(int count) { tdls_busy_count_ = count; }
115 private:
116 typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
118 void SetDefaultProperties();
119 void PassStubDeviceProperties(const dbus::ObjectPath& device_path,
120 const DictionaryValueCallback& callback) const;
122 // Posts a task to run a void callback with status code |status|.
123 void PostVoidCallback(const VoidDBusMethodCallback& callback,
124 DBusMethodCallStatus status);
126 void NotifyObserversPropertyChanged(const dbus::ObjectPath& device_path,
127 const std::string& property);
128 base::DictionaryValue* GetDeviceProperties(const std::string& device_path);
129 PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
131 // Dictionary of <device_name, Dictionary>.
132 base::DictionaryValue stub_devices_;
133 // Observer list for each device.
134 std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_;
136 int tdls_busy_count_; // Number of times to return InProgress for TDLS.
138 // Wake on packet connections for each device.
139 std::map<dbus::ObjectPath, std::set<net::IPEndPoint> >
140 wake_on_packet_connections_;
142 // Note: This should remain the last member so it'll be destroyed and
143 // invalidate its weak pointers before any other members are destroyed.
144 base::WeakPtrFactory<FakeShillDeviceClient> weak_ptr_factory_;
146 DISALLOW_COPY_AND_ASSIGN(FakeShillDeviceClient);
149 } // namespace chromeos
151 #endif // CHROMEOS_DBUS_FAKE_SHILL_DEVICE_CLIENT_H_