shill: Convert DHCP Proxy to use a model similar to Supplicant and ModemManager.
Also, don't create a DBus connection for each proxy since this doesn't work in
some event callbacks and wastes resources. Instead use a shared connection
provided by the ProxyFactory.
BUG=chromium-os:17735
TEST=unit tests, tested on device
Change-Id: I4d16b430783c1159501c0414ef3b846bce1a4c0e
Reviewed-on: http://gerrit.chromium.org/gerrit/4279
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
diff --git a/proxy_factory.h b/proxy_factory.h
index 726c2ac..3799cc8 100644
--- a/proxy_factory.h
+++ b/proxy_factory.h
@@ -8,12 +8,14 @@
#include <string>
#include <base/basictypes.h>
+#include <base/memory/scoped_ptr.h>
#include <dbus-c++/dbus.h>
#include "shill/refptr_types.h"
namespace shill {
+class DHCPProxyInterface;
class ModemManager;
class ModemManagerProxyInterface;
class SupplicantInterfaceProxyInterface;
@@ -25,26 +27,34 @@
ProxyFactory();
virtual ~ProxyFactory();
+ void Init();
+
virtual ModemManagerProxyInterface *CreateModemManagerProxy(
ModemManager *manager,
const std::string &path,
const std::string &service);
- virtual SupplicantProcessProxyInterface *CreateProcessProxy(
+ virtual SupplicantProcessProxyInterface *CreateSupplicantProcessProxy(
const char *dbus_path,
const char *dbus_addr);
- virtual SupplicantInterfaceProxyInterface *CreateInterfaceProxy(
+ virtual SupplicantInterfaceProxyInterface *CreateSupplicantInterfaceProxy(
const WiFiRefPtr &wifi,
const DBus::Path &object_path,
const char *dbus_addr);
+ virtual DHCPProxyInterface *CreateDHCPProxy(const char *service);
+
static ProxyFactory *factory() { return factory_; }
static void set_factory(ProxyFactory *factory) { factory_ = factory; }
+ DBus::Connection *connection() { return connection_.get(); }
+
private:
static ProxyFactory *factory_;
+ scoped_ptr<DBus::Connection> connection_;
+
DISALLOW_COPY_AND_ASSIGN(ProxyFactory);
};