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

Unified Diff: chrome/browser/media/audio_debug_recordings_handler.h

Issue 1650133002: Start and stop RTC event logs from private extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split the logging handler into one for audio recordings and one for event logs Created 4 years, 10 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: chrome/browser/media/audio_debug_recordings_handler.h
diff --git a/chrome/browser/media/audio_debug_recordings_handler.h b/chrome/browser/media/audio_debug_recordings_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d55293325020f52481dbf5e75ba722800b5c182
--- /dev/null
+++ b/chrome/browser/media/audio_debug_recordings_handler.h
@@ -0,0 +1,96 @@
+// Copyright 2016 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 CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_
+#define CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "base/macros.h"
+#include "build/build_config.h"
+#include "content/public/browser/browser_message_filter.h"
Henrik Grunell 2016/02/23 15:29:10 Remove. Seems like other includes could be removed
terelius-chromium 2016/03/02 10:01:10 Done.
+#include "content/public/browser/render_process_host.h"
+#include "net/base/network_interfaces.h"
+
+class Profile;
+
+// AudioDebugRecordingsHandler provides an interface to the internal logs
+// in WebRTC:
+// - Starts and stops AudioDebugRecordings, aka AEC dumps.
+// - Starts and stops RTC event logs.
Guido Urdaneta 2016/02/23 13:57:34 This class is only for AudioDebugRecordings. Shoul
Henrik Grunell 2016/02/23 15:29:10 It's not strictly WebRTC since it also does record
Henrik Grunell 2016/02/23 15:29:10 Remove comment about RTC event log. :) Actually, r
terelius-chromium 2016/03/02 10:01:10 Done.
+class AudioDebugRecordingsHandler
+ : public base::RefCountedThreadSafe<AudioDebugRecordingsHandler> {
+ public:
+ typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback;
+ typedef base::Callback<void(const std::string&)>
+ TimeLimitedRecordingErrorCallback;
Henrik Grunell 2016/02/23 15:29:10 Drop "TimeLimited".
terelius-chromium 2016/03/02 10:01:10 Done. Changed to RecordingErrorCallback and Record
+ typedef base::Callback<void(const std::string&, bool, bool)>
+ TimeLimitedRecordingCallback;
+
+ // Key used to attach the handler to the RenderProcessHost
+ static const char kAudioDebugRecordingsHandlerKey[];
+
+ explicit AudioDebugRecordingsHandler(Profile* profile);
+
+ // Starts an audio debug recording. The recording lasts the given |delay|,
+ // unless |delay| is zero, in which case recording will continue until
+ // StopAudioDebugRecordings() is explicitly invoked.
+ // |callback| is invoked once recording stops. If |delay| is zero
+ // |callback| is invoked once recording starts.
+ // If a recording was already in progress, |error_callback| is invoked instead
+ // of |callback|.
+ void StartAudioDebugRecordings(
+ content::RenderProcessHost* host,
+ base::TimeDelta delay,
+ const TimeLimitedRecordingCallback& callback,
+ const TimeLimitedRecordingErrorCallback& error_callback);
+
+ // Stops an audio debug recording. |callback| is invoked once recording
+ // stops. If no recording was in progress, |error_callback| is invoked instead
+ // of |callback|.
+ void StopAudioDebugRecordings(
+ content::RenderProcessHost* host,
+ const TimeLimitedRecordingCallback& callback,
+ const TimeLimitedRecordingErrorCallback& error_callback);
+
+ private:
+ friend class content::BrowserThread;
Henrik Grunell 2016/02/23 15:29:10 Not sure why these friends are needed. Can be remo
terelius-chromium 2016/03/02 10:01:10 Based on a comment in base/memory/ref_counted.h, I
Henrik Grunell 2016/03/10 21:33:34 Acknowledged.
+ friend class base::DeleteHelper<AudioDebugRecordingsHandler>;
+ friend class base::RefCountedThreadSafe<AudioDebugRecordingsHandler>;
+
+ virtual ~AudioDebugRecordingsHandler();
+
+ base::FilePath GetLogDirectoryAndEnsureExists();
+
+ // Helper for starting audio debug recordings.
+ void DoStartAudioDebugRecordings(
+ content::RenderProcessHost* host,
+ base::TimeDelta delay,
+ const TimeLimitedRecordingCallback& callback,
+ const TimeLimitedRecordingErrorCallback& error_callback,
+ const base::FilePath& log_directory);
+
+ // Helper for stopping audio debug recordings.
+ void DoStopAudioDebugRecordings(
+ content::RenderProcessHost* host,
+ bool is_manual_stop,
+ uint64_t audio_debug_recordings_id,
+ const TimeLimitedRecordingCallback& callback,
+ const TimeLimitedRecordingErrorCallback& error_callback,
+ const base::FilePath& log_directory);
+
+ // The profile associated with our renderer process.
+ Profile* const profile_;
+
+ // Must be accessed on the UI thread.
+ bool is_audio_debug_recordings_in_progress_;
+
+ // This counter allows saving each debug recording in separate files.
+ uint64_t current_audio_debug_recordings_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingsHandler);
+};
+
+#endif // CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698