| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/webrtc_logging.h" | 5 #include "content/renderer/media/webrtc_logging.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "base/lazy_instance.h" | |
| 9 #include "base/threading/thread_local.h" | |
| 10 #include "content/public/renderer/webrtc_log_message_delegate.h" | 8 #include "content/public/renderer/webrtc_log_message_delegate.h" |
| 11 #include "third_party/webrtc/overrides/webrtc/base/logging.h" | 9 #include "third_party/webrtc/overrides/webrtc/base/logging.h" |
| 12 | 10 |
| 13 namespace content { | 11 namespace content { |
| 14 | 12 |
| 15 // Shall only be set once within a RenderThread and never go back to NULL. | 13 // Shall only be set once and never go back to NULL. |
| 16 base::LazyInstance<base::ThreadLocalPointer<WebRtcLogMessageDelegate> >::Leaky | 14 WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL; |
| 17 g_webrtc_logging_delegate_tls = LAZY_INSTANCE_INITIALIZER; | |
| 18 | 15 |
| 19 void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) { | 16 void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) { |
| 20 CHECK(!g_webrtc_logging_delegate_tls.Pointer()->Get()); | 17 CHECK(!g_webrtc_logging_delegate); |
| 21 CHECK(delegate); | 18 CHECK(delegate); |
| 22 | 19 |
| 23 g_webrtc_logging_delegate_tls.Pointer()->Set(delegate); | 20 g_webrtc_logging_delegate = delegate; |
| 24 } | 21 } |
| 25 | 22 |
| 26 void InitWebRtcLogging() { | 23 void InitWebRtcLogging() { |
| 27 // Log messages from Libjingle should not have timestamps. | 24 // Log messages from Libjingle should not have timestamps. |
| 28 rtc::InitDiagnosticLoggingDelegateFunction(&WebRtcLogMessage); | 25 rtc::InitDiagnosticLoggingDelegateFunction(&WebRtcLogMessage); |
| 29 } | 26 } |
| 30 | 27 |
| 31 void WebRtcLogMessage(const std::string& message) { | 28 void WebRtcLogMessage(const std::string& message) { |
| 32 if (g_webrtc_logging_delegate_tls.Pointer()->Get()) | 29 if (g_webrtc_logging_delegate) |
| 33 g_webrtc_logging_delegate_tls.Pointer()->Get()->LogMessage(message); | 30 g_webrtc_logging_delegate->LogMessage(message); |
| 34 } | 31 } |
| 35 | 32 |
| 36 } // namespace content | 33 } // namespace content |
| OLD | NEW |