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

Unified Diff: content/browser/media/audio_debug_controller.cc

Issue 1246283003: Split out audio debug recording from RenderProcessHostImpl. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile. Created 4 years, 11 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
« no previous file with comments | « content/browser/media/audio_debug_controller.h ('k') | content/browser/media/audio_debug_recording_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/audio_debug_controller.cc
diff --git a/content/browser/media/audio_debug_controller.cc b/content/browser/media/audio_debug_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a2bbf427b5edde794e5c7ee136adc572f884ad51
--- /dev/null
+++ b/content/browser/media/audio_debug_controller.cc
@@ -0,0 +1,90 @@
+// 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.
+
+#include "content/browser/media/audio_debug_controller.h"
+
+#include <utility>
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/memory/singleton.h"
+#include "base/stl_util.h"
+#include "content/browser/media/audio_debug_recording_impl.h"
+
+namespace content {
+
+// static
+AudioDebugController* AudioDebugController::GetInstance() {
+ return base::Singleton<AudioDebugController>::get();
+}
+
+// static
+void AudioDebugController::CreateService(
+ int render_host_id,
+ const scoped_refptr<AudioInputRendererHost>& audio_input_renderer_host,
+ mojo::InterfaceRequest<AudioDebugRecording> request) {
+ GetInstance()->CreateServiceInternal(
+ render_host_id, audio_input_renderer_host, std::move(request));
+}
+
+AudioDebugController::AudioDebugController() {}
+
+AudioDebugController::~AudioDebugController() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ STLDeleteContainerPointers(registered_impls_.begin(),
+ registered_impls_.end());
+}
+
+void AudioDebugController::EnableAudioDebugRecording(
+ const base::FilePath& file) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ for (auto impl : registered_impls_)
+ impl->EnableAudioDebugRecording(file);
+}
+
+void AudioDebugController::DisableAudioDebugRecording() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ for (auto impl : registered_impls_)
+ impl->DisableAudioDebugRecording();
+}
+
+void AudioDebugController::EnableAudioDebugRecordingForHost(
+ int render_host_id, const base::FilePath& file) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ for (auto impl : registered_impls_) {
+ if (impl->render_host_id() == render_host_id)
+ impl->EnableAudioDebugRecording(file);
+ }
+}
+
+void AudioDebugController::DisableAudioDebugRecordingForHost(
+ int render_host_id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ for (auto impl : registered_impls_) {
+ if (impl->render_host_id() == render_host_id)
+ impl->DisableAudioDebugRecording();
+ }
+}
+
+void AudioDebugController::CreateServiceInternal(
+ int render_host_id,
+ const scoped_refptr<AudioInputRendererHost>& audio_input_renderer_host,
+ mojo::InterfaceRequest<AudioDebugRecording> request) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ AudioDebugRecordingImpl* impl = new AudioDebugRecordingImpl(
+ render_host_id, audio_input_renderer_host,
+ base::Bind(&AudioDebugController::OnDisconnect, base::Unretained(this)),
+ std::move(request));
+ bool inserted = registered_impls_.insert(impl).second;
+ DCHECK(inserted);
+}
+
+void AudioDebugController::OnDisconnect(AudioDebugRecordingImpl* impl) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ size_t num_removed = registered_impls_.erase(impl);
+ DCHECK_EQ(num_removed, 1U);
+ delete impl;
+}
+
+} // namespace content
« no previous file with comments | « content/browser/media/audio_debug_controller.h ('k') | content/browser/media/audio_debug_recording_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698