summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjinlong.zhai <jinlong.zhai@samsung.com>2015-02-06 15:20:06 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-06 23:21:20 +0000
commit1fb332dc1f81bb05716342704b7f969af6921f3e (patch)
treeb85b8b6ed67021afc896b6e6471b34944a59868d
parentbb461c8f803f441364fdbb9f5124045771daa31a (diff)
downloadchromium_src-1fb332dc1f81bb05716342704b7f969af6921f3e.zip
chromium_src-1fb332dc1f81bb05716342704b7f969af6921f3e.tar.gz
chromium_src-1fb332dc1f81bb05716342704b7f969af6921f3e.tar.bz2
Change g_webrtc_logging_delegate from process-level to RenderThread-level
--single-process mode may happen crash in file of webrtc_logging.cc where code is CHECK(!g_webrtc_logging_delegate). The orginal code is to expect there to be only one g_webrtc_logging_delegate instance in a single render process. g_webrtc_logging_delegate is created when a RenderThreadImpl is created. But in --single-process model all RenderThreadImpl are created in browser process and so g_webrtc_logging_delegate may be created many times in a single process. Then CHECK(!g_webrtc_logging_delegate) will fail. In this patch will change g_webrtc_logging_delegate from process-level to RenderThread-Level. Since every render process will only keep one RenderThread. BUG=455573 Review URL: https://codereview.chromium.org/889313003 Cr-Commit-Position: refs/heads/master@{#315131}
-rw-r--r--AUTHORS1
-rw-r--r--content/renderer/media/webrtc_logging.cc15
2 files changed, 10 insertions, 6 deletions
diff --git a/AUTHORS b/AUTHORS
index 25d543f..a5c494c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -222,6 +222,7 @@ Jin Yang <jin.a.yang@intel.com>
Jincheol Jo <jincheol.jo@navercorp.com>
Jingwei Liu <kingweiliu@gmail.com>
Jingyi Wei <wjywbs@gmail.com>
+Jinlong Zhai <jinlong.zhai@samsung.com>
Jinho Bang <jinho.bang@samsung.com>
Jinwoo Song <jinwoo7.song@samsung.com>
Jitendra Kumar Sahoo <jitendra.ks@samsung.com>
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