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. 4 5 #ifndef CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_STUB_H_ 6 #define CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_STUB_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "chromeos/dbus/shill_ipconfig_client.h" 12 13 namespace chromeos { 14 15 // A stub implementation of ShillIPConfigClient. 16 class ShillIPConfigClientStub : public ShillIPConfigClient { 17 public: 18 ShillIPConfigClientStub(); 19 virtual ~ShillIPConfigClientStub(); 20 21 // ShillIPConfigClient overrides: 22 virtual void AddPropertyChangedObserver( 23 const dbus::ObjectPath& ipconfig_path, 24 ShillPropertyChangedObserver* observer) OVERRIDE; 25 virtual void RemovePropertyChangedObserver( 26 const dbus::ObjectPath& ipconfig_path, 27 ShillPropertyChangedObserver* observer) OVERRIDE; 28 virtual void Refresh(const dbus::ObjectPath& ipconfig_path, 29 const VoidDBusMethodCallback& callback) OVERRIDE; 30 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 31 const DictionaryValueCallback& callback) OVERRIDE; 32 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 33 const dbus::ObjectPath& ipconfig_path) OVERRIDE; 34 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path, 35 const std::string& name, 36 const base::Value& value, 37 const VoidDBusMethodCallback& callback) OVERRIDE; 38 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path, 39 const std::string& name, 40 const VoidDBusMethodCallback& callback) OVERRIDE; 41 virtual void Remove(const dbus::ObjectPath& ipconfig_path, 42 const VoidDBusMethodCallback& callback) OVERRIDE; 43 44 private: 45 // Runs callback with |values|. 46 void PassProperties(const base::DictionaryValue* values, 47 const DictionaryValueCallback& callback) const; 48 49 // Dictionary of <ipconfig_path, property dictionaries> 50 base::DictionaryValue ipconfigs_; 51 52 // Note: This should remain the last member so it'll be destroyed and 53 // invalidate its weak pointers before any other members are destroyed. 54 base::WeakPtrFactory<ShillIPConfigClientStub> weak_ptr_factory_; 55 56 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientStub); 57 }; 58 59 } // namespace chromeos 60 61 #endif // CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_STUB_H_ 62