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/command_line.h" | |
7 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "content/public/common/content_switches.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 and never go back to NULL |
16 // except for single process model. | |
14 WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL; | 17 WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL; |
15 | 18 |
16 void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) { | 19 void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) { |
17 CHECK(!g_webrtc_logging_delegate); | 20 // We will not check g_webrtc_logging_delegate in single process mode, |
21 // since g_webrtc_logging_delegate may shared by two RenderThreads in | |
22 // the same browser process. | |
23 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | |
24 switches::kSingleProcess) || | |
25 !g_webrtc_logging_delegate); | |
tommi (sloooow) - chröme
2015/03/04 13:23:20
In the case where g_webrtc_logging_delegate is not
jinlong.zhai
2015/03/05 01:50:17
In this case, it will overwrite the provious value
| |
18 CHECK(delegate); | 26 CHECK(delegate); |
19 | 27 |
20 g_webrtc_logging_delegate = delegate; | 28 g_webrtc_logging_delegate = delegate; |
21 } | 29 } |
22 | 30 |
23 void InitWebRtcLogging() { | 31 void InitWebRtcLogging() { |
24 // Log messages from Libjingle should not have timestamps. | 32 // Log messages from Libjingle should not have timestamps. |
25 rtc::InitDiagnosticLoggingDelegateFunction(&WebRtcLogMessage); | 33 rtc::InitDiagnosticLoggingDelegateFunction(&WebRtcLogMessage); |
26 } | 34 } |
27 | 35 |
28 void WebRtcLogMessage(const std::string& message) { | 36 void WebRtcLogMessage(const std::string& message) { |
29 if (g_webrtc_logging_delegate) | 37 if (g_webrtc_logging_delegate) |
30 g_webrtc_logging_delegate->LogMessage(message); | 38 g_webrtc_logging_delegate->LogMessage(message); |
31 } | 39 } |
32 | 40 |
33 } // namespace content | 41 } // namespace content |
OLD | NEW |