Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_INTERNAL_LOG_HANDLER_HOST_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_WEBRTC_INTERNAL_LOG_HANDLER_HOST_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "build/build_config.h" | |
| 13 #include "content/public/browser/browser_message_filter.h" | |
| 14 #include "content/public/browser/render_process_host.h" | |
| 15 #include "net/base/network_interfaces.h" | |
| 16 | |
| 17 class Profile; | |
| 18 | |
| 19 // WebRtcInternalLogHandlerHost provides an interface to the internal logs | |
| 20 // in WebRTC: | |
| 21 // - Starts and stops AudioDebugRecordings, aka AEC dumps. | |
| 22 // - Starts and stops RTC event logs. | |
| 23 class WebRtcInternalLogHandlerHost | |
|
Henrik Grunell
2016/02/17 12:33:02
I'd prefer separate classes for the audio recordin
terelius-chromium
2016/02/22 09:28:55
Done. Please take a look.
| |
| 24 : public base::RefCountedThreadSafe<WebRtcInternalLogHandlerHost> { | |
| 25 public: | |
| 26 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; | |
| 27 typedef base::Callback<void(const std::string&)> | |
| 28 TimeLimitedRecordingErrorCallback; | |
| 29 typedef base::Callback<void(const std::string&, bool, bool)> | |
| 30 TimeLimitedRecordingCallback; | |
| 31 | |
| 32 // Key used to attach the handler to the RenderProcessHost | |
| 33 static const char kWebRtcInternalLogHandlerHostKey[]; | |
| 34 | |
| 35 explicit WebRtcInternalLogHandlerHost(Profile* profile); | |
| 36 | |
| 37 // Starts an audio debug recording. The recording lasts the given |delay|, | |
| 38 // unless |delay| is zero, in which case recording will continue until | |
| 39 // StopAudioDebugRecordings() is explicitly invoked. | |
| 40 // |callback| is invoked once recording stops. If |delay| is zero | |
| 41 // |callback| is invoked once recording starts. | |
| 42 // If a recording was already in progress, |error_callback| is invoked instead | |
| 43 // of |callback|. | |
| 44 void StartAudioDebugRecordings( | |
| 45 content::RenderProcessHost* host, | |
| 46 base::TimeDelta delay, | |
| 47 const TimeLimitedRecordingCallback& callback, | |
| 48 const TimeLimitedRecordingErrorCallback& error_callback); | |
| 49 | |
| 50 // Stops an audio debug recording. |callback| is invoked once recording | |
| 51 // stops. If no recording was in progress, |error_callback| is invoked instead | |
| 52 // of |callback|. | |
| 53 void StopAudioDebugRecordings( | |
| 54 content::RenderProcessHost* host, | |
| 55 const TimeLimitedRecordingCallback& callback, | |
| 56 const TimeLimitedRecordingErrorCallback& error_callback); | |
| 57 | |
| 58 // Starts an RTC event log. The call writes the most recent events to a | |
| 59 // file and then starts logging events for the given |delay|. | |
| 60 // If |delay| is zero, the logging will continue until StopRtcEventLogging() | |
| 61 // is explicitly invoked. | |
| 62 // |callback| is invoked once recording stops. If |delay| is zero | |
| 63 // |callback| is invoked once recording starts. | |
| 64 // If a recording was already in progress, |error_callback| is invoked instead | |
| 65 // of |callback|. | |
| 66 void StartRtcEventLogging( | |
| 67 content::RenderProcessHost* host, | |
| 68 base::TimeDelta delay, | |
| 69 const TimeLimitedRecordingCallback& callback, | |
| 70 const TimeLimitedRecordingErrorCallback& error_callback); | |
| 71 | |
| 72 // Stops an RTC event log. |callback| is invoked once recording | |
| 73 // stops. If no recording was in progress, |error_callback| is invoked instead | |
| 74 // of |callback|. | |
| 75 void StopRtcEventLogging( | |
| 76 content::RenderProcessHost* host, | |
| 77 const TimeLimitedRecordingCallback& callback, | |
| 78 const TimeLimitedRecordingErrorCallback& error_callback); | |
| 79 | |
| 80 private: | |
| 81 friend class content::BrowserThread; | |
| 82 friend class base::DeleteHelper<WebRtcInternalLogHandlerHost>; | |
| 83 friend class base::RefCountedThreadSafe<WebRtcInternalLogHandlerHost>; | |
| 84 | |
| 85 virtual ~WebRtcInternalLogHandlerHost(); | |
| 86 | |
| 87 base::FilePath GetLogDirectoryAndEnsureExists(); | |
| 88 | |
| 89 // Helper for starting audio debug recordings. | |
| 90 void DoStartAudioDebugRecordings( | |
| 91 content::RenderProcessHost* host, | |
| 92 base::TimeDelta delay, | |
| 93 const TimeLimitedRecordingCallback& callback, | |
| 94 const TimeLimitedRecordingErrorCallback& error_callback, | |
| 95 const base::FilePath& log_directory); | |
| 96 | |
| 97 // Helper for stopping audio debug recordings. | |
| 98 void DoStopAudioDebugRecordings( | |
| 99 content::RenderProcessHost* host, | |
| 100 bool is_manual_stop, | |
| 101 uint64_t audio_debug_recordings_id, | |
| 102 const TimeLimitedRecordingCallback& callback, | |
| 103 const TimeLimitedRecordingErrorCallback& error_callback, | |
| 104 const base::FilePath& log_directory); | |
| 105 | |
| 106 // Helper for starting RTC event logs. | |
| 107 void DoStartRtcEventLogging( | |
| 108 content::RenderProcessHost* host, | |
| 109 base::TimeDelta delay, | |
| 110 const TimeLimitedRecordingCallback& callback, | |
| 111 const TimeLimitedRecordingErrorCallback& error_callback, | |
| 112 const base::FilePath& log_directory); | |
| 113 | |
| 114 // Helper for stopping RTC event logs. | |
| 115 void DoStopRtcEventLogging( | |
| 116 content::RenderProcessHost* host, | |
| 117 bool is_manual_stop, | |
| 118 uint64_t audio_debug_recordings_id, | |
| 119 const TimeLimitedRecordingCallback& callback, | |
| 120 const TimeLimitedRecordingErrorCallback& error_callback, | |
| 121 const base::FilePath& log_directory); | |
| 122 | |
| 123 // The profile associated with our renderer process. | |
| 124 Profile* const profile_; | |
| 125 | |
| 126 // Must be accessed on the UI thread. | |
| 127 bool is_audio_debug_recordings_in_progress_; | |
| 128 | |
| 129 // This counter allows saving each debug recording in separate files. | |
| 130 uint64_t current_audio_debug_recordings_id_; | |
| 131 | |
| 132 // Must be accessed on the UI thread. | |
| 133 bool is_rtc_event_logging_in_progress_; | |
| 134 | |
| 135 // This counter allows saving each log in a separate file. | |
| 136 uint64_t current_rtc_event_log_id_; | |
| 137 | |
| 138 DISALLOW_COPY_AND_ASSIGN(WebRtcInternalLogHandlerHost); | |
| 139 }; | |
| 140 | |
| 141 #endif // CHROME_BROWSER_MEDIA_WEBRTC_INTERNAL_LOG_HANDLER_HOST_H_ | |
| OLD | NEW |