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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8 #include "content/public/renderer/webrtc_log_message_delegate.h" 10 #include "content/public/renderer/webrtc_log_message_delegate.h"
9 #include "third_party/webrtc/overrides/webrtc/base/logging.h" 11 #include "third_party/webrtc/overrides/webrtc/base/logging.h"
10 12
11 namespace content { 13 namespace content {
12 14
13 // Shall only be set once and never go back to NULL. 15 // Shall only be set once within a RenderThread and never go back to NULL.
14 WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL; 16 base::LazyInstance<base::ThreadLocalPointer<WebRtcLogMessageDelegate> >::Leaky
17 g_webrtc_logging_delegate_tls = LAZY_INSTANCE_INITIALIZER;
15 18
16 void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) { 19 void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) {
17 CHECK(!g_webrtc_logging_delegate); 20 CHECK(!g_webrtc_logging_delegate_tls.Pointer()->Get());
18 CHECK(delegate); 21 CHECK(delegate);
19 22
20 g_webrtc_logging_delegate = delegate; 23 g_webrtc_logging_delegate_tls.Pointer()->Set(delegate);
21 } 24 }
22 25
23 void InitWebRtcLogging() { 26 void InitWebRtcLogging() {
24 // Log messages from Libjingle should not have timestamps. 27 // Log messages from Libjingle should not have timestamps.
25 rtc::InitDiagnosticLoggingDelegateFunction(&WebRtcLogMessage); 28 rtc::InitDiagnosticLoggingDelegateFunction(&WebRtcLogMessage);
26 } 29 }
27 30
28 void WebRtcLogMessage(const std::string& message) { 31 void WebRtcLogMessage(const std::string& message) {
29 if (g_webrtc_logging_delegate) 32 if (g_webrtc_logging_delegate_tls.Pointer()->Get())
30 g_webrtc_logging_delegate->LogMessage(message); 33 g_webrtc_logging_delegate_tls.Pointer()->Get()->LogMessage(message);
31 } 34 }
32 35
33 } // namespace content 36 } // namespace content
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698