shill: Add device metrics registration for devices without link message.

Cellular devices may be created and registered without a preceding RTNL
link message.

BUG=chromium-os:38187
TEST=Restart modemmanager and make sure shill doesn't crash

Change-Id: I13697f53a007a5c4ff67106f980380db338fba64
Reviewed-on: https://gerrit.chromium.org/gerrit/41918
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Thieu Le <thieule@chromium.org>
Tested-by: Thieu Le <thieule@chromium.org>
diff --git a/metrics.h b/metrics.h
index baa7613..9775692 100644
--- a/metrics.h
+++ b/metrics.h
@@ -331,6 +331,10 @@
   void RegisterDevice(int interface_index,
                       Technology::Identifier technology);
 
+  // Checks to see if the device has already been registered.
+  bool IsDeviceRegistered(int interface_index,
+                          Technology::Identifier technology);
+
   // Deregisters the device from this class.  All state transition timers
   // will be removed.
   void DeregisterDevice(int interface_index);
@@ -390,6 +394,7 @@
 
   struct DeviceMetrics {
     DeviceMetrics() {}
+    Technology::Identifier technology;
     scoped_ptr<chromeos_metrics::TimerReporter> initialization_timer;
     scoped_ptr<chromeos_metrics::TimerReporter> enable_timer;
     scoped_ptr<chromeos_metrics::TimerReporter> disable_timer;
@@ -417,7 +422,7 @@
                                            Service::ConnectState new_state);
   void SendServiceFailure(const Service *service);
 
-  DeviceMetrics *GetDeviceMetrics(int interface_index);
+  DeviceMetrics *GetDeviceMetrics (int interface_index) const;
 
   // For unit test purposes.
   void set_library(MetricsLibraryInterface *library);