Bug 1241690: reduce logging output for unconnected PCs. r=bwc draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Thu, 21 Jan 2016 12:04:28 -0800
changeset 324611 c2a1d73d3cb5f26df333c23dd94b35214f1d7721
parent 324406 449747fa7dd37efe062cd80b88a7e55d72004292
child 513410 06eff9c427911c9337481ef41a3b52b8208fb7ac
push id9937
push userdrno@ohlmeier.org
push dateSat, 23 Jan 2016 20:06:27 +0000
reviewersbwc
bugs1241690
milestone46.0a1
Bug 1241690: reduce logging output for unconnected PCs. r=bwc
media/mtransport/nricemediastream.cpp
media/mtransport/test/ice_unittest.cpp
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -301,16 +301,21 @@ nsresult NrIceMediaStream::GetActivePair
 
 nsresult NrIceMediaStream::GetCandidatePairs(std::vector<NrIceCandidatePair>*
                                              out_pairs) const {
   MOZ_ASSERT(out_pairs);
   if (!stream_) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  // If we haven't at least started checking then there is nothing to report
+  if (ctx_->connection_state() == NrIceCtx::ICE_CTX_INIT) {
+    return NS_OK;
+  }
+
   // Get the check_list on the peer stream (this is where the check_list
   // actually lives, not in stream_)
   nr_ice_media_stream* peer_stream;
   int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
   if (r != 0) {
     return NS_ERROR_FAILURE;
   }
 
@@ -478,16 +483,21 @@ nsresult NrIceMediaStream::GetLocalCandi
 }
 
 nsresult NrIceMediaStream::GetRemoteCandidates(
     std::vector<NrIceCandidate>* candidates) const {
   if (!stream_) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  // If we haven't at least started checking then there is nothing to report
+  if (ctx_->connection_state() == NrIceCtx::ICE_CTX_INIT) {
+    return NS_OK;
+  }
+
   nr_ice_media_stream* peer_stream;
   int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
   if (r != 0) {
     return NS_ERROR_FAILURE;
   }
 
   return GetCandidatesFromStream(peer_stream, candidates);
 }
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -2912,21 +2912,21 @@ TEST_F(IceConnectTest, TestConnectShutdo
 
 TEST_F(IceConnectTest, TestPollCandPairsBeforeConnect) {
   AddStream("first", 1);
   ASSERT_TRUE(Gather());
 
   std::vector<NrIceCandidatePair> pairs;
   nsresult res = p1_->GetCandidatePairs(0, &pairs);
   // There should be no candidate pairs prior to calling Connect()
-  ASSERT_TRUE(NS_FAILED(res));
+  ASSERT_EQ(NS_OK, res);
   ASSERT_EQ(0U, pairs.size());
 
   res = p2_->GetCandidatePairs(0, &pairs);
-  ASSERT_TRUE(NS_FAILED(res));
+  ASSERT_EQ(NS_OK, res);
   ASSERT_EQ(0U, pairs.size());
 }
 
 TEST_F(IceConnectTest, TestPollCandPairsAfterConnect) {
   AddStream("first", 1);
   ASSERT_TRUE(Gather());
   Connect();