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

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

Issue 334743006: Support multiple files for AEC dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review (sky). Created 6 years, 6 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
Index: content/renderer/media/aec_dump_message_filter.cc
diff --git a/content/renderer/media/aec_dump_message_filter.cc b/content/renderer/media/aec_dump_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..89356f2076cfea14e540c85d3970d7c905990087
--- /dev/null
+++ b/content/renderer/media/aec_dump_message_filter.cc
@@ -0,0 +1,130 @@
+// Copyright (c) 2014 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/aec_dump_message_filter.h"
+
+#include "base/message_loop/message_loop_proxy.h"
+#include "content/common/media/aec_dump_messages.h"
+#include "content/renderer/media/webrtc_logging.h"
+#include "ipc/ipc_logging.h"
+#include "ipc/ipc_sender.h"
+
+namespace content {
+
+AecDumpMessageFilter* AecDumpMessageFilter::g_filter = NULL;
+
+AecDumpMessageFilter::AecDumpMessageFilter(
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop,
+ const scoped_refptr<base::MessageLoopProxy>& main_message_loop)
+ : sender_(NULL),
+ observer_(NULL),
+ io_message_loop_(io_message_loop),
+ main_message_loop_(main_message_loop) {
+ DCHECK(!g_filter);
+ g_filter = this;
+}
+
+AecDumpMessageFilter::~AecDumpMessageFilter() {
+ DCHECK_EQ(g_filter, this);
+ g_filter = NULL;
+}
+
+// static
+scoped_refptr<AecDumpMessageFilter> AecDumpMessageFilter::Get() {
+ return g_filter;
no longer working on chromium 2014/06/16 18:30:55 which thread creates the AecDumpMessageFilter? and
Henrik Grunell 2014/06/17 20:21:41 It's created by the RenderThreadImpl on the main t
+}
+
+void AecDumpMessageFilter::RegisterAecDumpConsumer(int id) {
+ Send(new AecDumpMsg_RegisterAecDumpConsumer(id));
+}
+
+void AecDumpMessageFilter::UnregisterAecDumpConsumer(int id) {
+ Send(new AecDumpMsg_UnregisterAecDumpConsumer(id));
+}
+
+void AecDumpMessageFilter::Send(IPC::Message* message) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ if (sender_)
no longer working on chromium 2014/06/16 18:30:55 I am not familiar with the IPC code, could you ple
Henrik Grunell 2014/06/17 20:21:41 Sure. But the code is similar to existing code in
+ sender_->Send(message);
+ else
+ delete message;
+}
+
+bool AecDumpMessageFilter::OnMessageReceived(const IPC::Message& message) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(AecDumpMessageFilter, message)
+ IPC_MESSAGE_HANDLER(AecDumpMsg_EnableAecDump, OnEnableAecDump)
+ IPC_MESSAGE_HANDLER(AecDumpMsg_DisableAecDump, OnDisableAecDump)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void AecDumpMessageFilter::OnFilterAdded(IPC::Sender* sender) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ sender_ = sender;
+}
+
+void AecDumpMessageFilter::OnFilterRemoved() {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+
+ // Once removed, a filter will not be used again. At this time the
+ // observer must be notified so it releases its reference.
+ OnChannelClosing();
+}
+
+void AecDumpMessageFilter::OnChannelClosing() {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ sender_ = NULL;
+ main_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &AecDumpMessageFilter::DoChannelClosingOnObserver,
+ this));
+}
+
+void AecDumpMessageFilter::OnEnableAecDump(
+ int id,
+ IPC::PlatformFileForTransit file_handle) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ main_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &AecDumpMessageFilter::DoEnableAecDump,
+ this,
+ id,
+ file_handle));
+}
+
+void AecDumpMessageFilter::OnDisableAecDump() {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ main_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &AecDumpMessageFilter::DoDisableAecDump,
+ this));
+}
+
+void AecDumpMessageFilter::DoEnableAecDump(
+ int id,
+ IPC::PlatformFileForTransit file_handle) {
+ DCHECK(main_message_loop_->BelongsToCurrentThread());
+ if (observer_)
+ observer_->OnAecDumpFile(id, file_handle);
no longer working on chromium 2014/06/16 18:30:55 why not call OnEnableAecDump?
Henrik Grunell 2014/06/17 20:21:41 The observer doesn't have such a function. Not sur
+}
+
+void AecDumpMessageFilter::DoDisableAecDump() {
+ DCHECK(main_message_loop_->BelongsToCurrentThread());
+ if (observer_)
+ observer_->OnDisableAecDump();
+}
+
+void AecDumpMessageFilter::DoChannelClosingOnObserver() {
+ DCHECK(main_message_loop_->BelongsToCurrentThread());
+ if (observer_)
+ observer_->OnIpcClosed();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698