Bug 1309129: enable redirecting of nICEr logging to NSPR logging. r=bwc
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Tue, 11 Oct 2016 00:17:26 -0700
changeset 317988 28cab19aa7f1cd9a5801e18b580e2bc46eb4cf24
parent 317987 3ccac82a6bcff2da20a93b056a4a21663fc35652
child 317989 a2aec8df69ccee359ea1a35d299fa250414be503
push id33189
push userdrno@ohlmeier.org
push dateFri, 14 Oct 2016 20:34:09 +0000
treeherderautoland@28cab19aa7f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1309129
milestone52.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 1309129: enable redirecting of nICEr logging to NSPR logging. r=bwc MozReview-Commit-ID: ESB6F0MlKdQ
media/mtransport/build/moz.build
media/mtransport/common.build
media/mtransport/nricectx.cpp
media/mtransport/rlogconnector.cpp
media/mtransport/rlogconnector.h
media/mtransport/rlogringbuffer.cpp
media/mtransport/rlogringbuffer.h
media/mtransport/test/gtest_ringbuffer_dumper.h
media/mtransport/test/ice_unittest.cpp
media/mtransport/test/moz.build
media/mtransport/test/rlogconnector_unittest.cpp
media/mtransport/test/rlogringbuffer_unittest.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
media/webrtc/signaling/test/signaling_unittests.cpp
--- a/media/mtransport/build/moz.build
+++ b/media/mtransport/build/moz.build
@@ -7,17 +7,17 @@
 include("/ipc/chromium/chromium-config.mozbuild")
 
 EXPORTS.mtransport += [
     '../dtlsidentity.h',
     '../m_cpp_utils.h',
     '../nricectx.h',
     '../nricemediastream.h',
     '../nriceresolverfake.h',
-    '../rlogringbuffer.h',
+    '../rlogconnector.h',
     '../runnable_utils.h',
     '../sigslot.h',
     '../simpletokenbucket.h',
     '../stun_socket_filter.h',
     '../transportflow.h',
     '../transportlayer.h',
     '../transportlayerdtls.h',
     '../transportlayerice.h',
--- a/media/mtransport/common.build
+++ b/media/mtransport/common.build
@@ -9,17 +9,17 @@ mtransport_lcppsrcs = [
     'nr_socket_prsock.cpp',
     'nr_timer.cpp',
     'nricectx.cpp',
     'nricectxhandler.cpp',
     'nricemediastream.cpp',
     'nriceresolver.cpp',
     'nriceresolverfake.cpp',
     'nrinterfaceprioritizer.cpp',
-    'rlogringbuffer.cpp',
+    'rlogconnector.cpp',
     'simpletokenbucket.cpp',
     'stun_socket_filter.cpp',
     'test_nr_socket.cpp',
     'transportflow.cpp',
     'transportlayer.cpp',
     'transportlayerdtls.cpp',
     'transportlayerice.cpp',
     'transportlayerlog.cpp',
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -87,17 +87,17 @@ extern "C" {
 #include "ice_handler.h"
 }
 
 // Local includes
 #include "nricectx.h"
 #include "nricemediastream.h"
 #include "nr_socket_prsock.h"
 #include "nrinterfaceprioritizer.h"
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 #include "test_nr_socket.h"
 
 namespace mozilla {
 
 TimeStamp nr_socket_short_term_violation_time() {
   return NrSocketBase::short_term_violation_time();
 }
 
@@ -659,17 +659,17 @@ int NrIceCtx::SetNat(const RefPtr<TestNa
   return 0;
 }
 
 // ONLY USE THIS FOR TESTING. Will cause totally unpredictable and possibly very
 // bad effects if ICE is still live.
 void NrIceCtx::internal_DeinitializeGlobal() {
   NR_reg_del((char *)"stun");
   NR_reg_del((char *)"ice");
-  RLogRingBuffer::DestroyInstance();
+  RLogConnector::DestroyInstance();
   nr_crypto_vtbl = nullptr;
   initialized = false;
 }
 
 void NrIceCtx::internal_SetTimerAccelarator(int divider) {
   ctx_->test_timer_divider = divider;
 }
 
@@ -981,17 +981,17 @@ void NrIceCtx::SetConnectionState(Connec
 
   MOZ_MTLOG(ML_INFO, "NrIceCtx(" << name_ << "): state " <<
             connection_state_ << "->" << state);
   connection_state_ = state;
 
   if (connection_state_ == ICE_CTX_FAILED) {
     MOZ_MTLOG(ML_INFO, "NrIceCtx(" << name_ << "): dumping r_log ringbuffer... ");
     std::deque<std::string> logs;
-    RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+    RLogConnector::GetInstance()->GetAny(0, &logs);
     for (auto l = logs.begin(); l != logs.end(); ++l) {
       MOZ_MTLOG(ML_INFO, *l);
     }
   }
 
   SignalConnectionStateChange(this, state);
 }
 
rename from media/mtransport/rlogringbuffer.cpp
rename to media/mtransport/rlogconnector.cpp
--- a/media/mtransport/rlogringbuffer.cpp
+++ b/media/mtransport/rlogconnector.cpp
@@ -4,20 +4,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Original author: bcampen@mozilla.com */
 
 #include <cstdarg>
 
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 
 #include <deque>
 #include <string>
+#include "logging.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Move.h" // Pinch hitting for <utility> and std::move
 #include "mozilla/Mutex.h"
 #include "mozilla/Sprintf.h"
 #include <vector>
 
 extern "C" {
 #include <csi_platform.h>
@@ -25,113 +26,138 @@ extern "C" {
 #include "registry.h"
 }
 
 /* Matches r_dest_vlog type defined in r_log.h */
 static int ringbuffer_vlog(int facility,
                            int level,
                            const char *format,
                            va_list ap) {
-  MOZ_ASSERT(mozilla::RLogRingBuffer::GetInstance());
+  MOZ_ASSERT(mozilla::RLogConnector::GetInstance());
   // I could be evil and printf right into a std::string, but unless this
   // shows up in profiling, it is not worth doing.
   char temp[4096];
   VsprintfLiteral(temp, format, ap);
 
-  mozilla::RLogRingBuffer::GetInstance()->Log(std::string(temp));
+  mozilla::RLogConnector::GetInstance()->Log(level, std::string(temp));
   return 0;
 }
 
+static mozilla::LogLevel rLogLvlToMozLogLvl(int level) {
+  switch (level) {
+    case LOG_EMERG:
+    case LOG_ALERT:
+    case LOG_CRIT:
+    case LOG_ERR:
+      return mozilla::LogLevel::Error;
+    case LOG_WARNING:
+      return mozilla::LogLevel::Warning;
+    case LOG_NOTICE:
+      return mozilla::LogLevel::Info;
+    case LOG_INFO:
+      return mozilla::LogLevel::Debug;
+    case LOG_DEBUG:
+    default:
+      return mozilla::LogLevel::Verbose;
+  }
+}
+
+MOZ_MTLOG_MODULE("nicer");
+
 namespace mozilla {
 
-RLogRingBuffer* RLogRingBuffer::instance;
+RLogConnector* RLogConnector::instance;
 
-RLogRingBuffer::RLogRingBuffer()
+RLogConnector::RLogConnector()
   : log_limit_(4096),
-    mutex_("RLogRingBuffer::mutex_"),
+    mutex_("RLogConnector::mutex_"),
     disableCount_(0) {
 }
 
-RLogRingBuffer::~RLogRingBuffer() {
+RLogConnector::~RLogConnector() {
 }
 
-void RLogRingBuffer::SetLogLimit(uint32_t new_limit) {
+void RLogConnector::SetLogLimit(uint32_t new_limit) {
   OffTheBooksMutexAutoLock lock(mutex_);
   log_limit_ = new_limit;
   RemoveOld();
 }
 
-void RLogRingBuffer::Log(std::string&& log) {
-  OffTheBooksMutexAutoLock lock(mutex_);
-  if (disableCount_ == 0) {
-    AddMsg(Move(log));
+void RLogConnector::Log(int level, std::string&& log) {
+  MOZ_MTLOG(rLogLvlToMozLogLvl(level), log);
+
+  if (level <= LOG_INFO) {
+    OffTheBooksMutexAutoLock lock(mutex_);
+    if (disableCount_ == 0) {
+      AddMsg(Move(log));
+    }
   }
 }
 
-void RLogRingBuffer::AddMsg(std::string&& msg) {
+void RLogConnector::AddMsg(std::string&& msg) {
   log_messages_.push_front(Move(msg));
   RemoveOld();
 }
 
-inline void RLogRingBuffer::RemoveOld() {
+inline void RLogConnector::RemoveOld() {
   if (log_messages_.size() > log_limit_) {
     log_messages_.resize(log_limit_);
   }
 }
 
-RLogRingBuffer* RLogRingBuffer::CreateInstance() {
+RLogConnector* RLogConnector::CreateInstance() {
   if (!instance) {
-    instance = new RLogRingBuffer;
+    instance = new RLogConnector;
     NR_reg_init(NR_REG_MODE_LOCAL);
-    r_log_set_extra_destination(LOG_INFO, &ringbuffer_vlog);
+    r_log_set_extra_destination(LOG_DEBUG, &ringbuffer_vlog);
   }
   return instance;
 }
 
-RLogRingBuffer* RLogRingBuffer::GetInstance() {
+RLogConnector* RLogConnector::GetInstance() {
   return instance;
 }
 
-void RLogRingBuffer::DestroyInstance() {
+void RLogConnector::DestroyInstance() {
   // First param is ignored when passing null
-  r_log_set_extra_destination(LOG_INFO, nullptr);
+  r_log_set_extra_destination(LOG_DEBUG, nullptr);
   delete instance;
   instance = nullptr;
 }
 
 // As long as at least one PeerConnection exists in a Private Window rlog messages will not
-// be saved in the RLogRingBuffer. This is necessary because the log_messages buffer
+// be saved in the RLogConnector. This is necessary because the log_messages buffer
 // is shared across all instances of PeerConnectionImpls. There is no way with the current
 // structure of r_log to run separate logs.
 
-void RLogRingBuffer::EnterPrivateMode() {
+void RLogConnector::EnterPrivateMode() {
   OffTheBooksMutexAutoLock lock(mutex_);
   ++disableCount_;
   MOZ_ASSERT(disableCount_ != 0);
 
   if (disableCount_ == 1) {
     AddMsg("LOGGING SUSPENDED: a connection is active in a Private Window ***");
   }
 }
 
-void RLogRingBuffer::ExitPrivateMode() {
+void RLogConnector::ExitPrivateMode() {
   OffTheBooksMutexAutoLock lock(mutex_);
   MOZ_ASSERT(disableCount_ != 0);
 
   if (--disableCount_ == 0) {
     AddMsg("LOGGING RESUMED: no connections are active in a Private Window ***");
   }
 }
 
-void RLogRingBuffer::Clear() {
+void RLogConnector::Clear() {
   OffTheBooksMutexAutoLock lock(mutex_);
   log_messages_.clear();
 }
 
-void RLogRingBuffer::Filter(const std::string& substring,
+void RLogConnector::Filter(const std::string& substring,
                             uint32_t limit,
                             std::deque<std::string>* matching_logs) {
   std::vector<std::string> substrings;
   substrings.push_back(substring);
   FilterAny(substrings, limit, matching_logs);
 }
 
 inline bool AnySubstringMatches(const std::vector<std::string>& substrings,
@@ -139,17 +165,17 @@ inline bool AnySubstringMatches(const st
   for (auto sub = substrings.begin(); sub != substrings.end(); ++sub) {
     if (string.find(*sub) != std::string::npos) {
       return true;
     }
   }
   return false;
 }
 
-void RLogRingBuffer::FilterAny(const std::vector<std::string>& substrings,
+void RLogConnector::FilterAny(const std::vector<std::string>& substrings,
                                uint32_t limit,
                                std::deque<std::string>* matching_logs) {
   OffTheBooksMutexAutoLock lock(mutex_);
   if (limit == 0) {
     // At a max, all of the log messages.
     limit = log_limit_;
   }
 
rename from media/mtransport/rlogringbuffer.h
rename to media/mtransport/rlogconnector.h
--- a/media/mtransport/rlogringbuffer.h
+++ b/media/mtransport/rlogconnector.h
@@ -45,39 +45,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 /* Original author: bcampen@mozilla.com */
 
 /*
    This file defines an r_dest_vlog that can be used to accumulate log messages
    for later inspection/filtering. The intent is to use this for interactive
    debug purposes on an about:webrtc page or similar.
 */
 
-#ifndef rlogringbuffer_h__
-#define rlogringbuffer_h__
+#ifndef rlogconnector_h__
+#define rlogconnector_h__
 
 #include <stdint.h>
 
 #include <deque>
 #include <string>
 #include <vector>
 
 #include "mozilla/Mutex.h"
 
 #include "m_cpp_utils.h"
 
 namespace mozilla {
 
-class RLogRingBuffer {
+class RLogConnector {
   public:
     /*
        NB: These are not threadsafe, nor are they safe to call during static
        init/deinit.
     */
-    static RLogRingBuffer* CreateInstance();
-    static RLogRingBuffer* GetInstance();
+    static RLogConnector* CreateInstance();
+    static RLogConnector* GetInstance();
     static void DestroyInstance();
 
     /*
        Retrieves log statements that match a given substring, subject to a
        limit. |matching_logs| will be filled in chronological order (front()
        is oldest, back() is newest). |limit| == 0 will be interpreted as no
        limit.
     */
@@ -90,40 +90,40 @@ class RLogRingBuffer {
                    std::deque<std::string>* matching_logs);
 
     inline void GetAny(uint32_t limit,
                        std::deque<std::string>* matching_logs) {
       Filter("", limit, matching_logs);
     }
 
     void SetLogLimit(uint32_t new_limit);
-    void Log(std::string&& log);
+    void Log(int level, std::string&& log);
     void Clear();
 
     // Methods to signal when a PeerConnection exists in a Private Window.
     void EnterPrivateMode();
     void ExitPrivateMode();
 
   private:
-    RLogRingBuffer();
-    ~RLogRingBuffer();
+    RLogConnector();
+    ~RLogConnector();
     void RemoveOld();
     void AddMsg(std::string&& msg);
 
-    static RLogRingBuffer* instance;
+    static RLogConnector* instance;
 
     /*
      * Might be worthwhile making this a circular buffer, but I think it is
      * preferable to take up as little space as possible if no logging is
      * happening/the ringbuffer is not being used.
     */
     std::deque<std::string> log_messages_;
     /* Max size of log buffer (should we use time-depth instead/also?) */
     uint32_t log_limit_;
     OffTheBooksMutex mutex_;
     uint32_t disableCount_;
 
-    DISALLOW_COPY_ASSIGN(RLogRingBuffer);
-}; // class RLogRingBuffer
+    DISALLOW_COPY_ASSIGN(RLogConnector);
+}; // class RLogConnector
 
 } // namespace mozilla
 
-#endif // rlogringbuffer_h__
+#endif // rlogconnector_h__
--- a/media/mtransport/test/gtest_ringbuffer_dumper.h
+++ b/media/mtransport/test/gtest_ringbuffer_dumper.h
@@ -11,43 +11,43 @@
 
 #include "mozilla/SyncRunnable.h"
 
 #define GTEST_HAS_RTTI 0
 #include "gtest/gtest.h"
 
 #include "mtransport_test_utils.h"
 #include "runnable_utils.h"
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 
-using mozilla::RLogRingBuffer;
+using mozilla::RLogConnector;
 using mozilla::WrapRunnable;
 
 namespace test {
 class RingbufferDumper : public ::testing::EmptyTestEventListener {
   public:
     explicit RingbufferDumper(MtransportTestUtils* test_utils) :
       test_utils_(test_utils)
     {}
 
     void ClearRingBuffer_s() {
-      RLogRingBuffer::CreateInstance();
+      RLogConnector::CreateInstance();
       // Set limit to zero to clear the ringbuffer
-      RLogRingBuffer::GetInstance()->SetLogLimit(0);
-      RLogRingBuffer::GetInstance()->SetLogLimit(UINT32_MAX);
+      RLogConnector::GetInstance()->SetLogLimit(0);
+      RLogConnector::GetInstance()->SetLogLimit(UINT32_MAX);
     }
 
     void DestroyRingBuffer_s() {
-      RLogRingBuffer::DestroyInstance();
+      RLogConnector::DestroyInstance();
     }
 
     void DumpRingBuffer_s() {
       std::deque<std::string> logs;
       // Get an unlimited number of log lines, with no filter
-      RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+      RLogConnector::GetInstance()->GetAny(0, &logs);
       for (auto l = logs.begin(); l != logs.end(); ++l) {
         std::cout << *l << std::endl;
       }
       ClearRingBuffer_s();
     }
 
     virtual void OnTestStart(const ::testing::TestInfo& testInfo) {
       mozilla::SyncRunnable::DispatchToThread(
@@ -59,17 +59,17 @@ class RingbufferDumper : public ::testin
       mozilla::SyncRunnable::DispatchToThread(
           test_utils_->sts_target(),
           WrapRunnable(this, &RingbufferDumper::DestroyRingBuffer_s));
     }
 
     // Called after a failed assertion or a SUCCEED() invocation.
     virtual void OnTestPartResult(const ::testing::TestPartResult& testResult) {
       if (testResult.failed()) {
-        // Dump (and empty) the RLogRingBuffer
+        // Dump (and empty) the RLogConnector
         mozilla::SyncRunnable::DispatchToThread(
             test_utils_->sts_target(),
             WrapRunnable(this, &RingbufferDumper::DumpRingBuffer_s));
       }
     }
 
   private:
     MtransportTestUtils *test_utils_;
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -26,17 +26,17 @@
 #include "nsXPCOM.h"
 
 #include "nricectxhandler.h"
 #include "nricemediastream.h"
 #include "nriceresolverfake.h"
 #include "nriceresolver.h"
 #include "nrinterfaceprioritizer.h"
 #include "gtest_ringbuffer_dumper.h"
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 #include "runnable_utils.h"
 #include "stunserver.h"
 #include "nr_socket_prsock.h"
 #include "test_nr_socket.h"
 #include "ice_ctx.h"
 #include "stun_socket_filter.h"
 #include "mozilla/net/DNS.h"
 
@@ -136,19 +136,19 @@ public:
       stun_server_address_ = Resolve(stun_server_hostname_, AF_INET);
     }
 
     // Make sure NrIceCtx is in a testable state.
     test_utils_->sts_target()->Dispatch(
         WrapRunnableNM(&NrIceCtx::internal_DeinitializeGlobal),
         NS_DISPATCH_SYNC);
 
-    // NB: NrIceCtx::internal_DeinitializeGlobal destroys the RLogRingBuffer
+    // NB: NrIceCtx::internal_DeinitializeGlobal destroys the RLogConnector
     // singleton.
-    RLogRingBuffer::CreateInstance();
+    RLogConnector::CreateInstance();
 
     test_utils_->sts_target()->Dispatch(
         WrapRunnableNM(&TestStunServer::GetInstance, AF_INET),
                        NS_DISPATCH_SYNC);
     test_utils_->sts_target()->Dispatch(
         WrapRunnableNM(&TestStunServer::GetInstance, AF_INET6),
                        NS_DISPATCH_SYNC);
 
@@ -166,17 +166,17 @@ public:
         NS_DISPATCH_SYNC);
 
     test_utils_->sts_target()->Dispatch(
         WrapRunnableNM(&TestStunServer::ShutdownInstance), NS_DISPATCH_SYNC);
 
     test_utils_->sts_target()->Dispatch(
         WrapRunnableNM(&TestStunTcpServer::ShutdownInstance), NS_DISPATCH_SYNC);
 
-    RLogRingBuffer::DestroyInstance();
+    RLogConnector::DestroyInstance();
 
     MtransportTest::TearDown();
   }
 };
 
 enum TrickleMode { TRICKLE_NONE, TRICKLE_SIMULATE, TRICKLE_REAL };
 
 enum ConsentStatus { CONSENT_FRESH, CONSENT_STALE, CONSENT_EXPIRED};
@@ -3641,17 +3641,17 @@ TEST_F(WebRtcIceConnectTest, TestPollCan
 
   WaitForComplete();
   p1_->UpdateAndValidateCandidatePairs(0, &pairs1);
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
   ASSERT_TRUE(ContainsSucceededPair(pairs1));
   ASSERT_TRUE(ContainsSucceededPair(pairs2));
 }
 
-TEST_F(WebRtcIceConnectTest, TestRLogRingBuffer) {
+TEST_F(WebRtcIceConnectTest, TestRLogConnector) {
   AddStream(1);
   ASSERT_TRUE(Gather());
 
   p2_->Connect(p1_.get(), TRICKLE_NONE, false);
   p1_->Connect(p2_.get(), TRICKLE_NONE, false);
 
   std::vector<NrIceCandidatePair> pairs1;
   std::vector<NrIceCandidatePair> pairs2;
@@ -3669,25 +3669,25 @@ TEST_F(WebRtcIceConnectTest, TestRLogRin
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
   ASSERT_TRUE(ContainsSucceededPair(pairs1));
   ASSERT_TRUE(ContainsSucceededPair(pairs2));
 
   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);
+    RLogConnector::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);
+    RLogConnector::GetInstance()->Filter(substring, 0, &logs);
     ASSERT_NE(0U, logs.size());
   }
 }
 
 TEST_F(WebRtcIcePrioritizerTest, TestPrioritizer) {
   SetPriorizer(::mozilla::CreateInterfacePrioritizer());
 
   AddInterface("0", NR_INTERFACE_TYPE_VPN, 100); // unknown vpn
--- a/media/mtransport/test/moz.build
+++ b/media/mtransport/test/moz.build
@@ -6,17 +6,17 @@
 
 if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'buffered_stun_socket_unittest.cpp',
         'ice_unittest.cpp',
         'multi_tcp_socket_unittest.cpp',
         'nrappkit_unittest.cpp',
         'proxy_tunnel_socket_unittest.cpp',
-        'rlogringbuffer_unittest.cpp',
+        'rlogconnector_unittest.cpp',
         'runnable_utils_unittest.cpp',
         'simpletokenbucket_unittest.cpp',
         'sockettransportservice_unittest.cpp',
         'stunserver.cpp',
         'test_nr_socket_unittest.cpp',
         'TestSyncRunnable.cpp',
         'transport_unittests.cpp',
         'turn_unittest.cpp',
rename from media/mtransport/test/rlogringbuffer_unittest.cpp
rename to media/mtransport/test/rlogconnector_unittest.cpp
--- a/media/mtransport/test/rlogringbuffer_unittest.cpp
+++ b/media/mtransport/test/rlogconnector_unittest.cpp
@@ -1,264 +1,264 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Original author: bcampen@mozilla.com */
 
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 
 extern "C" {
 #include "registry.h"
 #include "r_log.h"
 }
 
 #define GTEST_HAS_RTTI 0
 #include "gtest/gtest.h"
 #include "gtest_utils.h"
 
 #include <deque>
 #include <string>
 #include <vector>
 
-using mozilla::RLogRingBuffer;
+using mozilla::RLogConnector;
 
 int NR_LOG_TEST = 0;
 
-class RLogRingBufferTest : public ::testing::Test {
+class RLogConnectorTest : public ::testing::Test {
   public:
-    RLogRingBufferTest() {
+    RLogConnectorTest() {
       Init();
     }
 
-    ~RLogRingBufferTest() {
+    ~RLogConnectorTest() {
       Free();
     }
 
     static void SetUpTestCase() {
       NR_reg_init(NR_REG_MODE_LOCAL);
       r_log_init();
       /* Would be nice to be able to unregister in the fixture */
-      const char* facility = "rlogringbuffer_test";
+      const char* facility = "rlogconnector_test";
       r_log_register(const_cast<char*>(facility), &NR_LOG_TEST);
     }
 
     void Init() {
-      RLogRingBuffer::CreateInstance();
+      RLogConnector::CreateInstance();
     }
 
     void Free() {
-      RLogRingBuffer::DestroyInstance();
+      RLogConnector::DestroyInstance();
     }
 
     void ReInit() {
       Free();
       Init();
     }
 };
 
-TEST_F(RLogRingBufferTest, TestGetFree) {
-  RLogRingBuffer* instance = RLogRingBuffer::GetInstance();
+TEST_F(RLogConnectorTest, TestGetFree) {
+  RLogConnector* instance = RLogConnector::GetInstance();
   ASSERT_NE(nullptr, instance);
 }
 
-TEST_F(RLogRingBufferTest, TestFilterEmpty) {
+TEST_F(RLogConnectorTest, TestFilterEmpty) {
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ(0U, logs.size());
 }
 
-TEST_F(RLogRingBufferTest, TestBasicFilter) {
+TEST_F(RLogConnectorTest, TestBasicFilter) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->Filter("Test", 0, &logs);
+  RLogConnector::GetInstance()->Filter("Test", 0, &logs);
   ASSERT_EQ(1U, logs.size());
 }
 
-TEST_F(RLogRingBufferTest, TestBasicFilterContent) {
+TEST_F(RLogConnectorTest, TestBasicFilterContent) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->Filter("Test", 0, &logs);
+  RLogConnector::GetInstance()->Filter("Test", 0, &logs);
   ASSERT_EQ("Test", logs.back());
 }
 
-TEST_F(RLogRingBufferTest, TestFilterAnyFrontMatch) {
+TEST_F(RLogConnectorTest, TestFilterAnyFrontMatch) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test");
   std::vector<std::string> substrings;
   substrings.push_back("foo");
   substrings.push_back("Test");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->FilterAny(substrings, 0, &logs);
+  RLogConnector::GetInstance()->FilterAny(substrings, 0, &logs);
   ASSERT_EQ("Test", logs.back());
 }
 
-TEST_F(RLogRingBufferTest, TestFilterAnyBackMatch) {
+TEST_F(RLogConnectorTest, TestFilterAnyBackMatch) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test");
   std::vector<std::string> substrings;
   substrings.push_back("Test");
   substrings.push_back("foo");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->FilterAny(substrings, 0, &logs);
+  RLogConnector::GetInstance()->FilterAny(substrings, 0, &logs);
   ASSERT_EQ("Test", logs.back());
 }
 
-TEST_F(RLogRingBufferTest, TestFilterAnyBothMatch) {
+TEST_F(RLogConnectorTest, TestFilterAnyBothMatch) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test");
   std::vector<std::string> substrings;
   substrings.push_back("Tes");
   substrings.push_back("est");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->FilterAny(substrings, 0, &logs);
+  RLogConnector::GetInstance()->FilterAny(substrings, 0, &logs);
   ASSERT_EQ("Test", logs.back());
 }
 
-TEST_F(RLogRingBufferTest, TestFilterAnyNeitherMatch) {
+TEST_F(RLogConnectorTest, TestFilterAnyNeitherMatch) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test");
   std::vector<std::string> substrings;
   substrings.push_back("tes");
   substrings.push_back("esT");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->FilterAny(substrings, 0, &logs);
+  RLogConnector::GetInstance()->FilterAny(substrings, 0, &logs);
   ASSERT_EQ(0U, logs.size());
 }
 
-TEST_F(RLogRingBufferTest, TestAllMatch) {
+TEST_F(RLogConnectorTest, TestAllMatch) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ(2U, logs.size());
 }
 
-TEST_F(RLogRingBufferTest, TestOrder) {
+TEST_F(RLogConnectorTest, TestOrder) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ("Test2", logs.back());
   ASSERT_EQ("Test1", logs.front());
 }
 
-TEST_F(RLogRingBufferTest, TestNoMatch) {
+TEST_F(RLogConnectorTest, TestNoMatch) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->Filter("foo", 0, &logs);
+  RLogConnector::GetInstance()->Filter("foo", 0, &logs);
   ASSERT_EQ(0U, logs.size());
 }
 
-TEST_F(RLogRingBufferTest, TestSubstringFilter) {
+TEST_F(RLogConnectorTest, TestSubstringFilter) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->Filter("t1", 0, &logs);
+  RLogConnector::GetInstance()->Filter("t1", 0, &logs);
   ASSERT_EQ(1U, logs.size());
   ASSERT_EQ("Test1", logs.back());
 }
 
-TEST_F(RLogRingBufferTest, TestFilterLimit) {
+TEST_F(RLogConnectorTest, TestFilterLimit) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   r_log(NR_LOG_TEST, LOG_INFO, "Test3");
   r_log(NR_LOG_TEST, LOG_INFO, "Test4");
   r_log(NR_LOG_TEST, LOG_INFO, "Test5");
   r_log(NR_LOG_TEST, LOG_INFO, "Test6");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->Filter("Test", 2, &logs);
+  RLogConnector::GetInstance()->Filter("Test", 2, &logs);
   ASSERT_EQ(2U, logs.size());
   ASSERT_EQ("Test6", logs.back());
   ASSERT_EQ("Test5", logs.front());
 }
 
-TEST_F(RLogRingBufferTest, TestFilterAnyLimit) {
+TEST_F(RLogConnectorTest, TestFilterAnyLimit) {
   r_log(NR_LOG_TEST, LOG_INFO, "TestOne");
   r_log(NR_LOG_TEST, LOG_INFO, "TestTwo");
   r_log(NR_LOG_TEST, LOG_INFO, "TestThree");
   r_log(NR_LOG_TEST, LOG_INFO, "TestFour");
   r_log(NR_LOG_TEST, LOG_INFO, "TestFive");
   r_log(NR_LOG_TEST, LOG_INFO, "TestSix");
   std::vector<std::string> substrings;
   // Matches Two, Three, Four, and Six
   substrings.push_back("tT");
   substrings.push_back("o");
   substrings.push_back("r");
   substrings.push_back("S");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->FilterAny(substrings, 2, &logs);
+  RLogConnector::GetInstance()->FilterAny(substrings, 2, &logs);
   ASSERT_EQ(2U, logs.size());
   ASSERT_EQ("TestSix", logs.back());
   ASSERT_EQ("TestFour", logs.front());
 }
 
-TEST_F(RLogRingBufferTest, TestLimit) {
-  RLogRingBuffer::GetInstance()->SetLogLimit(3);
+TEST_F(RLogConnectorTest, TestLimit) {
+  RLogConnector::GetInstance()->SetLogLimit(3);
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   r_log(NR_LOG_TEST, LOG_INFO, "Test3");
   r_log(NR_LOG_TEST, LOG_INFO, "Test4");
   r_log(NR_LOG_TEST, LOG_INFO, "Test5");
   r_log(NR_LOG_TEST, LOG_INFO, "Test6");
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ(3U, logs.size());
   ASSERT_EQ("Test6", logs.back());
   ASSERT_EQ("Test4", logs.front());
 }
 
-TEST_F(RLogRingBufferTest, TestLimitBulkDiscard) {
+TEST_F(RLogConnectorTest, TestLimitBulkDiscard) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   r_log(NR_LOG_TEST, LOG_INFO, "Test3");
   r_log(NR_LOG_TEST, LOG_INFO, "Test4");
   r_log(NR_LOG_TEST, LOG_INFO, "Test5");
   r_log(NR_LOG_TEST, LOG_INFO, "Test6");
-  RLogRingBuffer::GetInstance()->SetLogLimit(3);
+  RLogConnector::GetInstance()->SetLogLimit(3);
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ(3U, logs.size());
   ASSERT_EQ("Test6", logs.back());
   ASSERT_EQ("Test4", logs.front());
 }
 
-TEST_F(RLogRingBufferTest, TestIncreaseLimit) {
-  RLogRingBuffer::GetInstance()->SetLogLimit(3);
+TEST_F(RLogConnectorTest, TestIncreaseLimit) {
+  RLogConnector::GetInstance()->SetLogLimit(3);
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   r_log(NR_LOG_TEST, LOG_INFO, "Test3");
   r_log(NR_LOG_TEST, LOG_INFO, "Test4");
   r_log(NR_LOG_TEST, LOG_INFO, "Test5");
   r_log(NR_LOG_TEST, LOG_INFO, "Test6");
-  RLogRingBuffer::GetInstance()->SetLogLimit(300);
+  RLogConnector::GetInstance()->SetLogLimit(300);
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ(3U, logs.size());
   ASSERT_EQ("Test6", logs.back());
   ASSERT_EQ("Test4", logs.front());
 }
 
-TEST_F(RLogRingBufferTest, TestClear) {
+TEST_F(RLogConnectorTest, TestClear) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   r_log(NR_LOG_TEST, LOG_INFO, "Test3");
   r_log(NR_LOG_TEST, LOG_INFO, "Test4");
   r_log(NR_LOG_TEST, LOG_INFO, "Test5");
   r_log(NR_LOG_TEST, LOG_INFO, "Test6");
-  RLogRingBuffer::GetInstance()->SetLogLimit(0);
-  RLogRingBuffer::GetInstance()->SetLogLimit(4096);
+  RLogConnector::GetInstance()->SetLogLimit(0);
+  RLogConnector::GetInstance()->SetLogLimit(4096);
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ(0U, logs.size());
 }
 
-TEST_F(RLogRingBufferTest, TestReInit) {
+TEST_F(RLogConnectorTest, TestReInit) {
   r_log(NR_LOG_TEST, LOG_INFO, "Test1");
   r_log(NR_LOG_TEST, LOG_INFO, "Test2");
   r_log(NR_LOG_TEST, LOG_INFO, "Test3");
   r_log(NR_LOG_TEST, LOG_INFO, "Test4");
   r_log(NR_LOG_TEST, LOG_INFO, "Test5");
   r_log(NR_LOG_TEST, LOG_INFO, "Test6");
   ReInit();
   std::deque<std::string> logs;
-  RLogRingBuffer::GetInstance()->GetAny(0, &logs);
+  RLogConnector::GetInstance()->GetAny(0, &logs);
   ASSERT_EQ(0U, logs.size());
 }
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -90,17 +90,17 @@
 #include "mozilla/dom/PluginCrashedEvent.h"
 #include "MediaStreamList.h"
 #include "MediaStreamTrack.h"
 #include "AudioStreamTrack.h"
 #include "VideoStreamTrack.h"
 #include "nsIScriptGlobalObject.h"
 #include "MediaStreamGraph.h"
 #include "DOMMediaStream.h"
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 #include "WebrtcGlobalInformation.h"
 #include "mozilla/dom/Event.h"
 #include "nsIDOMCustomEvent.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/net/DataChannelProtocol.h"
 #endif
 
 #ifndef USE_FAKE_MEDIA_STREAMS
@@ -342,17 +342,17 @@ PeerConnectionImpl::PeerConnectionImpl(c
   , mHaveDataStream(false)
   , mAddCandidateErrorCount(0)
   , mTrickle(true) // TODO(ekr@rtfm.com): Use pref
   , mNegotiationNeeded(false)
   , mPrivateWindow(false)
 {
 #if !defined(MOZILLA_EXTERNAL_LINKAGE)
   MOZ_ASSERT(NS_IsMainThread());
-  auto log = RLogRingBuffer::CreateInstance();
+  auto log = RLogConnector::CreateInstance();
   if (aGlobal) {
     mWindow = do_QueryInterface(aGlobal->GetAsSupports());
     if (IsPrivateBrowsing(mWindow)) {
       mPrivateWindow = true;
       log->EnterPrivateMode();
     }
   }
 #endif
@@ -376,17 +376,17 @@ PeerConnectionImpl::~PeerConnectionImpl(
     print_timecard(mTimeCard);
     destroy_timecard(mTimeCard);
     mTimeCard = nullptr;
   }
   // This aborts if not on main thread (in Debug builds)
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
 #if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (mPrivateWindow) {
-    auto * log = RLogRingBuffer::GetInstance();
+    auto * log = RLogConnector::GetInstance();
     if (log) {
       log->ExitPrivateMode();
     }
     mPrivateWindow = false;
   }
 #endif
   if (PeerConnectionCtx::isActive()) {
     PeerConnectionCtx::GetInstance()->mPeerConnections.erase(mHandle);
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -734,17 +734,17 @@ private:
   static void DeliverStatsReportToPCObserver_m(
       const std::string& pcHandle,
       nsresult result,
       nsAutoPtr<RTCStatsQuery> query);
 #endif
 
   // When ICE completes, we record a bunch of statistics that outlive the
   // PeerConnection. This is just telemetry right now, but this can also
-  // include things like dumping the RLogRingbuffer somewhere, saving away
+  // include things like dumping the RLogConnector somewhere, saving away
   // an RTCStatsReport somewhere so it can be inspected after the call is over,
   // or other things.
   void RecordLongtermICEStatistics();
 
   void OnNegotiationNeeded();
   static void MaybeFireNegotiationNeeded_static(const std::string& pcHandle);
   void MaybeFireNegotiationNeeded();
 
--- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
+++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
@@ -25,17 +25,17 @@
 #include "mozilla/ErrorResult.h"
 #include "mozilla/Vector.h"
 #include "nsProxyRelease.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/RefPtr.h"
 
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 #include "runnable_utils.h"
 #include "PeerConnectionCtx.h"
 #include "PeerConnectionImpl.h"
 #include "webrtc/system_wrappers/interface/trace.h"
 
 static const char* logTag = "WebrtcGlobalInformation";
 
 namespace mozilla {
@@ -354,17 +354,17 @@ static void OnGetLogging_m(WebrtcGlobalC
   LogRequest::Delete(aRequestId);
 }
 
 static void GetLogging_s(WebrtcGlobalChild* aThisChild,
                          const int aRequestId,
                          const std::string& aPattern)
 {
   // Request log while not on the main thread.
-  RLogRingBuffer* logs = RLogRingBuffer::GetInstance();
+  RLogConnector* logs = RLogConnector::GetInstance();
   nsAutoPtr<std::deque<std::string>> result(new std::deque<std::string>);
   // Might not exist yet.
   if (logs) {
     logs->Filter(aPattern, 0, result);
   }
   // Return to main thread to complete processing.
   NS_DispatchToMainThread(WrapRunnableNM(&OnGetLogging_m,
                                          aThisChild,
@@ -553,17 +553,17 @@ RunLogQuery(const nsCString& aPattern,
                                     aPattern.get()),
                      NS_DISPATCH_NORMAL);
   return rv;
 }
 
 static void ClearLogs_s()
 {
   // Make call off main thread.
-  RLogRingBuffer* logs = RLogRingBuffer::GetInstance();
+  RLogConnector* logs = RLogConnector::GetInstance();
   if (logs) {
     logs->Clear();
   }
 }
 
 static nsresult
 RunLogClear()
 {
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -31,17 +31,17 @@
 #include "nsServiceManagerUtils.h"
 #include "mozilla/Services.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIDNSService.h"
 #include "nsQueryObject.h"
 #include "nsWeakReference.h"
 #include "nricectx.h"
-#include "rlogringbuffer.h"
+#include "rlogconnector.h"
 #include "mozilla/SyncRunnable.h"
 #include "logging.h"
 #include "stunserver.h"
 #include "stunserver.cpp"
 #ifdef SIGNALING_UNITTEST_STANDALONE
 #include "PeerConnectionImplEnumsBinding.cpp"
 #endif