| Index: chrome/browser/media/webrtc_logging_handler_host.cc
|
| diff --git a/chrome/browser/media/webrtc_logging_handler_host.cc b/chrome/browser/media/webrtc_logging_handler_host.cc
|
| index e0c49cc30877974447a3a42173ca2805b7e3520c..0cee5e8827240f5bdc9dce6dc3aae0080bd41546 100644
|
| --- a/chrome/browser/media/webrtc_logging_handler_host.cc
|
| +++ b/chrome/browser/media/webrtc_logging_handler_host.cc
|
| @@ -116,6 +116,14 @@ base::FilePath GetAudioDebugRecordingsPrefixPath(
|
| base::Int64ToString(audio_debug_recordings_id));
|
| }
|
|
|
| +// Returns a path name to be used as prefix for RTC event log files.
|
| +base::FilePath GetRtcEventLogPrefixPath(const base::FilePath& directory,
|
| + uint64_t rtc_event_log_id) {
|
| + static const char kRtcEventLogFilePrefix[] = "RtcEventLog.";
|
| + return directory.AppendASCII(kRtcEventLogFilePrefix +
|
| + base::Int64ToString(rtc_event_log_id));
|
| +}
|
| +
|
| } // namespace
|
|
|
| WebRtcLogBuffer::WebRtcLogBuffer()
|
| @@ -160,7 +168,9 @@ WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost(
|
| upload_log_on_render_close_(false),
|
| log_uploader_(log_uploader),
|
| is_audio_debug_recordings_in_progress_(false),
|
| - current_audio_debug_recordings_id_(0) {
|
| + current_audio_debug_recordings_id_(0),
|
| + is_rtc_event_logging_in_progress_(false),
|
| + current_rtc_event_log_id_(0) {
|
| DCHECK(profile_);
|
| DCHECK(log_uploader_);
|
| }
|
| @@ -446,8 +456,8 @@ void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread(
|
| void WebRtcLoggingHandlerHost::StartAudioDebugRecordings(
|
| content::RenderProcessHost* host,
|
| base::TimeDelta delay,
|
| - const AudioDebugRecordingsCallback& callback,
|
| - const AudioDebugRecordingsErrorCallback& error_callback) {
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
| BrowserThread::PostTaskAndReplyWithResult(
|
| @@ -460,8 +470,8 @@ void WebRtcLoggingHandlerHost::StartAudioDebugRecordings(
|
|
|
| void WebRtcLoggingHandlerHost::StopAudioDebugRecordings(
|
| content::RenderProcessHost* host,
|
| - const AudioDebugRecordingsCallback& callback,
|
| - const AudioDebugRecordingsErrorCallback& error_callback) {
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| BrowserThread::PostTaskAndReplyWithResult(
|
| BrowserThread::FILE, FROM_HERE,
|
| @@ -472,6 +482,35 @@ void WebRtcLoggingHandlerHost::StopAudioDebugRecordings(
|
| current_audio_debug_recordings_id_, callback, error_callback));
|
| }
|
|
|
| +void WebRtcLoggingHandlerHost::StartRtcEventLogging(
|
| + content::RenderProcessHost* host,
|
| + base::TimeDelta delay,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + BrowserThread::PostTaskAndReplyWithResult(
|
| + BrowserThread::FILE, FROM_HERE,
|
| + base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
|
| + this),
|
| + base::Bind(&WebRtcLoggingHandlerHost::DoStartRtcEventLogging, this, host,
|
| + delay, callback, error_callback));
|
| +}
|
| +
|
| +void WebRtcLoggingHandlerHost::StopRtcEventLogging(
|
| + content::RenderProcessHost* host,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + BrowserThread::PostTaskAndReplyWithResult(
|
| + BrowserThread::FILE, FROM_HERE,
|
| + base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
|
| + this),
|
| + base::Bind(&WebRtcLoggingHandlerHost::DoStopRtcEventLogging, this, host,
|
| + true /* manual stop */, current_audio_debug_recordings_id_,
|
| + callback, error_callback));
|
| +}
|
| +
|
| void WebRtcLoggingHandlerHost::OnChannelClosing() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| if (logging_state_ == STARTED || logging_state_ == STOPPED) {
|
| @@ -812,8 +851,8 @@ void WebRtcLoggingHandlerHost::FireGenericDoneCallback(
|
| void WebRtcLoggingHandlerHost::DoStartAudioDebugRecordings(
|
| content::RenderProcessHost* host,
|
| base::TimeDelta delay,
|
| - const AudioDebugRecordingsCallback& callback,
|
| - const AudioDebugRecordingsErrorCallback& error_callback,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback,
|
| const base::FilePath& log_directory) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
| @@ -846,8 +885,8 @@ void WebRtcLoggingHandlerHost::DoStopAudioDebugRecordings(
|
| content::RenderProcessHost* host,
|
| bool is_manual_stop,
|
| uint64_t audio_debug_recordings_id,
|
| - const AudioDebugRecordingsCallback& callback,
|
| - const AudioDebugRecordingsErrorCallback& error_callback,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback,
|
| const base::FilePath& log_directory) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| DCHECK_LE(audio_debug_recordings_id, current_audio_debug_recordings_id_);
|
| @@ -874,3 +913,68 @@ void WebRtcLoggingHandlerHost::DoStopAudioDebugRecordings(
|
| is_audio_debug_recordings_in_progress_ = false;
|
| callback.Run(prefix_path.AsUTF8Unsafe(), true /* stopped */, is_manual_stop);
|
| }
|
| +
|
| +void WebRtcLoggingHandlerHost::DoStartRtcEventLogging(
|
| + content::RenderProcessHost* host,
|
| + base::TimeDelta delay,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback,
|
| + const base::FilePath& log_directory) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + if (is_rtc_event_logging_in_progress_) {
|
| + error_callback.Run("RTC event logging already in progress");
|
| + return;
|
| + }
|
| +
|
| + is_rtc_event_logging_in_progress_ = true;
|
| + base::FilePath prefix_path =
|
| + GetRtcEventLogPrefixPath(log_directory, ++current_rtc_event_log_id_);
|
| + host->EnableEventLogRecordings(prefix_path);
|
| +
|
| + if (delay.is_zero()) {
|
| + callback.Run(prefix_path.AsUTF8Unsafe(), false /* not stopped */,
|
| + false /* not manually stopped */);
|
| + return;
|
| + }
|
| +
|
| + BrowserThread::PostDelayedTask(
|
| + BrowserThread::UI, FROM_HERE,
|
| + base::Bind(&WebRtcLoggingHandlerHost::DoStopRtcEventLogging, this, host,
|
| + false /* no manual stop */, current_rtc_event_log_id_,
|
| + callback, error_callback, prefix_path),
|
| + delay);
|
| +}
|
| +
|
| +void WebRtcLoggingHandlerHost::DoStopRtcEventLogging(
|
| + content::RenderProcessHost* host,
|
| + bool is_manual_stop,
|
| + uint64_t rtc_event_log_id,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback,
|
| + const base::FilePath& log_directory) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + DCHECK_LE(rtc_event_log_id, current_rtc_event_log_id_);
|
| +
|
| + base::FilePath prefix_path =
|
| + GetRtcEventLogPrefixPath(log_directory, rtc_event_log_id);
|
| + // Prevent an old posted DoStopRtcEventLogging() call to stop a newer dump.
|
| + // This could happen in a sequence like:
|
| + // Start(10); //Start dump 1. Post Stop() to run after 10 seconds.
|
| + // Stop(); // Manually stop dump 1 before 10 seconds;
|
| + // Start(20); // Start dump 2. Posted Stop() for 1 should not stop dump 2.
|
| + if (rtc_event_log_id < current_rtc_event_log_id_) {
|
| + callback.Run(prefix_path.AsUTF8Unsafe(), false /* not stopped */,
|
| + is_manual_stop);
|
| + return;
|
| + }
|
| +
|
| + if (!is_rtc_event_logging_in_progress_) {
|
| + error_callback.Run("No RTC event logging in progress");
|
| + return;
|
| + }
|
| +
|
| + host->DisableEventLogRecordings();
|
| + is_rtc_event_logging_in_progress_ = false;
|
| + callback.Run(prefix_path.AsUTF8Unsafe(), true /* stopped */, is_manual_stop);
|
| +}
|
|
|