summaryrefslogtreecommitdiffstats
path: root/content/renderer/media/webrtc_logging.cc
diff options
context:
space:
mode:
Diffstat (limited to 'content/renderer/media/webrtc_logging.cc')
-rw-r--r--content/renderer/media/webrtc_logging.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/content/renderer/media/webrtc_logging.cc b/content/renderer/media/webrtc_logging.cc
index 17e5c57..204c2c9 100644
--- a/content/renderer/media/webrtc_logging.cc
+++ b/content/renderer/media/webrtc_logging.cc
@@ -5,19 +5,22 @@
#include "content/renderer/media/webrtc_logging.h"
#include "base/time/time.h"
+#include "base/lazy_instance.h"
+#include "base/threading/thread_local.h"
#include "content/public/renderer/webrtc_log_message_delegate.h"
#include "third_party/webrtc/overrides/webrtc/base/logging.h"
namespace content {
-// Shall only be set once and never go back to NULL.
-WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL;
+// Shall only be set once within a RenderThread and never go back to NULL.
+base::LazyInstance<base::ThreadLocalPointer<WebRtcLogMessageDelegate> >::Leaky
+ g_webrtc_logging_delegate_tls = LAZY_INSTANCE_INITIALIZER;
void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) {
- CHECK(!g_webrtc_logging_delegate);
+ CHECK(!g_webrtc_logging_delegate_tls.Pointer()->Get());
CHECK(delegate);
- g_webrtc_logging_delegate = delegate;
+ g_webrtc_logging_delegate_tls.Pointer()->Set(delegate);
}
void InitWebRtcLogging() {
@@ -26,8 +29,8 @@ void InitWebRtcLogging() {
}
void WebRtcLogMessage(const std::string& message) {
- if (g_webrtc_logging_delegate)
- g_webrtc_logging_delegate->LogMessage(message);
+ if (g_webrtc_logging_delegate_tls.Pointer()->Get())
+ g_webrtc_logging_delegate_tls.Pointer()->Get()->LogMessage(message);
}
} // namespace content