| Index: chrome/browser/media/webrtc_internal_log_handler_host.h
|
| diff --git a/chrome/browser/media/webrtc_internal_log_handler_host.h b/chrome/browser/media/webrtc_internal_log_handler_host.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..896059cdd9d88fa03b3b84e01f95ed3238f52cbd
|
| --- /dev/null
|
| +++ b/chrome/browser/media/webrtc_internal_log_handler_host.h
|
| @@ -0,0 +1,143 @@
|
| +// Copyright 2013 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_WEBRTC_INTERNAL_LOG_HANDLER_HOST_H_
|
| +#define CHROME_BROWSER_MEDIA_WEBRTC_INTERNAL_LOG_HANDLER_HOST_H_
|
| +
|
| +#include <stddef.h>
|
| +#include <stdint.h>
|
| +
|
| +#include "base/macros.h"
|
| +#include "build/build_config.h"
|
| +#include "content/public/browser/browser_message_filter.h"
|
| +#include "content/public/browser/render_process_host.h"
|
| +#include "net/base/network_interfaces.h"
|
| +
|
| +class Profile;
|
| +
|
| +// WebRtcInternalLogHandlerHost provides an interface to the internal logs
|
| +// in WebRTC:
|
| +// - Starts and stops AEC dumps / AudioDebugRecordings.
|
| +// - Starts and stops RTC event logs.
|
| +// - In the future, detects when channel, i.e. renderer, is going away and
|
| +// possibly triggers uploading the log.
|
| +class WebRtcInternalLogHandlerHost : public content::BrowserMessageFilter {
|
| + public:
|
| + typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback;
|
| + typedef base::Callback<void(const std::string&)>
|
| + TimeLimitedRecordingErrorCallback;
|
| + typedef base::Callback<void(const std::string&, bool, bool)>
|
| + TimeLimitedRecordingCallback;
|
| +
|
| + explicit WebRtcInternalLogHandlerHost(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);
|
| +
|
| + // Starts an RTC event log. The call writes the most recent events to a
|
| + // file and then starts logging events for the given |delay|.
|
| + // If |delay| is zero, the logging will continue until StopRtcEventLogging()
|
| + // 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 StartRtcEventLogging(
|
| + content::RenderProcessHost* host,
|
| + base::TimeDelta delay,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback);
|
| +
|
| + // Stops an RTC event log. |callback| is invoked once recording
|
| + // stops. If no recording was in progress, |error_callback| is invoked instead
|
| + // of |callback|.
|
| + void StopRtcEventLogging(
|
| + content::RenderProcessHost* host,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback);
|
| +
|
| + private:
|
| + friend class content::BrowserThread;
|
| + friend class base::DeleteHelper<WebRtcInternalLogHandlerHost>;
|
| +
|
| + ~WebRtcInternalLogHandlerHost() override;
|
| +
|
| + // BrowserMessageFilter implementation.
|
| + void OnChannelClosing() override;
|
| + void OnDestruct() const override;
|
| + bool OnMessageReceived(const IPC::Message& message) override;
|
| +
|
| + 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);
|
| +
|
| + // Helper for starting RTC event logs.
|
| + void DoStartRtcEventLogging(
|
| + content::RenderProcessHost* host,
|
| + base::TimeDelta delay,
|
| + const TimeLimitedRecordingCallback& callback,
|
| + const TimeLimitedRecordingErrorCallback& error_callback,
|
| + const base::FilePath& log_directory);
|
| +
|
| + // Helper for stopping RTC event logs.
|
| + void DoStopRtcEventLogging(
|
| + 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_;
|
| +
|
| + // Must be accessed on the UI thread.
|
| + bool is_rtc_event_logging_in_progress_;
|
| +
|
| + // This counter allows saving each log in a separate file.
|
| + uint64_t current_rtc_event_log_id_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebRtcInternalLogHandlerHost);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_MEDIA_WEBRTC_INTERNAL_LOG_HANDLER_HOST_H_
|
|
|