shill: Manager: Map between Technology and Provider

Create a map between Technology::Identifier and the Provider, so
most operations on provders are done either by iterating through
the map or by selecting the provider by its technology.  There
are some exceptions remaining, namely the methods called in
ConfigureServiceForProfile, which will be fixed in an upcoming
CL, and a few methods where the Manager explicitly calls
non-generic methods on the WiFiProvider.

BUG=chromium:265518
TEST=Unit tests

Change-Id: I43f217c6050d68d1f94800d08b06a7dcf1e5bafc
Reviewed-on: https://gerrit.chromium.org/gerrit/63605
Commit-Queue: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/manager.h b/manager.h
index 0b75110..538d89c 100644
--- a/manager.h
+++ b/manager.h
@@ -253,7 +253,7 @@
   }
   VPNProvider *vpn_provider() const { return vpn_provider_.get(); }
   WiFiProvider *wifi_provider() const { return wifi_provider_.get(); }
-  virtual WiMaxProvider *wimax_provider() { return &wimax_provider_; }
+  virtual WiMaxProvider *wimax_provider() { return wimax_provider_.get(); }
   PropertyStore *mutable_store() { return &store_; }
   virtual const PropertyStore &store() const { return store_; }
   GLib *glib() const { return glib_; }
@@ -491,6 +491,7 @@
 
   // For unit testing.
   void set_metrics(Metrics *metrics) { metrics_ = metrics; }
+  void UpdateProviderMapping();
 
   // Used by tests to set a mock PowerManager.  Takes ownership of
   // power_manager.
@@ -510,7 +511,7 @@
   scoped_ptr<EthernetEapProvider> ethernet_eap_provider_;
   scoped_ptr<VPNProvider> vpn_provider_;
   scoped_ptr<WiFiProvider> wifi_provider_;
-  WiMaxProvider wimax_provider_;
+  scoped_ptr<WiMaxProvider> wimax_provider_;
   // Hold pointer to singleton Resolver instance for testing purposes.
   Resolver *resolver_;
   bool running_;
@@ -521,6 +522,10 @@
   // Services that are connected appear first in the vector.  See
   // Service::Compare() for details of the sorting criteria.
   std::vector<ServiceRefPtr> services_;
+  // Map of technologies to Provider instances.  These pointers are owned
+  // by the respective scoped_reptr objects that are held over the lifetime
+  // of the Manager object.
+  std::map<Technology::Identifier, Provider *> providers_;
   // List of startup profile names to push on the profile stack on startup.
   std::vector<ProfileRefPtr> profiles_;
   ProfileRefPtr ephemeral_profile_;