Index: content/renderer/media/audio_debug_recorder.h |
diff --git a/content/renderer/media/audio_debug_recorder.h b/content/renderer/media/audio_debug_recorder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d731e1418d517eb0f91da4171cff52ef24b3e6e2 |
--- /dev/null |
+++ b/content/renderer/media/audio_debug_recorder.h |
@@ -0,0 +1,86 @@ |
+// Copyright 2015 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_AUDIO_DEBUG_RECORDER_H_ |
+#define CONTENT_RENDERER_MEDIA_AUDIO_DEBUG_RECORDER_H_ |
+ |
+#include <map> |
+ |
+#include "base/containers/scoped_ptr_map.h" |
+#include "base/files/file.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/threading/thread_checker.h" |
+#include "content/common/content_export.h" |
+#include "content/common/media/audio_debug_recording.mojom.h" |
+ |
+namespace base { |
+class SingleThreadTaskRunner; |
+} |
+ |
+namespace content { |
+ |
+class ServiceRegistry; |
+ |
+// MessageFilter that handles AEC dump messages and forwards them to an |
+// observer. |
+class CONTENT_EXPORT AudioDebugRecorder |
+ : public base::RefCountedThreadSafe<AudioDebugRecorder> { |
+ public: |
+ class AecDumpDelegate { |
+ public: |
+ virtual void OnAecDumpFile(base::PlatformFile file_handle) = 0; |
+ virtual void OnDisableAecDump() = 0; |
+ virtual void OnIpcClosing() = 0; |
+ }; |
+ |
+ explicit AudioDebugRecorder(ServiceRegistry* service_registry); |
+ |
+ // Getter for the one AudioDebugRecorder object. |
+ static scoped_refptr<AudioDebugRecorder> Get(); |
+ |
+ // Adds a delegate that receives the enable and disable notifications. |
+ void AddDelegate(AudioDebugRecorder::AecDumpDelegate* delegate); |
+ |
+ // Removes a delegate. |
+ void RemoveDelegate(AudioDebugRecorder::AecDumpDelegate* delegate); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<AudioDebugRecorder>; |
+ ~AudioDebugRecorder(); |
+ |
+ class Observer; |
+ |
+ void OnConnectionError(); |
+ |
+ // Accessed on |main_task_runner_|. |
+ void DoEnableAecDump(int id, base::PlatformFile file_handle); |
+ void DoDisableAecDump(); |
+ int GetIdForDelegate(AudioDebugRecorder::AecDumpDelegate* delegate); |
+ |
+ AudioDebugRecordingPtr service_; |
+ |
+ // The delgates for this filter. Must only be accessed on |
+ // |main_task_runner_|. |
+ typedef std::map<int, AudioDebugRecorder::AecDumpDelegate*> DelegateMap; |
+ DelegateMap delegates_; |
+ |
+ using ObserverMap = base::ScopedPtrMap<int, scoped_ptr<Observer>>; |
Henrik Grunell
2015/10/15 12:17:03
What are the observers for? Comment would be good.
Anand Mistry (off Chromium)
2015/10/21 03:58:24
Done. Updated a bunch of comments.
|
+ ObserverMap observers_; |
+ |
+ // Counter for generating unique IDs to delegates. Accessed on |
+ // |main_task_runner_|. |
+ int delegate_id_counter_; |
+ |
+ // The singleton instance for this filter. |
+ static AudioDebugRecorder* g_filter; |
+ |
+ base::ThreadChecker thread_checker_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioDebugRecorder); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_MEDIA_AUDIO_DEBUG_RECORDER_H_ |