Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: content/renderer/media/webrtc_logging.cc

Issue 889313003: Change g_webrtc_logging_delegate from process-level to RenderThread-level (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_logging.cc
diff --git a/content/renderer/media/webrtc_logging.cc b/content/renderer/media/webrtc_logging.cc
index 17e5c5745420d96fcd68aefd64911bdf1f9c5140..204c2c99ab37e62b55a21edb83a3a9bde100ae05 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
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698