summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-31 23:58:31 +0000
committergrunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-31 23:58:31 +0000
commit6ef98b5a0dabccfe9271697efee657316693cbee (patch)
tree7e219b96acacdbaab8c6e7d84e136a36df0a0362
parent66d5ac0c4ff1e95e240d076c798300435891b58b (diff)
downloadchromium_src-6ef98b5a0dabccfe9271697efee657316693cbee.zip
chromium_src-6ef98b5a0dabccfe9271697efee657316693cbee.tar.gz
chromium_src-6ef98b5a0dabccfe9271697efee657316693cbee.tar.bz2
Moving WebRTC logging related files from content to chrome.
BUG=229829 Review URL: https://chromiumcodereview.appspot.com/15741003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203516 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_content_browser_client.cc7
-rw-r--r--chrome/browser/media/webrtc_logging_handler_host.cc (renamed from content/browser/renderer_host/media/webrtc_logging_handler_host.cc)12
-rw-r--r--chrome/browser/media/webrtc_logging_handler_host.h (renamed from content/browser/renderer_host/media/webrtc_logging_handler_host.h)16
-rw-r--r--chrome/chrome_browser.gypi12
-rw-r--r--chrome/chrome_common.gypi8
-rw-r--r--chrome/chrome_renderer.gypi12
-rw-r--r--chrome/chrome_tests_unit.gypi7
-rw-r--r--chrome/common/common_message_generator.h4
-rw-r--r--chrome/common/media/webrtc_logging_messages.h (renamed from content/common/media/webrtc_logging_messages.h)2
-rw-r--r--chrome/common/partial_circular_buffer.cc (renamed from content/common/partial_circular_buffer.cc)8
-rw-r--r--chrome/common/partial_circular_buffer.h (renamed from content/common/partial_circular_buffer.h)15
-rw-r--r--chrome/common/partial_circular_buffer_unittest.cc (renamed from content/common/partial_circular_buffer_unittest.cc)8
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc12
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h7
-rw-r--r--chrome/renderer/media/webrtc_logging_handler_impl.cc (renamed from content/renderer/media/webrtc_logging_handler_impl.cc)50
-rw-r--r--chrome/renderer/media/webrtc_logging_handler_impl.h (renamed from content/renderer/media/webrtc_logging_handler_impl.h)34
-rw-r--r--chrome/renderer/media/webrtc_logging_handler_impl_unittest.cc (renamed from content/renderer/media/webrtc_logging_handler_impl_unittest.cc)14
-rw-r--r--chrome/renderer/media/webrtc_logging_message_filter.cc (renamed from content/renderer/media/webrtc_logging_message_filter.cc)31
-rw-r--r--chrome/renderer/media/webrtc_logging_message_filter.h (renamed from content/renderer/media/webrtc_logging_message_filter.h)21
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc7
-rw-r--r--content/common/content_message_generator.h1
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/content_common.gypi3
-rw-r--r--content/content_renderer.gypi7
-rw-r--r--content/content_tests.gypi2
-rw-r--r--content/public/renderer/content_renderer_client.h1
-rw-r--r--content/public/renderer/webrtc_log_message_delegate.h38
-rw-r--r--content/renderer/media/media_stream_dependency_factory.cc24
-rw-r--r--content/renderer/media/media_stream_dependency_factory.h2
-rw-r--r--content/renderer/media/webrtc_logging_initializer.cc37
-rw-r--r--content/renderer/media/webrtc_logging_initializer.h23
-rw-r--r--content/renderer/render_thread_impl.cc7
-rw-r--r--content/renderer/render_thread_impl.h8
-rw-r--r--third_party/libjingle/libjingle.gyp3
-rw-r--r--third_party/libjingle/overrides/logging/log_message_delegate.h27
-rw-r--r--third_party/libjingle/overrides/talk/base/logging.cc14
-rw-r--r--third_party/libjingle/overrides/talk/base/logging.h7
37 files changed, 275 insertions, 218 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 568351e..393fec0 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -181,6 +181,10 @@
#include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.h"
#endif
+#if defined(ENABLE_WEBRTC)
+#include "chrome/browser/media/webrtc_logging_handler_host.h"
+#endif
+
using base::FileDescriptor;
using content::AccessTokenStore;
using content::BrowserChildProcessHostIterator;
@@ -723,6 +727,9 @@ void ChromeContentBrowserClient::RenderProcessHostCreated(
new prerender::PrerenderMessageFilter(id, profile));
host->GetChannel()->AddFilter(new ValidationMessageMessageFilter(id));
host->GetChannel()->AddFilter(new TtsMessageFilter(id, profile));
+#if defined(ENABLE_WEBRTC)
+ host->GetChannel()->AddFilter(new WebRtcLoggingHandlerHost());
+#endif
host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
profile->IsOffTheRecord()));
diff --git a/content/browser/renderer_host/media/webrtc_logging_handler_host.cc b/chrome/browser/media/webrtc_logging_handler_host.cc
index 10e2101..c04a28a 100644
--- a/content/browser/renderer_host/media/webrtc_logging_handler_host.cc
+++ b/chrome/browser/media/webrtc_logging_handler_host.cc
@@ -1,14 +1,14 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/renderer_host/media/webrtc_logging_handler_host.h"
+#include "chrome/browser/media/webrtc_logging_handler_host.h"
#include "base/bind.h"
#include "base/logging.h"
-#include "content/common/media/webrtc_logging_messages.h"
+#include "chrome/common/media/webrtc_logging_messages.h"
-namespace content {
+using content::BrowserThread;
#if defined(OS_ANDROID)
const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB
@@ -23,7 +23,7 @@ WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() {
}
void WebRtcLoggingHandlerHost::OnChannelClosing() {
- BrowserMessageFilter::OnChannelClosing();
+ content::BrowserMessageFilter::OnChannelClosing();
}
void WebRtcLoggingHandlerHost::OnDestruct() const {
@@ -64,5 +64,3 @@ void WebRtcLoggingHandlerHost::OnOpenLog(const std::string& app_session_id,
app_url_ = app_url;
Send(new WebRtcLoggingMsg_LogOpened(foreign_memory_handle, kWebRtcLogSize));
}
-
-} // namespace content
diff --git a/content/browser/renderer_host/media/webrtc_logging_handler_host.h b/chrome/browser/media/webrtc_logging_handler_host.h
index 7ab7fba..2b735a8 100644
--- a/content/browser/renderer_host/media/webrtc_logging_handler_host.h
+++ b/chrome/browser/media/webrtc_logging_handler_host.h
@@ -1,20 +1,18 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
-#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
+#ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
+#define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
#include "base/basictypes.h"
#include "base/shared_memory.h"
#include "content/public/browser/browser_message_filter.h"
-namespace content {
-
// WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging:
// opening and closing shared memory buffer that the handler in the renderer
// process writes to.
-class WebRtcLoggingHandlerHost : public BrowserMessageFilter {
+class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
public:
WebRtcLoggingHandlerHost();
@@ -25,7 +23,7 @@ class WebRtcLoggingHandlerHost : public BrowserMessageFilter {
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) OVERRIDE;
- friend class BrowserThread;
+ friend class content::BrowserThread;
friend class base::DeleteHelper<WebRtcLoggingHandlerHost>;
virtual ~WebRtcLoggingHandlerHost();
@@ -39,6 +37,4 @@ class WebRtcLoggingHandlerHost : public BrowserMessageFilter {
DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
};
-} // namespace content
-
-#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
+#endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index f6a3b1d..2c1fa67 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -973,6 +973,8 @@
'browser/media/media_stream_devices_controller.h',
'browser/media/media_stream_infobar_delegate.cc',
'browser/media/media_stream_infobar_delegate.h',
+ 'browser/media/webrtc_logging_handler_host.cc',
+ 'browser/media/webrtc_logging_handler_host.h',
'browser/media_galleries/fileapi/filtering_file_enumerator.cc',
'browser/media_galleries/fileapi/filtering_file_enumerator.h',
'browser/media_galleries/fileapi/itunes_finder.cc',
@@ -3068,11 +3070,11 @@
['exclude', '^browser/managed_mode/'],
]
}],
- ['enable_webrtc==1', {
- 'dependencies': [
- '../third_party/libjingle/libjingle.gyp:libjingle_webrtc',
- '../third_party/libjingle/libjingle.gyp:libpeerconnection',
- ],
+ ['enable_webrtc==0', {
+ 'sources!': [
+ 'browser/media/webrtc_logging_handler_host.cc',
+ 'browser/media/webrtc_logging_handler_host.h',
+ ]
}],
],
'target_conditions': [
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 58c0057..429cc9c 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -352,6 +352,7 @@
'common/mac/objc_method_swizzle.mm',
'common/mac/objc_zombie.h',
'common/mac/objc_zombie.mm',
+ 'common/media/webrtc_logging_messages.h',
'common/metrics/entropy_provider.cc',
'common/metrics/entropy_provider.h',
'common/metrics/metrics_log_base.cc',
@@ -380,6 +381,8 @@
'common/omaha_query_params/omaha_query_params.h',
'common/omnibox_focus_state.h',
'common/one_click_signin_messages.h',
+ 'common/partial_circular_buffer.cc',
+ 'common/partial_circular_buffer.h',
'common/pepper_flash.cc',
'common/pepper_flash.h',
'common/pref_names_util.cc',
@@ -573,6 +576,11 @@
'<(DEPTH)/base/third_party/nspr/nspr.gyp:nspr',
],
}],
+ ['enable_webrtc==0', {
+ 'sources!': [
+ 'common/media/webrtc_logging_messages.h',
+ ]
+ }],
],
'target_conditions': [
['OS == "ios"', {
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 032f414..653c1e1 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -145,6 +145,10 @@
'renderer/isolated_world_ids.h',
'renderer/loadtimes_extension_bindings.cc',
'renderer/loadtimes_extension_bindings.h',
+ 'renderer/media/webrtc_logging_handler_impl.cc',
+ 'renderer/media/webrtc_logging_handler_impl.h',
+ 'renderer/media/webrtc_logging_message_filter.cc',
+ 'renderer/media/webrtc_logging_message_filter.h',
'renderer/net/net_error_helper.cc',
'renderer/net/net_error_helper.h',
'renderer/net/predictor_queue.cc',
@@ -348,6 +352,14 @@
['exclude', '^renderer/safe_browsing/'],
],
}],
+ ['enable_webrtc==0', {
+ 'sources!': [
+ 'renderer/media/webrtc_logging_handler_impl.cc',
+ 'renderer/media/webrtc_logging_handler_impl.h',
+ 'renderer/media/webrtc_logging_message_filter.cc',
+ 'renderer/media/webrtc_logging_message_filter.h',
+ ],
+ }],
['OS=="mac"', {
'dependencies': [
'../third_party/mach_override/mach_override.gyp:mach_override',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 915cb64..b98e7c8 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1671,6 +1671,7 @@
'common/multi_process_lock_unittest.cc',
'common/net/net_error_tracker_unittest.cc',
'common/net/x509_certificate_model_unittest.cc',
+ 'common/partial_circular_buffer_unittest.cc',
'common/pref_names_util_unittest.cc',
'common/service_process_util_unittest.cc',
'common/switch_utils_unittest.cc',
@@ -1687,6 +1688,7 @@
'renderer/extensions/json_schema_unittest.cc',
'renderer/extensions/module_system_unittest.cc',
'renderer/extensions/renderer_permissions_policy_delegate_unittest.cc',
+ 'renderer/media/webrtc_logging_handler_impl_unittest.cc',
'renderer/net/predictor_queue_unittest.cc',
'renderer/net/renderer_predictor_unittest.cc',
'renderer/plugins/plugin_uma_unittest.cc',
@@ -2049,6 +2051,11 @@
'browser/ui/startup/session_crashed_infobar_delegate_unittest.cc',
],
}],
+ ['enable_webrtc==0', {
+ 'sources!': [
+ 'renderer/media/webrtc_logging_handler_impl_unittest.cc',
+ ],
+ }],
['chromeos==1', {
'sources!': [
'browser/password_manager/native_backend_gnome_x_unittest.cc',
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index de8ab77..dce23eb 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -17,3 +17,7 @@
#include "chrome/common/spellcheck_messages.h"
#include "chrome/common/tts_messages.h"
#include "chrome/common/validation_message_messages.h"
+
+#if defined(ENABLE_WEBRTC)
+#include "chrome/common/media/webrtc_logging_messages.h"
+#endif
diff --git a/content/common/media/webrtc_logging_messages.h b/chrome/common/media/webrtc_logging_messages.h
index 8e893ab..5bcf8f9 100644
--- a/content/common/media/webrtc_logging_messages.h
+++ b/chrome/common/media/webrtc_logging_messages.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/content/common/partial_circular_buffer.cc b/chrome/common/partial_circular_buffer.cc
index cba2243..f6e0b70 100644
--- a/content/common/partial_circular_buffer.cc
+++ b/chrome/common/partial_circular_buffer.cc
@@ -1,15 +1,13 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/partial_circular_buffer.h"
+#include "chrome/common/partial_circular_buffer.h"
#include <algorithm>
#include "base/logging.h"
-namespace content {
-
namespace {
inline uint32 Min3(uint32 a, uint32 b, uint32 c) {
@@ -162,5 +160,3 @@ void PartialCircularBuffer::DoWrite(void* dest, const void* src, uint32 num) {
std::min(buffer_data_->total_written + num, data_size_);
buffer_data_->end_position = position_;
}
-
-} // namespace content
diff --git a/content/common/partial_circular_buffer.h b/chrome/common/partial_circular_buffer.h
index b692ac5..582487c 100644
--- a/content/common/partial_circular_buffer.h
+++ b/chrome/common/partial_circular_buffer.h
@@ -1,15 +1,12 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_COMMON_PARTIAL_CIRCULAR_BUFFER_H_
-#define CONTENT_COMMON_PARTIAL_CIRCULAR_BUFFER_H_
+#ifndef CHROME_COMMON_PARTIAL_CIRCULAR_BUFFER_H_
+#define CHROME_COMMON_PARTIAL_CIRCULAR_BUFFER_H_
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
-#include "content/common/content_export.h"
-
-namespace content {
// A wrapper around a memory buffer that allows circular read and write with a
// selectable wrapping position. Buffer layout (after wrap; H is header):
@@ -25,7 +22,7 @@ namespace content {
// - End position of buffer. (If the last byte is at x, this will be x + 1.)
// Users of wrappers around the same underlying buffer must ensure that writing
// is finished before reading is started.
-class CONTENT_EXPORT PartialCircularBuffer {
+class PartialCircularBuffer {
public:
// Use for reading. |buffer_size| is in bytes and must be larger than the
// header size (see above).
@@ -65,6 +62,4 @@ class CONTENT_EXPORT PartialCircularBuffer {
uint32 total_read_;
};
-} // namespace content
-
-#endif // CONTENT_COMMON_PARTIAL_CIRCULAR_BUFFER_H_
+#endif // CHROME_COMMON_PARTIAL_CIRCULAR_BUFFER_H_
diff --git a/content/common/partial_circular_buffer_unittest.cc b/chrome/common/partial_circular_buffer_unittest.cc
index 5925667..f176e82 100644
--- a/content/common/partial_circular_buffer_unittest.cc
+++ b/chrome/common/partial_circular_buffer_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,11 +13,9 @@
// data is the same since the offset at each wrap is always the same.
#include "base/memory/scoped_ptr.h"
-#include "content/common/partial_circular_buffer.h"
+#include "chrome/common/partial_circular_buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace content {
-
const uint32 kWrapPosition = 20;
const uint8 kInputData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
const uint8 kOutputRefDataWrap[] =
@@ -134,5 +132,3 @@ TEST_F(PartialCircularBufferTest, WrapOnceSmallerOutputBuffer) {
EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data)));
}
-
-} // namespace content
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 14c0cd0..092b48f 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -100,6 +100,10 @@
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+#if defined(ENABLE_WEBRTC)
+#include "chrome/renderer/media/webrtc_logging_message_filter.h"
+#endif
+
using autofill::AutofillAgent;
using autofill::PasswordAutofillAgent;
using autofill::PasswordGenerationManager;
@@ -223,6 +227,10 @@ void ChromeContentRendererClient::RenderThreadStarted() {
phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create());
#endif
prerender_dispatcher_.reset(new prerender::PrerenderDispatcher());
+#if defined(ENABLE_WEBRTC)
+ webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter(
+ content::RenderThread::Get()->GetIOMessageLoopProxy());
+#endif
RenderThread* thread = RenderThread::Get();
@@ -235,6 +243,10 @@ void ChromeContentRendererClient::RenderThreadStarted() {
thread->AddObserver(visited_link_slave_.get());
thread->AddObserver(prerender_dispatcher_.get());
+#if defined(ENABLE_WEBRTC)
+ thread->AddFilter(webrtc_logging_message_filter_.get());
+#endif
+
thread->RegisterExtension(extensions_v8::ExternalExtension::Get());
thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get());
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index 02f620b..4edcfb8 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -48,6 +48,10 @@ namespace WebKit {
class WebSecurityOrigin;
}
+#if defined(ENABLE_WEBRTC)
+class WebRtcLoggingMessageFilter;
+#endif
+
namespace chrome {
class ChromeContentRendererClient : public content::ContentRendererClient {
@@ -184,6 +188,9 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
+#if defined(ENABLE_WEBRTC)
+ scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
+#endif
};
} // namespace chrome
diff --git a/content/renderer/media/webrtc_logging_handler_impl.cc b/chrome/renderer/media/webrtc_logging_handler_impl.cc
index 9581a85..b46ec73 100644
--- a/content/renderer/media/webrtc_logging_handler_impl.cc
+++ b/chrome/renderer/media/webrtc_logging_handler_impl.cc
@@ -1,28 +1,39 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/renderer/media/webrtc_logging_handler_impl.h"
+#include "chrome/renderer/media/webrtc_logging_handler_impl.h"
#include "base/logging.h"
#include "base/message_loop_proxy.h"
-#include "content/common/partial_circular_buffer.h"
-#include "content/renderer/media/webrtc_logging_message_filter.h"
-#include "third_party/libjingle/overrides/talk/base/logging.h"
-
-namespace content {
+#include "chrome/common/partial_circular_buffer.h"
+#include "chrome/renderer/media/webrtc_logging_message_filter.h"
WebRtcLoggingHandlerImpl::WebRtcLoggingHandlerImpl(
- const scoped_refptr<base::MessageLoopProxy>& io_message_loop)
- : io_message_loop_(io_message_loop) {
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop,
+ WebRtcLoggingMessageFilter* message_filter)
+ : io_message_loop_(io_message_loop),
+ message_filter_(message_filter),
+ log_initialized_(false) {
+ content::InitWebRtcLoggingDelegate(this);
}
WebRtcLoggingHandlerImpl::~WebRtcLoggingHandlerImpl() {
DCHECK(CalledOnValidThread());
}
+void WebRtcLoggingHandlerImpl::InitLogging(const std::string& app_session_id,
+ const std::string& app_url) {
+ DCHECK(CalledOnValidThread());
+
+ if (!log_initialized_) {
+ log_initialized_ = true;
+ message_filter_->InitLogging(app_session_id, app_url);
+ }
+}
+
void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) {
- if (!io_message_loop_->BelongsToCurrentThread()) {
+ if (!CalledOnValidThread()) {
io_message_loop_->PostTask(
FROM_HERE, base::Bind(
&WebRtcLoggingHandlerImpl::LogMessage,
@@ -31,13 +42,16 @@ void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) {
return;
}
- circular_buffer_->Write(message.c_str(), message.length());
- const char eol = '\n';
- circular_buffer_->Write(&eol, 1);
+ if (circular_buffer_) {
+ circular_buffer_->Write(message.c_str(), message.length());
+ const char eol = '\n';
+ circular_buffer_->Write(&eol, 1);
+ }
}
void WebRtcLoggingHandlerImpl::OnFilterRemoved() {
DCHECK(CalledOnValidThread());
+ message_filter_ = NULL;
}
void WebRtcLoggingHandlerImpl::OnLogOpened(
@@ -48,11 +62,9 @@ void WebRtcLoggingHandlerImpl::OnLogOpened(
shared_memory_.reset(new base::SharedMemory(handle, false));
CHECK(shared_memory_->Map(length));
circular_buffer_.reset(
- new content::PartialCircularBuffer(shared_memory_->memory(),
- length,
- length / 2));
-
- talk_base::InitDiagnosticLoggingDelegate(this);
+ new PartialCircularBuffer(shared_memory_->memory(),
+ length,
+ length / 2));
}
void WebRtcLoggingHandlerImpl::OnOpenLogFailed() {
@@ -61,5 +73,3 @@ void WebRtcLoggingHandlerImpl::OnOpenLogFailed() {
// TODO(grunell): Implement.
NOTIMPLEMENTED();
}
-
-} // namespace content
diff --git a/content/renderer/media/webrtc_logging_handler_impl.h b/chrome/renderer/media/webrtc_logging_handler_impl.h
index ff9b4f3..5a98143 100644
--- a/content/renderer/media/webrtc_logging_handler_impl.h
+++ b/chrome/renderer/media/webrtc_logging_handler_impl.h
@@ -1,24 +1,20 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_LOGGING_HANDLER_IMPL_H_
-#define CONTENT_RENDERER_MEDIA_WEBRTC_LOGGING_HANDLER_IMPL_H_
+#ifndef CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_HANDLER_IMPL_H_
+#define CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_HANDLER_IMPL_H_
#include <string>
#include "base/shared_memory.h"
-#include "base/threading/non_thread_safe.h"
-#include "content/common/content_export.h"
+#include "content/public/renderer/webrtc_log_message_delegate.h"
#include "ipc/ipc_channel_proxy.h"
-#include "third_party/libjingle/overrides/logging/log_message_delegate.h"
namespace base {
class MessageLoopProxy;
}
-namespace content {
-
class PartialCircularBuffer;
class WebRtcLoggingMessageFilter;
@@ -26,16 +22,19 @@ class WebRtcLoggingMessageFilter;
// render process, owned by WebRtcLoggingMessageFilter. It communicates with
// WebRtcLoggingHandlerHost and receives logging messages from libjingle and
// writes them to a shared memory buffer.
-class CONTENT_EXPORT WebRtcLoggingHandlerImpl
- : public NON_EXPORTED_BASE(talk_base::LogMessageDelegate),
- public NON_EXPORTED_BASE(base::NonThreadSafe) {
+class WebRtcLoggingHandlerImpl
+ : public content::WebRtcLogMessageDelegate,
+ public base::NonThreadSafe {
public:
WebRtcLoggingHandlerImpl(
- const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop,
+ WebRtcLoggingMessageFilter* message_filter);
virtual ~WebRtcLoggingHandlerImpl();
- // talk_base::LogMessageDelegate implementation.
+ // content::WebRtcLogMessageDelegate implementation.
+ virtual void InitLogging(const std::string& app_session_id,
+ const std::string& app_url) OVERRIDE;
virtual void LogMessage(const std::string& message) OVERRIDE;
void OnFilterRemoved();
@@ -46,11 +45,12 @@ class CONTENT_EXPORT WebRtcLoggingHandlerImpl
private:
scoped_refptr<base::MessageLoopProxy> io_message_loop_;
scoped_ptr<base::SharedMemory> shared_memory_;
- scoped_ptr<content::PartialCircularBuffer> circular_buffer_;
+ scoped_ptr<PartialCircularBuffer> circular_buffer_;
+
+ WebRtcLoggingMessageFilter* message_filter_;
+ bool log_initialized_;
DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerImpl);
};
-} // namespace content
-
-#endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOGGING_HANDLER_IMPL_H_
+#endif // CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_HANDLER_IMPL_H_
diff --git a/content/renderer/media/webrtc_logging_handler_impl_unittest.cc b/chrome/renderer/media/webrtc_logging_handler_impl_unittest.cc
index fc70baa..b12f622 100644
--- a/content/renderer/media/webrtc_logging_handler_impl_unittest.cc
+++ b/chrome/renderer/media/webrtc_logging_handler_impl_unittest.cc
@@ -1,16 +1,14 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "base/process_util.h"
-#include "content/common/partial_circular_buffer.h"
-#include "content/renderer/media/webrtc_logging_handler_impl.h"
+#include "chrome/common/partial_circular_buffer.h"
+#include "chrome/renderer/media/webrtc_logging_handler_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace content {
-
TEST(WebRtcLoggingHandlerImplTest, Basic) {
const uint32 kTestLogSize = 1024; // 1 KB
const char kTestString[] = "abcdefghijklmnopqrstuvwxyz";
@@ -18,7 +16,7 @@ TEST(WebRtcLoggingHandlerImplTest, Basic) {
base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
scoped_ptr<WebRtcLoggingHandlerImpl> logging_handler(
- new WebRtcLoggingHandlerImpl(message_loop.message_loop_proxy()));
+ new WebRtcLoggingHandlerImpl(message_loop.message_loop_proxy(), NULL));
base::SharedMemory shared_memory;
ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(kTestLogSize));
@@ -30,7 +28,7 @@ TEST(WebRtcLoggingHandlerImplTest, Basic) {
logging_handler->LogMessage(kTestString);
logging_handler->LogMessage(kTestString);
- content::PartialCircularBuffer read_pcb(
+ PartialCircularBuffer read_pcb(
reinterpret_cast<uint8*>(shared_memory.memory()), kTestLogSize);
// Size is calculated as (sizeof(kTestString) - 1 for terminating null
@@ -46,5 +44,3 @@ TEST(WebRtcLoggingHandlerImplTest, Basic) {
ref_output.append("\n");
EXPECT_STREQ(ref_output.c_str(), read_buffer);
}
-
-} // namespace content
diff --git a/content/renderer/media/webrtc_logging_message_filter.cc b/chrome/renderer/media/webrtc_logging_message_filter.cc
index 155de27..f12c695 100644
--- a/content/renderer/media/webrtc_logging_message_filter.cc
+++ b/chrome/renderer/media/webrtc_logging_message_filter.cc
@@ -1,23 +1,24 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/renderer/media/webrtc_logging_message_filter.h"
+#include "chrome/renderer/media/webrtc_logging_message_filter.h"
#include "base/logging.h"
#include "base/message_loop_proxy.h"
-#include "content/common/media/webrtc_logging_messages.h"
-#include "content/renderer/media/webrtc_logging_handler_impl.h"
+#include "chrome/common/media/webrtc_logging_messages.h"
+#include "chrome/renderer/media/webrtc_logging_handler_impl.h"
#include "ipc/ipc_logging.h"
-#include "third_party/libjingle/overrides/talk/base/logging.h"
-
-namespace content {
WebRtcLoggingMessageFilter::WebRtcLoggingMessageFilter(
const scoped_refptr<base::MessageLoopProxy>& io_message_loop)
: logging_handler_(NULL),
io_message_loop_(io_message_loop),
channel_(NULL) {
+ io_message_loop_->PostTask(
+ FROM_HERE, base::Bind(
+ &WebRtcLoggingMessageFilter::CreateLoggingHandler,
+ base::Unretained(this)));
}
WebRtcLoggingMessageFilter::~WebRtcLoggingMessageFilter() {
@@ -53,27 +54,27 @@ void WebRtcLoggingMessageFilter::OnChannelClosing() {
}
void WebRtcLoggingMessageFilter::InitLogging(
- WebRtcLoggingHandlerImpl* logging_handler,
const std::string& app_session_id,
const std::string& app_url) {
DCHECK(io_message_loop_->BelongsToCurrentThread());
- DCHECK(!logging_handler_);
- logging_handler_ = logging_handler;
Send(new WebRtcLoggingMsg_OpenLog(app_session_id, app_url));
}
+void WebRtcLoggingMessageFilter::CreateLoggingHandler() {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ logging_handler_ = new WebRtcLoggingHandlerImpl(io_message_loop_, this);
+}
+
void WebRtcLoggingMessageFilter::OnLogOpened(
base::SharedMemoryHandle handle,
uint32 length) {
DCHECK(io_message_loop_->BelongsToCurrentThread());
- if (logging_handler_)
- logging_handler_->OnLogOpened(handle, length);
+ logging_handler_->OnLogOpened(handle, length);
}
void WebRtcLoggingMessageFilter::OnOpenLogFailed() {
DCHECK(io_message_loop_->BelongsToCurrentThread());
- if (logging_handler_)
- logging_handler_->OnOpenLogFailed();
+ logging_handler_->OnOpenLogFailed();
}
void WebRtcLoggingMessageFilter::Send(IPC::Message* message) {
@@ -85,5 +86,3 @@ void WebRtcLoggingMessageFilter::Send(IPC::Message* message) {
channel_->Send(message);
}
}
-
-} // namespace content
diff --git a/content/renderer/media/webrtc_logging_message_filter.h b/chrome/renderer/media/webrtc_logging_message_filter.h
index aeb1119..4466a1cd 100644
--- a/content/renderer/media/webrtc_logging_message_filter.h
+++ b/chrome/renderer/media/webrtc_logging_message_filter.h
@@ -1,34 +1,29 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
-#define CONTENT_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
+#ifndef CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
+#define CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
#include "base/shared_memory.h"
-#include "content/common/content_export.h"
#include "ipc/ipc_channel_proxy.h"
namespace base {
class MessageLoopProxy;
}
-namespace content {
-
class WebRtcLoggingHandlerImpl;
// Filter for WebRTC logging messages. Sits between WebRtcLoggingHandlerImpl
// (renderer process) and WebRtcLoggingHandlerHost (browser process). Must be
// called on the IO thread.
-class CONTENT_EXPORT WebRtcLoggingMessageFilter
+class WebRtcLoggingMessageFilter
: public IPC::ChannelProxy::MessageFilter {
public:
explicit WebRtcLoggingMessageFilter(
const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
- // We take owbership of |logging_handler|. See also comment below.
- virtual void InitLogging(WebRtcLoggingHandlerImpl* logging_handler,
- const std::string& app_session_id,
+ virtual void InitLogging(const std::string& app_session_id,
const std::string& app_url);
const scoped_refptr<base::MessageLoopProxy>& io_message_loop() {
@@ -45,6 +40,8 @@ class CONTENT_EXPORT WebRtcLoggingMessageFilter
virtual void OnFilterRemoved() OVERRIDE;
virtual void OnChannelClosing() OVERRIDE;
+ void CreateLoggingHandler();
+
void OnLogOpened(base::SharedMemoryHandle handle, uint32 length);
void OnOpenLogFailed();
@@ -63,6 +60,4 @@ class CONTENT_EXPORT WebRtcLoggingMessageFilter
DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingMessageFilter);
};
-} // namespace content
-
-#endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
+#endif // CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 2b17557..c10a4f3 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -135,10 +135,6 @@
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#endif
-#if defined(ENABLE_WEBRTC)
-#include "content/browser/renderer_host/media/webrtc_logging_handler_host.h"
-#endif
-
#include "third_party/skia/include/core/SkBitmap.h"
extern bool g_exited_main_message_loop;
@@ -695,9 +691,6 @@ void RenderProcessHostImpl::CreateMessageFilters() {
channel_->AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER));
channel_->AddFilter(new HistogramMessageFilter());
channel_->AddFilter(new HyphenatorMessageFilter(this));
-#if defined(ENABLE_WEBRTC)
- channel_->AddFilter(new WebRtcLoggingHandlerHost());
-#endif
#if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableMemoryBenchmarking))
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h
index 955d5e4..d99a175 100644
--- a/content/common/content_message_generator.h
+++ b/content/common/content_message_generator.h
@@ -37,7 +37,6 @@
#include "content/common/media/media_stream_messages.h"
#include "content/common/media/peer_connection_tracker_messages.h"
#include "content/common/media/video_capture_messages.h"
-#include "content/common/media/webrtc_logging_messages.h"
#include "content/common/memory_benchmark_messages.h"
#include "content/common/mime_registry_messages.h"
#include "content/common/p2p_messages.h"
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index c09639f6..77a27a6 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -808,8 +808,6 @@
'browser/renderer_host/media/web_contents_tracker.h',
'browser/renderer_host/media/web_contents_video_capture_device.cc',
'browser/renderer_host/media/web_contents_video_capture_device.h',
- 'browser/renderer_host/media/webrtc_logging_handler_host.cc',
- 'browser/renderer_host/media/webrtc_logging_handler_host.h',
'browser/renderer_host/memory_benchmark_message_filter.cc',
'browser/renderer_host/memory_benchmark_message_filter.h',
'browser/renderer_host/native_web_keyboard_event_android.cc',
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 7c5b2a0..8d878dd 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -279,7 +279,6 @@
'common/media/media_stream_options.h',
'common/media/video_capture.h',
'common/media/video_capture_messages.h',
- 'common/media/webrtc_logging_messages.h',
'common/memory_benchmark_messages.h',
'common/message_router.cc',
'common/message_router.h',
@@ -291,8 +290,6 @@
'common/p2p_messages.h',
'common/p2p_sockets.h',
'common/page_zoom.cc',
- 'common/partial_circular_buffer.cc',
- 'common/partial_circular_buffer.h',
'common/pepper_messages.h',
'common/pepper_plugin_registry.cc',
'common/pepper_plugin_registry.h',
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 99c34cb..f6f7f2f 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -170,10 +170,6 @@
'renderer/media/video_capture_message_filter.h',
'renderer/media/webmediaplayer_proxy_impl_android.cc',
'renderer/media/webmediaplayer_proxy_impl_android.h',
- 'renderer/media/webrtc_logging_handler_impl.cc',
- 'renderer/media/webrtc_logging_handler_impl.h',
- 'renderer/media/webrtc_logging_message_filter.cc',
- 'renderer/media/webrtc_logging_message_filter.h',
'renderer/memory_benchmarking_extension.cc',
'renderer/memory_benchmarking_extension.h',
'renderer/mhtml_generator.cc',
@@ -387,6 +383,7 @@
'<(DEPTH)/crypto/crypto.gyp:crypto',
],
'sources': [
+ 'public/renderer/webrtc_log_message_delegate.h',
'renderer/media/media_stream_center.cc',
'renderer/media/media_stream_dependency_factory.cc',
'renderer/media/media_stream_dispatcher.cc',
@@ -432,6 +429,8 @@
'renderer/media/webrtc_local_audio_renderer.h',
'renderer/media/webrtc_local_audio_track.cc',
'renderer/media/webrtc_local_audio_track.h',
+ 'renderer/media/webrtc_logging_initializer.cc',
+ 'renderer/media/webrtc_logging_initializer.h',
'renderer/p2p/host_address_request.cc',
'renderer/p2p/host_address_request.h',
'renderer/p2p/ipc_network_manager.cc',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index c7df64e..eaa46bf 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -368,7 +368,6 @@
'common/gpu/gpu_memory_manager_unittest.cc',
'common/inter_process_time_ticks_converter_unittest.cc',
'common/page_zoom_unittest.cc',
- 'common/partial_circular_buffer_unittest.cc',
'common/resource_dispatcher_unittest.cc',
'common/sandbox_mac_diraccess_unittest.mm',
'common/sandbox_mac_fontloading_unittest.mm',
@@ -596,7 +595,6 @@
'renderer/media/video_source_handler_unittest.cc',
'renderer/media/webrtc_audio_device_unittest.cc',
'renderer/media/webrtc_local_audio_track_unittest.cc',
- 'renderer/media/webrtc_logging_handler_impl_unittest.cc',
],
'dependencies': [
'../third_party/libjingle/libjingle.gyp:libjingle_webrtc',
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
index 45a3999..f24aca7 100644
--- a/content/public/renderer/content_renderer_client.h
+++ b/content/public/renderer/content_renderer_client.h
@@ -239,6 +239,7 @@ class CONTENT_EXPORT ContentRendererClient {
// Returns whether BrowserPlugin should be allowed within the |container|.
virtual bool AllowBrowserPlugin(WebKit::WebPluginContainer* container) const;
+
};
} // namespace content
diff --git a/content/public/renderer/webrtc_log_message_delegate.h b/content/public/renderer/webrtc_log_message_delegate.h
new file mode 100644
index 0000000..4469567
--- /dev/null
+++ b/content/public/renderer/webrtc_log_message_delegate.h
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_RENDERER_MEDIA_WEBRTC_LOG_MESSAGE_DELEGATE_H_
+#define CONTENT_PUBLIC_RENDERER_MEDIA_WEBRTC_LOG_MESSAGE_DELEGATE_H_
+
+#include <string>
+
+#include "content/common/content_export.h"
+
+namespace content {
+
+// This interface is implemented by a handler in the embedder and used for
+// initializing the logging and passing log messages to the handler. The
+// purpose is to forward mainly libjingle log messages to embedder (besides
+// the ordinary logging stream) that will be used for diagnostic purposes.
+class WebRtcLogMessageDelegate {
+ public:
+ // Tells the handler to initialize WebRTC logging. |app_session_id| is set
+ // by the Javascript application. |app_url| is the Javascript application URL.
+ virtual void InitLogging(const std::string& app_session_id,
+ const std::string& app_url) = 0;
+
+ // Pass a diagnostic WebRTC log message.
+ virtual void LogMessage(const std::string& message) = 0;
+
+ protected:
+ virtual ~WebRtcLogMessageDelegate() {}
+};
+
+// Must be called on IO thread.
+CONTENT_EXPORT void InitWebRtcLoggingDelegate(
+ WebRtcLogMessageDelegate* delegate);
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_RENDERER_MEDIA_WEBRTC_LOG_MESSAGE_DELEGATE_H_
diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc
index 4faebcf..32f4d01 100644
--- a/content/renderer/media/media_stream_dependency_factory.cc
+++ b/content/renderer/media/media_stream_dependency_factory.cc
@@ -18,8 +18,7 @@
#include "content/renderer/media/webaudio_capturer_source.h"
#include "content/renderer/media/webrtc_audio_device_impl.h"
#include "content/renderer/media/webrtc_local_audio_track.h"
-#include "content/renderer/media/webrtc_logging_handler_impl.h"
-#include "content/renderer/media/webrtc_logging_message_filter.h"
+#include "content/renderer/media/webrtc_logging_initializer.h"
#include "content/renderer/media/webrtc_uma_histograms.h"
#include "content/renderer/p2p/ipc_network_manager.h"
#include "content/renderer/p2p/ipc_socket_factory.h"
@@ -217,8 +216,7 @@ MediaStreamDependencyFactory::MediaStreamDependencyFactory(
p2p_socket_dispatcher_(p2p_socket_dispatcher),
signaling_thread_(NULL),
worker_thread_(NULL),
- chrome_worker_thread_("Chrome_libJingle_WorkerThread"),
- webrtc_log_open_(false) {
+ chrome_worker_thread_("Chrome_libJingle_WorkerThread") {
}
MediaStreamDependencyFactory::~MediaStreamDependencyFactory() {
@@ -506,17 +504,12 @@ MediaStreamDependencyFactory::CreatePeerConnection(
webrtc::MediaConstraintsInterface::Constraints optional_constraints =
constraints->GetOptional();
std::string constraint_value;
- if (!webrtc_log_open_ &&
- optional_constraints.FindFirst(kWebRtcLoggingConstraint,
+ if (optional_constraints.FindFirst(kWebRtcLoggingConstraint,
&constraint_value)) {
- webrtc_log_open_ = true;
std::string url = web_frame->document().url().spec();
-
RenderThreadImpl::current()->GetIOMessageLoopProxy()->PostTask(
FROM_HERE, base::Bind(
- &MediaStreamDependencyFactory::CreateWebRtcLoggingHandler,
- base::Unretained(this),
- RenderThreadImpl::current()->webrtc_logging_message_filter(),
+ &InitWebRtcLogging,
constraint_value,
url));
}
@@ -791,13 +784,4 @@ void MediaStreamDependencyFactory::CleanupPeerConnectionFactory() {
}
}
-void MediaStreamDependencyFactory::CreateWebRtcLoggingHandler(
- WebRtcLoggingMessageFilter* filter,
- const std::string& app_session_id,
- const std::string& app_url) {
- WebRtcLoggingHandlerImpl* handler =
- new WebRtcLoggingHandlerImpl(filter->io_message_loop());
- filter->InitLogging(handler, app_session_id, app_url);
-}
-
} // namespace content
diff --git a/content/renderer/media/media_stream_dependency_factory.h b/content/renderer/media/media_stream_dependency_factory.h
index 9009959..5f56987 100644
--- a/content/renderer/media/media_stream_dependency_factory.h
+++ b/content/renderer/media/media_stream_dependency_factory.h
@@ -217,8 +217,6 @@ class CONTENT_EXPORT MediaStreamDependencyFactory
talk_base::Thread* worker_thread_;
base::Thread chrome_worker_thread_;
- bool webrtc_log_open_;
-
DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory);
};
diff --git a/content/renderer/media/webrtc_logging_initializer.cc b/content/renderer/media/webrtc_logging_initializer.cc
new file mode 100644
index 0000000..d0d95b4
--- /dev/null
+++ b/content/renderer/media/webrtc_logging_initializer.cc
@@ -0,0 +1,37 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/media/webrtc_logging_initializer.h"
+
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/webrtc_log_message_delegate.h"
+#include "content/renderer/render_thread_impl.h"
+#include "third_party/libjingle/overrides/talk/base/logging.h"
+
+namespace content {
+
+// Shall only be set once and never go back to NULL.
+WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL;
+
+void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) {
+ CHECK(!g_webrtc_logging_delegate);
+ CHECK(delegate);
+
+ g_webrtc_logging_delegate = delegate;
+}
+
+void InitWebRtcLogging(const std::string& app_session_id,
+ const std::string& app_url) {
+ if (g_webrtc_logging_delegate) {
+ g_webrtc_logging_delegate->InitLogging(app_session_id, app_url);
+ talk_base::InitDiagnosticLoggingDelegateFunction(WebRtcLogMessage);
+ }
+}
+
+void WebRtcLogMessage(const std::string& message) {
+ if (g_webrtc_logging_delegate)
+ g_webrtc_logging_delegate->LogMessage(message);
+}
+
+} // namespace content
diff --git a/content/renderer/media/webrtc_logging_initializer.h b/content/renderer/media/webrtc_logging_initializer.h
new file mode 100644
index 0000000..08abc66
--- /dev/null
+++ b/content/renderer/media/webrtc_logging_initializer.h
@@ -0,0 +1,23 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_WEBRTC_LOGGING_INITIALIZER_H_
+#define CONTENT_RENDERER_WEBRTC_LOGGING_INITIALIZER_H_
+
+#include <string>
+
+namespace content {
+
+class WebRtcLogMessageDelegate;
+
+// Must be called on IO thread.
+void InitWebRtcLogging(const std::string& app_session_id,
+ const std::string& app_url);
+
+// May be called on any thread.
+void WebRtcLogMessage(const std::string& message);
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_WEBRTC_LOGGING_INITIALIZER_H_
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 4a4ad9e..24ac0d2 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -65,7 +65,6 @@
#include "content/renderer/media/peer_connection_tracker.h"
#include "content/renderer/media/video_capture_impl_manager.h"
#include "content/renderer/media/video_capture_message_filter.h"
-#include "content/renderer/media/webrtc_logging_message_filter.h"
#include "content/renderer/memory_benchmarking_extension.h"
#include "content/renderer/p2p/socket_dispatcher.h"
#include "content/renderer/plugin_channel_host.h"
@@ -388,12 +387,6 @@ void RenderThreadImpl::Init() {
AddFilter(new IndexedDBMessageFilter);
-#if defined(ENABLE_WEBRTC)
- webrtc_logging_message_filter_ =
- new WebRtcLoggingMessageFilter(GetIOMessageLoopProxy());
- AddFilter(webrtc_logging_message_filter_.get());
-#endif
-
GetContentClient()->renderer()->RenderThreadStarted();
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h
index a7d615b..50d1362 100644
--- a/content/renderer/render_thread_impl.h
+++ b/content/renderer/render_thread_impl.h
@@ -87,7 +87,6 @@ class RenderProcessObserver;
class VideoCaptureImplManager;
class WebDatabaseObserverImpl;
class WebGraphicsContext3DCommandBufferImpl;
-class WebRtcLoggingMessageFilter;
// The RenderThreadImpl class represents a background thread where RenderView
// instances live. The RenderThread supports an API that is used by its
@@ -249,11 +248,6 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
return vc_manager_.get();
}
- const scoped_refptr<WebRtcLoggingMessageFilter>&
- webrtc_logging_message_filter() const {
- return webrtc_logging_message_filter_;
- }
-
// Get the GPU channel. Returns NULL if the channel is not established or
// has been lost.
GpuChannelHost* GetGpuChannel();
@@ -393,8 +387,6 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
// Used on multiple threads.
scoped_refptr<VideoCaptureImplManager> vc_manager_;
- scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
-
// Used on multiple script execution context threads.
scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_;
diff --git a/third_party/libjingle/libjingle.gyp b/third_party/libjingle/libjingle.gyp
index 83923c8..2a1bb27 100644
--- a/third_party/libjingle/libjingle.gyp
+++ b/third_party/libjingle/libjingle.gyp
@@ -241,9 +241,6 @@
'overrides/talk/base/basictypes.h',
'overrides/talk/base/constructormagic.h',
- # This file is in Chromium only.
- 'overrides/logging/log_message_delegate.h',
-
# Overrides logging.h/.cc because libjingle logging should be done to
# the same place as the chromium logging.
'overrides/talk/base/logging.cc',
diff --git a/third_party/libjingle/overrides/logging/log_message_delegate.h b/third_party/libjingle/overrides/logging/log_message_delegate.h
deleted file mode 100644
index e23465e..0000000
--- a/third_party/libjingle/overrides/logging/log_message_delegate.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_LIBJINGLE_OVERRIDES_LOGGING_LOG_MESSAGE_DELEGATE_H_
-#define THIRD_PARTY_LIBJINGLE_OVERRIDES_LOGGING_LOG_MESSAGE_DELEGATE_H_
-
-#include <string>
-
-namespace talk_base {
-
-// This interface is implemented by a handler in Chromium and used by the
-// overridden logging.h/cc in libjingle. The purpose is to forward libjingle
-// logging messages to Chromium (besides to the ordinary logging stream) that
-// will be used for diagnostic purposes. LogMessage can be called on any thread
-// used by libjingle.
-class LogMessageDelegate {
- public:
- virtual void LogMessage(const std::string& message) = 0;
-
- protected:
- virtual ~LogMessageDelegate() {}
-};
-
-} // namespace talk_base
-
-#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_LOGGING_LOG_MESSAGE_DELEGATE_H_
diff --git a/third_party/libjingle/overrides/talk/base/logging.cc b/third_party/libjingle/overrides/talk/base/logging.cc
index 88fa9f8..2968bd6 100644
--- a/third_party/libjingle/overrides/talk/base/logging.cc
+++ b/third_party/libjingle/overrides/talk/base/logging.cc
@@ -13,7 +13,6 @@
#include "base/atomicops.h"
#include "base/string_util.h"
#include "base/threading/platform_thread.h"
-#include "third_party/libjingle/overrides/logging/log_message_delegate.h"
#include "third_party/libjingle/source/talk/base/stream.h"
#include "third_party/libjingle/source/talk/base/stringencode.h"
#include "third_party/libjingle/source/talk/base/stringutils.h"
@@ -30,7 +29,7 @@
namespace talk_base {
-LogMessageDelegate* g_logging_delegate = NULL;
+void (*g_logging_delegate_function)(const std::string&) = NULL;
#ifndef NDEBUG
COMPILE_ASSERT(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId),
atomic32_not_same_size_as_platformthreadid);
@@ -151,8 +150,8 @@ DiagnosticLogMessage::~DiagnosticLogMessage() {
const std::string& str = print_stream_.str();
if (log_to_chrome_)
LOG_LAZY_STREAM_DIRECT(file_name_, line_, severity_) << str;
- if (g_logging_delegate && severity_ <= LS_INFO)
- g_logging_delegate->LogMessage(str);
+ if (g_logging_delegate_function && severity_ <= LS_INFO)
+ g_logging_delegate_function(str);
}
// Note: this function is a copy from the overriden libjingle implementation.
@@ -273,7 +272,8 @@ void LogMultiline(LoggingSeverity level, const char* label, bool input,
}
}
-void InitDiagnosticLoggingDelegate(LogMessageDelegate* delegate) {
+void InitDiagnosticLoggingDelegateFunction(
+ void (*delegate)(const std::string&)) {
#ifndef NDEBUG
// Ensure that this function is always called from the same thread.
base::subtle::NoBarrier_CompareAndSwap(&g_init_logging_delegate_thread_id, 0,
@@ -281,9 +281,9 @@ void InitDiagnosticLoggingDelegate(LogMessageDelegate* delegate) {
DCHECK_EQ(g_init_logging_delegate_thread_id,
base::PlatformThread::CurrentId());
#endif
- CHECK(!g_logging_delegate);
+ CHECK(!g_logging_delegate_function);
CHECK(delegate);
- g_logging_delegate = delegate;
+ g_logging_delegate_function = delegate;
}
} // namespace talk_base
diff --git a/third_party/libjingle/overrides/talk/base/logging.h b/third_party/libjingle/overrides/talk/base/logging.h
index 5203916..137d7a4 100644
--- a/third_party/libjingle/overrides/talk/base/logging.h
+++ b/third_party/libjingle/overrides/talk/base/logging.h
@@ -31,8 +31,6 @@
namespace talk_base {
-class LogMessageDelegate;
-
///////////////////////////////////////////////////////////////////////////////
// ConstantLabel can be used to easily generate string names from constant
// values. This can be useful for logging descriptive names of error messages.
@@ -165,9 +163,8 @@ void LogMultiline(LoggingSeverity level, const char* label, bool input,
const void* data, size_t len, bool hex_mode,
LogMultilineState* state);
-// Registers a delegate to receive diagnostic logging messages. Not thread safe,
-// must be called from the same thread.
-void InitDiagnosticLoggingDelegate(LogMessageDelegate* delegate);
+void InitDiagnosticLoggingDelegateFunction(
+ void (*delegate)(const std::string&));
} // namespace talk_base