Bug 906990 - Part 6: Add a codeword field to NrIceCandidatePair so related logging can be pulled from RLogRingBuffer. Proof of concept in ice_unittest. r=ekr
authorByron Campen [:bwc] <docfaraday@gmail.com>
Thu, 24 Oct 2013 11:45:10 -0700
changeset 167123 30a5abc9fc8c4723ffcbb710b3be22d728c129a1
parent 167122 8e3a17767287c99d7ae54658673fb54f0efaa7b1
child 167124 1cbb486b4fb73f257088ce3d3a1db974a3b79c88
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr
bugs906990
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 906990 - Part 6: Add a codeword field to NrIceCandidatePair so related logging can be pulled from RLogRingBuffer. Proof of concept in ice_unittest. r=ekr
media/mtransport/nricemediastream.cpp
media/mtransport/nricemediastream.h
media/mtransport/test/ice_unittest.cpp
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -286,16 +286,17 @@ nsresult NrIceMediaStream::GetCandidateP
       default:
         MOZ_ASSERT(0);
     }
 
     pair.priority = p1->priority;
     pair.nominated = p1->peer_nominated || p1->nominated;
     pair.selected = p1->local->component &&
                     p1->local->component->active == p1;
+    pair.codeword = p1->codeword;
 
     if (!ToNrIceCandidate(*(p1->local), &pair.local) ||
         !ToNrIceCandidate(*(p1->remote), &pair.remote)) {
       return NS_ERROR_FAILURE;
     }
 
     out_pairs->push_back(pair);
   }
--- a/media/mtransport/nricemediastream.h
+++ b/media/mtransport/nricemediastream.h
@@ -99,16 +99,17 @@ struct NrIceCandidatePair {
   // in STATE_SUCCEEDED.
   bool nominated;
   // Set if this candidate pair has been selected. Note: Since we are using
   // aggressive nomination, this could change frequently as ICE runs.
   bool selected;
   NrIceCandidate local;
   NrIceCandidate remote;
   // TODO(bcampen@mozilla.com): Is it important to put the foundation in here?
+  std::string codeword;
 };
 
 // Abstract base class for opaque values.
 class NrIceOpaque {
  public:
   virtual ~NrIceOpaque() {}
 };
 
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -102,16 +102,19 @@ bool operator==(const NrIceCandidate& lh
 }
 
 class IceCandidatePairCompare {
   public:
     bool operator()(const NrIceCandidatePair& lhs,
                     const NrIceCandidatePair& rhs) const {
       if (lhs.priority == rhs.priority) {
         if (lhs.local == rhs.local) {
+          if (lhs.remote == rhs.remote) {
+            return lhs.codeword < rhs.codeword;
+          }
           return lhs.remote < rhs.remote;
         }
         return lhs.local < rhs.local;
       }
       return lhs.priority < rhs.priority;
     }
 };
 
@@ -476,17 +479,18 @@ class IceTestPeer : public sigslot::has_
 
   void DumpCandidatePair(const NrIceCandidatePair& pair) {
       std::cerr << std::endl;
       DumpCandidate("Local", pair.local);
       DumpCandidate("Remote", pair.remote);
       std::cerr << "state = " << pair.state
                 << " priority = " << pair.priority
                 << " nominated = " << pair.nominated
-                << " selected = " << pair.selected << std::endl;
+                << " selected = " << pair.selected
+                << " codeword = " << pair.codeword << std::endl;
   }
 
   void DumpCandidatePairs(NrIceMediaStream *stream) {
     std::vector<NrIceCandidatePair> pairs;
     nsresult res = stream->GetCandidatePairs(&pairs);
     ASSERT_TRUE(NS_SUCCEEDED(res));
 
     std::cerr << "Begin list of candidate pairs [" << std::endl;
@@ -1244,22 +1248,32 @@ TEST_F(IceConnectTest, TestRLogRingBuffe
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
 
   WaitForComplete();
   p1_->UpdateAndValidateCandidatePairs(0, &pairs1);
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
   ASSERT_TRUE(ContainsSucceededPair(pairs1));
   ASSERT_TRUE(ContainsSucceededPair(pairs2));
 
-  std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->Filter("CAND-PAIR", 0, &logs);
-  std::cerr << "Dumping CAND-PAIR logging:" << std::endl;
-  for (auto i = logs.rbegin(); i != logs.rend(); ++i) {
-    std::cerr << *i << std::endl;
+  for (auto p = pairs1.begin(); p != pairs1.end(); ++p) {
+    std::deque<std::string> logs;
+    std::string substring("CAND-PAIR(");
+    substring += p->codeword;
+    RLogRingBuffer::GetInstance()->Filter(substring, 0, &logs);
+    ASSERT_NE(0U, logs.size());
   }
+
+  for (auto p = pairs2.begin(); p != pairs2.end(); ++p) {
+    std::deque<std::string> logs;
+    std::string substring("CAND-PAIR(");
+    substring += p->codeword;
+    RLogRingBuffer::GetInstance()->Filter(substring, 0, &logs);
+    ASSERT_NE(0U, logs.size());
+  }
+
   RLogRingBuffer::DestroyInstance();
 }
 
 TEST_F(PrioritizerTest, TestPrioritizer) {
   SetPriorizer(::mozilla::CreateInterfacePrioritizer());
 
   AddInterface("0", NR_INTERFACE_TYPE_VPN, 100); // unknown vpn
   AddInterface("1", NR_INTERFACE_TYPE_VPN | NR_INTERFACE_TYPE_WIRED, 100); // wired vpn