Home | History | Annotate | Download | only in dbus
      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.
      4 
      5 #ifndef CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
      6 #define CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "chromeos/chromeos_export.h"
     12 #include "chromeos/dbus/shill_ipconfig_client.h"
     13 
     14 namespace chromeos {
     15 
     16 // A fake implementation of ShillIPConfigClient.
     17 class CHROMEOS_EXPORT FakeShillIPConfigClient : public ShillIPConfigClient {
     18  public:
     19   FakeShillIPConfigClient();
     20   virtual ~FakeShillIPConfigClient();
     21 
     22   // ShillIPConfigClient overrides
     23   virtual void Init(dbus::Bus* bus) OVERRIDE;
     24   virtual void AddPropertyChangedObserver(
     25       const dbus::ObjectPath& ipconfig_path,
     26       ShillPropertyChangedObserver* observer) OVERRIDE;
     27   virtual void RemovePropertyChangedObserver(
     28       const dbus::ObjectPath& ipconfig_path,
     29       ShillPropertyChangedObserver* observer) OVERRIDE;
     30   virtual void Refresh(const dbus::ObjectPath& ipconfig_path,
     31                        const VoidDBusMethodCallback& callback) OVERRIDE;
     32   virtual void GetProperties(const dbus::ObjectPath& ipconfig_path,
     33                              const DictionaryValueCallback& callback) 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<FakeShillIPConfigClient> weak_ptr_factory_;
     55 
     56   DISALLOW_COPY_AND_ASSIGN(FakeShillIPConfigClient);
     57 };
     58 
     59 }  // namespace chromeos
     60 
     61 #endif  // CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
     62