Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / chromeos / dbus / shill_service_client_stub.h
blob507f95f08d436cf209f460d09606c4e58a4cf993
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_STUB_H_
6 #define CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_STUB_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chromeos/dbus/shill_service_client.h"
16 namespace chromeos {
18 // A stub implementation of ShillServiceClient.
19 class ShillServiceClientStub : public ShillServiceClient,
20 public ShillServiceClient::TestInterface {
21 public:
22 ShillServiceClientStub();
23 virtual ~ShillServiceClientStub();
25 // ShillServiceClient overrides.
26 virtual void AddPropertyChangedObserver(
27 const dbus::ObjectPath& service_path,
28 ShillPropertyChangedObserver* observer) OVERRIDE;
29 virtual void RemovePropertyChangedObserver(
30 const dbus::ObjectPath& service_path,
31 ShillPropertyChangedObserver* observer) OVERRIDE;
32 virtual void GetProperties(const dbus::ObjectPath& service_path,
33 const DictionaryValueCallback& callback) OVERRIDE;
34 virtual void SetProperty(const dbus::ObjectPath& service_path,
35 const std::string& name,
36 const base::Value& value,
37 const base::Closure& callback,
38 const ErrorCallback& error_callback) OVERRIDE;
39 virtual void ClearProperty(const dbus::ObjectPath& service_path,
40 const std::string& name,
41 const base::Closure& callback,
42 const ErrorCallback& error_callback) OVERRIDE;
43 virtual void ClearProperties(const dbus::ObjectPath& service_path,
44 const std::vector<std::string>& names,
45 const ListValueCallback& callback,
46 const ErrorCallback& error_callback) OVERRIDE;
47 virtual void Connect(const dbus::ObjectPath& service_path,
48 const base::Closure& callback,
49 const ErrorCallback& error_callback) OVERRIDE;
50 virtual void Disconnect(const dbus::ObjectPath& service_path,
51 const base::Closure& callback,
52 const ErrorCallback& error_callback) OVERRIDE;
53 virtual void Remove(const dbus::ObjectPath& service_path,
54 const base::Closure& callback,
55 const ErrorCallback& error_callback) OVERRIDE;
56 virtual void ActivateCellularModem(
57 const dbus::ObjectPath& service_path,
58 const std::string& carrier,
59 const base::Closure& callback,
60 const ErrorCallback& error_callback) OVERRIDE;
61 virtual void CompleteCellularActivation(
62 const dbus::ObjectPath& service_path,
63 const base::Closure& callback,
64 const ErrorCallback& error_callback) OVERRIDE;
65 virtual bool CallActivateCellularModemAndBlock(
66 const dbus::ObjectPath& service_path,
67 const std::string& carrier) OVERRIDE;
68 virtual ShillServiceClient::TestInterface* GetTestInterface() OVERRIDE;
70 // ShillServiceClient::TestInterface overrides.
71 virtual void AddService(const std::string& service_path,
72 const std::string& name,
73 const std::string& type,
74 const std::string& state,
75 bool add_to_watch_list) OVERRIDE;
76 virtual void AddServiceWithIPConfig(const std::string& service_path,
77 const std::string& name,
78 const std::string& type,
79 const std::string& state,
80 const std::string& ipconfig_path,
81 bool add_to_watch_list) OVERRIDE;
82 virtual void RemoveService(const std::string& service_path) OVERRIDE;
83 virtual void SetServiceProperty(const std::string& service_path,
84 const std::string& property,
85 const base::Value& value) OVERRIDE;
86 virtual const base::DictionaryValue* GetServiceProperties(
87 const std::string& service_path) const OVERRIDE;
88 virtual void ClearServices() OVERRIDE;
90 private:
91 typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
93 void SetDefaultProperties();
94 void PassStubServiceProperties(const dbus::ObjectPath& service_path,
95 const DictionaryValueCallback& callback);
96 void NotifyObserversPropertyChanged(const dbus::ObjectPath& service_path,
97 const std::string& property);
98 base::DictionaryValue* GetModifiableServiceProperties(
99 const std::string& service_path);
100 PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
102 base::DictionaryValue stub_services_;
103 // Observer list for each service.
104 std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_;
106 // Note: This should remain the last member so it'll be destroyed and
107 // invalidate its weak pointers before any other members are destroyed.
108 base::WeakPtrFactory<ShillServiceClientStub> weak_ptr_factory_;
110 DISALLOW_COPY_AND_ASSIGN(ShillServiceClientStub);
113 } // namespace chromeos
115 #endif // CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_STUB_H_