Minor refactoring of StatsCollector.
* Make GetTimeNow a static method in the cc file.
* Make GetTransportIdFromProxy a static method as well and not a class method.

The second change is in preparation of removing the proxy_to_transport_ member variable which isn't needed and is just a copy from the session stats.

R=xians@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/20959004

git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@6696 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/app/webrtc/statscollector.cc b/app/webrtc/statscollector.cc
index dd615ab..b165841 100644
--- a/app/webrtc/statscollector.cc
+++ b/app/webrtc/statscollector.cc
@@ -236,6 +236,32 @@
 namespace {
 typedef std::map<std::string, StatsReport> StatsMap;
 
+double GetTimeNow() {
+  return talk_base::Timing::WallTimeNow() * talk_base::kNumMillisecsPerSec;
+}
+
+bool GetTransportIdFromProxy(const cricket::ProxyTransportMap& map,
+                             const std::string& proxy,
+                             std::string* transport) {
+  // TODO(hta): Remove handling of empty proxy name once tests do not use it.
+  if (proxy.empty()) {
+    transport->clear();
+    return true;
+  }
+
+  cricket::ProxyTransportMap::const_iterator found = map.find(proxy);
+  if (found == map.end()) {
+    LOG(LS_ERROR) << "No transport ID mapping for " << proxy;
+    return false;
+  }
+
+  std::ostringstream ost;
+  // Component 1 is always used for RTP.
+  ost << "Channel-" << found->second << "-1";
+  *transport = ost.str();
+  return true;
+}
+
 std::string StatsId(const std::string& type, const std::string& id) {
   return type + "_" + id;
 }
@@ -902,7 +928,8 @@
     return;
   }
   std::string transport_id;
-  if (!GetTransportIdFromProxy(session_->voice_channel()->content_name(),
+  if (!GetTransportIdFromProxy(proxy_to_transport_,
+                               session_->voice_channel()->content_name(),
                                &transport_id)) {
     LOG(LS_ERROR) << "Failed to get transport name for proxy "
                   << session_->voice_channel()->content_name();
@@ -929,7 +956,8 @@
     return;
   }
   std::string transport_id;
-  if (!GetTransportIdFromProxy(session_->video_channel()->content_name(),
+  if (!GetTransportIdFromProxy(proxy_to_transport_,
+                               session_->video_channel()->content_name(),
                                &transport_id)) {
     LOG(LS_ERROR) << "Failed to get transport name for proxy "
                   << session_->video_channel()->content_name();
@@ -946,28 +974,6 @@
   }
 }
 
-double StatsCollector::GetTimeNow() {
-  return talk_base::Timing::WallTimeNow() * talk_base::kNumMillisecsPerSec;
-}
-
-bool StatsCollector::GetTransportIdFromProxy(const std::string& proxy,
-                                             std::string* transport) {
-  // TODO(hta): Remove handling of empty proxy name once tests do not use it.
-  if (proxy.empty()) {
-    transport->clear();
-    return true;
-  }
-  if (proxy_to_transport_.find(proxy) == proxy_to_transport_.end()) {
-    LOG(LS_ERROR) << "No transport ID mapping for " << proxy;
-    return false;
-  }
-  std::ostringstream ost;
-  // Component 1 is always used for RTP.
-  ost << "Channel-" << proxy_to_transport_[proxy] << "-1";
-  *transport = ost.str();
-  return true;
-}
-
 StatsReport* StatsCollector::GetReport(const std::string& type,
                                        const std::string& id,
                                        TrackDirection direction) {
diff --git a/app/webrtc/statscollector.h b/app/webrtc/statscollector.h
index f51cee8..a444da4 100644
--- a/app/webrtc/statscollector.h
+++ b/app/webrtc/statscollector.h
@@ -82,9 +82,6 @@
   // Prepare an SSRC report for the given remote ssrc. Used internally.
   StatsReport* PrepareRemoteReport(uint32 ssrc, const std::string& transport,
                                    TrackDirection direction);
-  // Extracts the ID of a Transport belonging to an SSRC. Used internally.
-  bool GetTransportIdFromProxy(const std::string& proxy,
-                               std::string* transport_id);
 
   // Method used by the unittest to force a update of stats since UpdateStats()
   // that occur less than kMinGatherStatsPeriod number of ms apart will be
@@ -105,7 +102,6 @@
   void ExtractSessionInfo();
   void ExtractVoiceInfo();
   void ExtractVideoInfo(PeerConnectionInterface::StatsOutputLevel level);
-  double GetTimeNow();
   void BuildSsrcToTransportId();
   webrtc::StatsReport* GetOrCreateReport(const std::string& type,
                                          const std::string& id,