shill_ipconfig_client.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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/dbus_client_implementation_type.h" 15#include "chromeos/dbus/shill_client_helper.h" 16 17namespace base { 18 19class Value; 20class DictionaryValue; 21 22} // namespace base 23 24namespace dbus { 25 26class ObjectPath; 27 28} // namespace dbus 29 30namespace chromeos { 31 32class ShillPropertyChangedObserver; 33 34// ShillIPConfigClient is used to communicate with the Shill IPConfig 35// service. All methods should be called from the origin thread which 36// initializes the DBusThreadManager instance. 37class CHROMEOS_EXPORT ShillIPConfigClient : public DBusClient { 38 public: 39 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler; 40 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback; 41 virtual ~ShillIPConfigClient(); 42 43 // Factory function, creates a new instance which is owned by the caller. 44 // For normal usage, access the singleton via DBusThreadManager::Get(). 45 static ShillIPConfigClient* Create(DBusClientImplementationType type); 46 47 // Adds a property changed |observer| for the ipconfig at |ipconfig_path|. 48 virtual void AddPropertyChangedObserver( 49 const dbus::ObjectPath& ipconfig_path, 50 ShillPropertyChangedObserver* observer) = 0; 51 52 // Removes a property changed |observer| for the ipconfig at |ipconfig_path|. 53 virtual void RemovePropertyChangedObserver( 54 const dbus::ObjectPath& ipconfig_path, 55 ShillPropertyChangedObserver* observer) = 0; 56 57 // Refreshes the active IP configuration after service property changes and 58 // renews the DHCP lease, if any. 59 virtual void Refresh(const dbus::ObjectPath& ipconfig_path, 60 const VoidDBusMethodCallback& callback) = 0; 61 62 // Calls GetProperties method. 63 // |callback| is called after the method call succeeds. 64 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 65 const DictionaryValueCallback& callback) = 0; 66 67 // DEPRECATED DO NOT USE: Calls GetProperties method and blocks until the 68 // method call finishes. The caller is responsible to delete the result. 69 // Thie method returns NULL when method call fails. 70 // 71 // TODO(hashimoto): Refactor CrosListIPConfigs to remove this method. 72 // crosbug.com/29902 73 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 74 const dbus::ObjectPath& ipconfig_path) = 0; 75 76 // Calls SetProperty method. 77 // |callback| is called after the method call succeeds. 78 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path, 79 const std::string& name, 80 const base::Value& value, 81 const VoidDBusMethodCallback& callback) = 0; 82 83 // Calls ClearProperty method. 84 // |callback| is called after the method call succeeds. 85 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path, 86 const std::string& name, 87 const VoidDBusMethodCallback& callback) = 0; 88 89 // Calls Remove method. 90 // |callback| is called after the method call succeeds. 91 virtual void Remove(const dbus::ObjectPath& ipconfig_path, 92 const VoidDBusMethodCallback& callback) = 0; 93 94 protected: 95 friend class ShillIPConfigClientTest; 96 97 // Create() should be used instead. 98 ShillIPConfigClient(); 99 100 private: 101 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClient); 102}; 103 104} // namespace chromeos 105 106#endif // CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_ 107