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 3 // found in the LICENSE file. 4 5 #ifndef CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_ 6 #define CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "base/callback.h" 12 #include "chromeos/chromeos_export.h" 13 #include "chromeos/dbus/dbus_client.h" 14 #include "chromeos/dbus/shill_client_helper.h" 15 16 namespace base { 17 18 class Value; 19 class DictionaryValue; 20 21 } // namespace base 22 23 namespace dbus { 24 25 class ObjectPath; 26 27 } // namespace dbus 28 29 namespace chromeos { 30 31 class ShillPropertyChangedObserver; 32 33 // ShillIPConfigClient is used to communicate with the Shill IPConfig 34 // service. All methods should be called from the origin thread which 35 // initializes the DBusThreadManager instance. 36 class CHROMEOS_EXPORT ShillIPConfigClient : public DBusClient { 37 public: 38 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler; 39 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback; 40 virtual ~ShillIPConfigClient(); 41 42 // Factory function, creates a new instance which is owned by the caller. 43 // For normal usage, access the singleton via DBusThreadManager::Get(). 44 static ShillIPConfigClient* Create(); 45 46 // Adds a property changed |observer| for the ipconfig at |ipconfig_path|. 47 virtual void AddPropertyChangedObserver( 48 const dbus::ObjectPath& ipconfig_path, 49 ShillPropertyChangedObserver* observer) = 0; 50 51 // Removes a property changed |observer| for the ipconfig at |ipconfig_path|. 52 virtual void RemovePropertyChangedObserver( 53 const dbus::ObjectPath& ipconfig_path, 54 ShillPropertyChangedObserver* observer) = 0; 55 56 // Refreshes the active IP configuration after service property changes and 57 // renews the DHCP lease, if any. 58 virtual void Refresh(const dbus::ObjectPath& ipconfig_path, 59 const VoidDBusMethodCallback& callback) = 0; 60 61 // Calls GetProperties method. 62 // |callback| is called after the method call succeeds. 63 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 64 const DictionaryValueCallback& callback) = 0; 65 66 // Calls SetProperty method. 67 // |callback| is called after the method call succeeds. 68 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path, 69 const std::string& name, 70 const base::Value& value, 71 const VoidDBusMethodCallback& callback) = 0; 72 73 // Calls ClearProperty method. 74 // |callback| is called after the method call succeeds. 75 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path, 76 const std::string& name, 77 const VoidDBusMethodCallback& callback) = 0; 78 79 // Calls Remove method. 80 // |callback| is called after the method call succeeds. 81 virtual void Remove(const dbus::ObjectPath& ipconfig_path, 82 const VoidDBusMethodCallback& callback) = 0; 83 84 protected: 85 friend class ShillIPConfigClientTest; 86 87 // Create() should be used instead. 88 ShillIPConfigClient(); 89 90 private: 91 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClient); 92 }; 93 94 } // namespace chromeos 95 96 #endif // CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_ 97