shill: cellular: Add Network.Shill.Cellular.TimeToScan metric.

BUG=chromium-os:38298
TEST=Unit tests, check for new metric under chrome://histograms

Change-Id: I4209898b49314b462cdde695bc607a051a531245
Reviewed-on: https://gerrit.chromium.org/gerrit/42196
Reviewed-by: Arman Uguray <armansito@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 73985c2..1136ca1 100644
--- a/metrics.h
+++ b/metrics.h
@@ -201,6 +201,10 @@
   static const char kMetricTimeToJoinMilliseconds[];
   static const char kMetricTimeToOnlineMilliseconds[];
   static const char kMetricTimeToPortalMilliseconds[];
+  static const char kMetricTimeToScanMilliseconds[];
+  static const int kMetricTimeToScanMillisecondsMax;
+  static const int kMetricTimeToScanMillisecondsMin;
+  static const int kMetricTimeToScanMillisecondsNumBuckets;
   static const int kTimerHistogramMillisecondsMax;
   static const int kTimerHistogramMillisecondsMin;
   static const int kTimerHistogramNumBuckets;
@@ -358,6 +362,12 @@
   // Notifies this object that a device has completed the disable process.
   void NotifyDeviceDisableFinished(int interface_index);
 
+  // Notifies this object that a device has started the scanning process.
+  void NotifyDeviceScanStarted(int interface_index);
+
+  // Notifies this object that a device has completed the scanning process.
+  void NotifyDeviceScanFinished(int interface_index);
+
   // Notifies this object that a device has started the connect process.
   void NotifyDeviceConnectStarted(int interface_index);
 
@@ -379,6 +389,7 @@
   FRIEND_TEST(MetricsTest, TimeToConfig);
   FRIEND_TEST(MetricsTest, TimeToOnline);
   FRIEND_TEST(MetricsTest, TimeToPortal);
+  FRIEND_TEST(MetricsTest, TimeToScanIgnore);
   FRIEND_TEST(MetricsTest, WiFiServiceChannel);
   FRIEND_TEST(MetricsTest, WiFiServicePostReady);
   FRIEND_TEST(WiFiMainTest, GetGeolocationObjects);
@@ -408,6 +419,7 @@
     scoped_ptr<chromeos_metrics::TimerReporter> initialization_timer;
     scoped_ptr<chromeos_metrics::TimerReporter> enable_timer;
     scoped_ptr<chromeos_metrics::TimerReporter> disable_timer;
+    scoped_ptr<chromeos_metrics::TimerReporter> scan_timer;
     scoped_ptr<chromeos_metrics::TimerReporter> connect_timer;
   };
   typedef std::map<const int, std::tr1::shared_ptr<DeviceMetrics> >
@@ -450,6 +462,11 @@
     chromeos_metrics::Timer *timer) {
     time_termination_actions_timer.reset(timer);  // Passes ownership
   }
+  void set_time_to_scan_timer(int interface_index,
+                              chromeos_metrics::TimerReporter *timer) {
+    DeviceMetrics *device_metrics = GetDeviceMetrics(interface_index);
+    device_metrics->scan_timer.reset(timer);  // Passes ownership
+  }
 
   // |library_| points to |metrics_library_| when shill runs normally.
   // However, in order to allow for unit testing, we point |library_| to a