Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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_RTC_EVENT_LOG_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_RTC_EVENT_LOG_HANDLER_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 // RtcEventLogHandler provides an interface to the internal logs | |
| 20 // in WebRTC: | |
| 21 // - 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.
| |
| 22 // - 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.
| |
| 23 class RtcEventLogHandler | |
| 24 : public base::RefCountedThreadSafe<RtcEventLogHandler> { | |
| 25 public: | |
| 26 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; | |
| 27 typedef base::Callback<void(const std::string&)> | |
| 28 TimeLimitedRecordingErrorCallback; | |
|
Henrik Grunell
2016/02/23 15:29:10
Drop "TimeLimited".
terelius-chromium
2016/03/02 10:01:10
Done.
| |
| 29 typedef base::Callback<void(const std::string&, bool, bool)> | |
| 30 TimeLimitedRecordingCallback; | |
| 31 | |
| 32 // 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.
| |
| 33 static const char kRtcEventLogHandlerKey[]; | |
| 34 | |
| 35 explicit RtcEventLogHandler(Profile* profile); | |
| 36 | |
| 37 // Starts an RTC event log. The call writes the most recent events to a | |
| 38 // file and then starts logging events for the given |delay|. | |
| 39 // If |delay| is zero, the logging will continue until StopRtcEventLogging() | |
| 40 // is explicitly invoked. | |
| 41 // |callback| is invoked once recording stops. If |delay| is zero | |
| 42 // |callback| is invoked once recording starts. | |
| 43 // If a recording was already in progress, |error_callback| is invoked instead | |
| 44 // of |callback|. | |
| 45 void StartRtcEventLogging( | |
| 46 content::RenderProcessHost* host, | |
| 47 base::TimeDelta delay, | |
| 48 const TimeLimitedRecordingCallback& callback, | |
| 49 const TimeLimitedRecordingErrorCallback& error_callback); | |
| 50 | |
| 51 // Stops an RTC event log. |callback| is invoked once recording | |
| 52 // stops. If no recording was in progress, |error_callback| is invoked instead | |
| 53 // of |callback|. | |
| 54 void StopRtcEventLogging( | |
| 55 content::RenderProcessHost* host, | |
| 56 const TimeLimitedRecordingCallback& callback, | |
| 57 const TimeLimitedRecordingErrorCallback& error_callback); | |
| 58 | |
| 59 private: | |
| 60 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.
| |
| 61 friend class base::DeleteHelper<RtcEventLogHandler>; | |
| 62 friend class base::RefCountedThreadSafe<RtcEventLogHandler>; | |
| 63 | |
| 64 virtual ~RtcEventLogHandler(); | |
| 65 | |
| 66 base::FilePath GetLogDirectoryAndEnsureExists(); | |
| 67 | |
| 68 // Helper for starting RTC event logs. | |
| 69 void DoStartRtcEventLogging( | |
| 70 content::RenderProcessHost* host, | |
| 71 base::TimeDelta delay, | |
| 72 const TimeLimitedRecordingCallback& callback, | |
| 73 const TimeLimitedRecordingErrorCallback& error_callback, | |
| 74 const base::FilePath& log_directory); | |
| 75 | |
| 76 // Helper for stopping RTC event logs. | |
| 77 void DoStopRtcEventLogging( | |
| 78 content::RenderProcessHost* host, | |
| 79 bool is_manual_stop, | |
| 80 uint64_t audio_debug_recordings_id, | |
| 81 const TimeLimitedRecordingCallback& callback, | |
| 82 const TimeLimitedRecordingErrorCallback& error_callback, | |
| 83 const base::FilePath& log_directory); | |
| 84 | |
| 85 // The profile associated with our renderer process. | |
| 86 Profile* const profile_; | |
| 87 | |
| 88 // Must be accessed on the UI thread. | |
| 89 bool is_rtc_event_logging_in_progress_; | |
| 90 | |
| 91 // This counter allows saving each log in a separate file. | |
| 92 uint64_t current_rtc_event_log_id_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(RtcEventLogHandler); | |
| 95 }; | |
| 96 | |
| 97 #endif // CHROME_BROWSER_MEDIA_RTC_EVENT_LOG_HANDLER_H_ | |
| OLD | NEW |