Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: chrome/browser/media/webrtc_internal_log_handler_host.h

Issue 1650133002: Start and stop RTC event logs from private extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create a new handler for the internal WebRTC logs instead of using WebRTCLoggingHandlerHost. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 AEC dumps / AudioDebugRecordings.
22 // - Starts and stops RTC event logs.
23 // - In the future, detects when channel, i.e. renderer, is going away and
24 // possibly triggers uploading the log.
25 class WebRtcInternalLogHandlerHost : public content::BrowserMessageFilter {
26 public:
27 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback;
28 typedef base::Callback<void(const std::string&)>
29 TimeLimitedRecordingErrorCallback;
30 typedef base::Callback<void(const std::string&, bool, bool)>
31 TimeLimitedRecordingCallback;
32
33 explicit WebRtcInternalLogHandlerHost(Profile* profile);
34
35 // Starts an audio debug recording. The recording lasts the given |delay|,
36 // unless |delay| is zero, in which case recording will continue until
37 // StopAudioDebugRecordings() is explicitly invoked.
38 // |callback| is invoked once recording stops. If |delay| is zero
39 // |callback| is invoked once recording starts.
40 // If a recording was already in progress, |error_callback| is invoked instead
41 // of |callback|.
42 void StartAudioDebugRecordings(
43 content::RenderProcessHost* host,
44 base::TimeDelta delay,
45 const TimeLimitedRecordingCallback& callback,
46 const TimeLimitedRecordingErrorCallback& error_callback);
47
48 // Stops an audio debug recording. |callback| is invoked once recording
49 // stops. If no recording was in progress, |error_callback| is invoked instead
50 // of |callback|.
51 void StopAudioDebugRecordings(
52 content::RenderProcessHost* host,
53 const TimeLimitedRecordingCallback& callback,
54 const TimeLimitedRecordingErrorCallback& error_callback);
55
56 // Starts an RTC event log. The call writes the most recent events to a
57 // file and then starts logging events for the given |delay|.
58 // If |delay| is zero, the logging will continue until StopRtcEventLogging()
59 // is explicitly invoked.
60 // |callback| is invoked once recording stops. If |delay| is zero
61 // |callback| is invoked once recording starts.
62 // If a recording was already in progress, |error_callback| is invoked instead
63 // of |callback|.
64 void StartRtcEventLogging(
65 content::RenderProcessHost* host,
66 base::TimeDelta delay,
67 const TimeLimitedRecordingCallback& callback,
68 const TimeLimitedRecordingErrorCallback& error_callback);
69
70 // Stops an RTC event log. |callback| is invoked once recording
71 // stops. If no recording was in progress, |error_callback| is invoked instead
72 // of |callback|.
73 void StopRtcEventLogging(
74 content::RenderProcessHost* host,
75 const TimeLimitedRecordingCallback& callback,
76 const TimeLimitedRecordingErrorCallback& error_callback);
77
78 private:
79 friend class content::BrowserThread;
80 friend class base::DeleteHelper<WebRtcInternalLogHandlerHost>;
81
82 ~WebRtcInternalLogHandlerHost() override;
83
84 // BrowserMessageFilter implementation.
85 void OnChannelClosing() override;
86 void OnDestruct() const override;
87 bool OnMessageReceived(const IPC::Message& message) override;
88
89 base::FilePath GetLogDirectoryAndEnsureExists();
90
91 // Helper for starting audio debug recordings.
92 void DoStartAudioDebugRecordings(
93 content::RenderProcessHost* host,
94 base::TimeDelta delay,
95 const TimeLimitedRecordingCallback& callback,
96 const TimeLimitedRecordingErrorCallback& error_callback,
97 const base::FilePath& log_directory);
98
99 // Helper for stopping audio debug recordings.
100 void DoStopAudioDebugRecordings(
101 content::RenderProcessHost* host,
102 bool is_manual_stop,
103 uint64_t audio_debug_recordings_id,
104 const TimeLimitedRecordingCallback& callback,
105 const TimeLimitedRecordingErrorCallback& error_callback,
106 const base::FilePath& log_directory);
107
108 // Helper for starting RTC event logs.
109 void DoStartRtcEventLogging(
110 content::RenderProcessHost* host,
111 base::TimeDelta delay,
112 const TimeLimitedRecordingCallback& callback,
113 const TimeLimitedRecordingErrorCallback& error_callback,
114 const base::FilePath& log_directory);
115
116 // Helper for stopping RTC event logs.
117 void DoStopRtcEventLogging(
118 content::RenderProcessHost* host,
119 bool is_manual_stop,
120 uint64_t audio_debug_recordings_id,
121 const TimeLimitedRecordingCallback& callback,
122 const TimeLimitedRecordingErrorCallback& error_callback,
123 const base::FilePath& log_directory);
124
125 // The profile associated with our renderer process.
126 Profile* const profile_;
127
128 // Must be accessed on the UI thread.
129 bool is_audio_debug_recordings_in_progress_;
130
131 // This counter allows saving each debug recording in separate files.
132 uint64_t current_audio_debug_recordings_id_;
133
134 // Must be accessed on the UI thread.
135 bool is_rtc_event_logging_in_progress_;
136
137 // This counter allows saving each log in a separate file.
138 uint64_t current_rtc_event_log_id_;
139
140 DISALLOW_COPY_AND_ASSIGN(WebRtcInternalLogHandlerHost);
141 };
142
143 #endif // CHROME_BROWSER_MEDIA_WEBRTC_INTERNAL_LOG_HANDLER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698