Chromium Code Reviews| Index: content/renderer/media/aec_dump_message_filter.h |
| diff --git a/content/renderer/media/aec_dump_message_filter.h b/content/renderer/media/aec_dump_message_filter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c168489255b2f4904154dffd96b06f4bbac00529 |
| --- /dev/null |
| +++ b/content/renderer/media/aec_dump_message_filter.h |
| @@ -0,0 +1,105 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
|
no longer working on chromium
2014/06/16 18:30:55
nit, you don't need the (c)
Henrik Grunell
2014/06/17 20:21:41
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_AEC_DUMP_MESSAGE_FILTER_H_ |
| +#define CONTENT_RENDERER_MEDIA_AEC_DUMP_MESSAGE_FILTER_H_ |
| + |
| +#include "base/gtest_prod_util.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/common/content_export.h" |
| +#include "content/renderer/render_thread_impl.h" |
| +#include "ipc/ipc_platform_file.h" |
| +#include "ipc/message_filter.h" |
| + |
| +namespace base { |
| +class MessageLoopProxy; |
| +} |
| + |
| +namespace content { |
| + |
| +// MessageFilter that handles AEC dump messages and forwards them to an |
| +// observer. |
| +class CONTENT_EXPORT AecDumpMessageFilter : public IPC::MessageFilter { |
| + public: |
| + class AecDumpObserver { |
| + public: |
| + virtual void OnAecDumpFile( |
| + int id, |
| + const IPC::PlatformFileForTransit& file_handle) = 0; |
| + virtual void OnDisableAecDump() = 0; |
| + virtual void OnIpcClosed() = 0; |
| + }; |
| + |
| + AecDumpMessageFilter( |
| + const scoped_refptr<base::MessageLoopProxy>& io_message_loop, |
| + const scoped_refptr<base::MessageLoopProxy>& main_message_loop); |
| + |
| + // Getter for the one AecDumpMessageFilter object. |
| + static scoped_refptr<AecDumpMessageFilter> Get(); |
| + |
| + void SetObserver(AecDumpMessageFilter::AecDumpObserver* observer) { |
| + DCHECK(main_message_loop_->BelongsToCurrentThread()); |
| + DCHECK(!observer != !observer_); |
|
no longer working on chromium
2014/06/16 18:30:55
move the implementation to .cc
no longer working on chromium
2014/06/16 18:30:55
it seems a high skilled DCHECK, can you simply it
Henrik Grunell
2014/06/17 20:21:41
Done.
Henrik Grunell
2014/06/17 20:21:41
Changed it to be more readable.
|
| + observer_ = observer; |
| + } |
| + |
| + // Registers a consumer of AEC dump in the browser process. This consumer will |
| + // get a file handle when the AEC dump is enabled and a notification when it |
| + // is disabled. |
| + void RegisterAecDumpConsumer(int id); |
| + |
| + // Unregisters a consumer of AEC dump in the browser process. |
| + void UnregisterAecDumpConsumer(int id); |
| + |
| + // IO message loop associated with this message filter. |
| + scoped_refptr<base::MessageLoopProxy> io_message_loop() const { |
| + return io_message_loop_; |
| + } |
| + |
| + protected: |
| + virtual ~AecDumpMessageFilter(); |
| + |
| + private: |
| + FRIEND_TEST_ALL_PREFIXES(AecDumpMessageFilter, Basic); |
| + FRIEND_TEST_ALL_PREFIXES(AecDumpMessageFilter, Delegates); |
| + |
| + // Sends an IPC message using |sender_|. |
| + void Send(IPC::Message* message); |
| + |
| + // IPC::MessageFilter override. Called on |io_message_loop|. |
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + virtual void OnFilterAdded(IPC::Sender* sender) OVERRIDE; |
| + virtual void OnFilterRemoved() OVERRIDE; |
| + virtual void OnChannelClosing() OVERRIDE; |
| + |
| + // Accessed on |io_message_loop|. |
| + void OnEnableAecDump(int id, IPC::PlatformFileForTransit file_handle); |
| + void OnDisableAecDump(); |
| + |
| + // Accessed on |main_message_loop_|. |
| + void DoEnableAecDump(int id, IPC::PlatformFileForTransit file_handle); |
| + void DoDisableAecDump(); |
| + void DoChannelClosingOnObserver(); |
| + |
| + // Accessed on |io_message_loop_|. |
| + IPC::Sender* sender_; |
| + |
| + // The observer of this filter. Must only be accessed on |main_message_loop_|. |
| + AecDumpObserver* observer_; |
| + |
| + // Message loop on which IPC calls are driven. |
| + const scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| + |
| + // Main message loop. |
| + const scoped_refptr<base::MessageLoopProxy> main_message_loop_; |
| + |
| + // The singleton instance for this filter. |
| + static AecDumpMessageFilter* g_filter; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AecDumpMessageFilter); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_AEC_DUMP_MESSAGE_FILTER_H_ |