Chromium Code Reviews| Index: chrome/browser/media/rtc_event_log_handler.h |
| diff --git a/chrome/browser/media/rtc_event_log_handler.h b/chrome/browser/media/rtc_event_log_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..870882fc31404c99eaea72541c96ed0ce24067b3 |
| --- /dev/null |
| +++ b/chrome/browser/media/rtc_event_log_handler.h |
| @@ -0,0 +1,97 @@ |
| +// 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_RTC_EVENT_LOG_HANDLER_H_ |
| +#define CHROME_BROWSER_MEDIA_RTC_EVENT_LOG_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" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "net/base/network_interfaces.h" |
| + |
| +class Profile; |
| + |
| +// RtcEventLogHandler provides an interface to the internal logs |
| +// in WebRTC: |
| +// - Starts and stops AudioDebugRecordings, aka AEC dumps. |
|
Henrik Grunell
2016/02/23 15:29:10
Remove this line and rewrite without any bullet.
terelius-chromium
2016/03/02 10:01:10
Done.
|
| +// - Starts and stops RTC event logs. |
|
Guido Urdaneta
2016/02/23 13:57:34
And this one is only for RTC event logs.
WebRtcEve
Henrik Grunell
2016/02/23 15:29:10
Agree with that name suggestion. (Sorry if I previ
terelius-chromium
2016/03/02 10:01:10
Done.
|
| +class RtcEventLogHandler |
| + : public base::RefCountedThreadSafe<RtcEventLogHandler> { |
| + 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.
|
| + typedef base::Callback<void(const std::string&, bool, bool)> |
| + TimeLimitedRecordingCallback; |
| + |
| + // Key used to attach the handler to the RenderProcessHost |
|
Henrik Grunell
2016/02/23 15:29:10
Nit: End with .
terelius-chromium
2016/03/02 10:01:10
Done.
|
| + static const char kRtcEventLogHandlerKey[]; |
| + |
| + explicit RtcEventLogHandler(Profile* profile); |
| + |
| + // 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; |
|
Henrik Grunell
2016/02/23 15:29:10
These three needed?
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<RtcEventLogHandler>; |
| + friend class base::RefCountedThreadSafe<RtcEventLogHandler>; |
| + |
| + virtual ~RtcEventLogHandler(); |
| + |
| + base::FilePath GetLogDirectoryAndEnsureExists(); |
| + |
| + // 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_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(RtcEventLogHandler); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_MEDIA_RTC_EVENT_LOG_HANDLER_H_ |