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

Side by Side Diff: chrome/browser/media/webrtc_logging_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: 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // - Closes the shared memory (and thereby discarding it) or triggers uploading 75 // - Closes the shared memory (and thereby discarding it) or triggers uploading
76 // of the log. 76 // of the log.
77 // - Detects when channel, i.e. renderer, is going away and possibly triggers 77 // - Detects when channel, i.e. renderer, is going away and possibly triggers
78 // uploading the log. 78 // uploading the log.
79 class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { 79 class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
80 public: 80 public:
81 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; 81 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback;
82 typedef base::Callback<void(bool, const std::string&, const std::string&)> 82 typedef base::Callback<void(bool, const std::string&, const std::string&)>
83 UploadDoneCallback; 83 UploadDoneCallback;
84 typedef base::Callback<void(const std::string&)> 84 typedef base::Callback<void(const std::string&)>
85 AudioDebugRecordingsErrorCallback; 85 TimeLimitedRecordingErrorCallback;
86 typedef base::Callback<void(const std::string&, bool, bool)> 86 typedef base::Callback<void(const std::string&, bool, bool)>
87 AudioDebugRecordingsCallback; 87 TimeLimitedRecordingCallback;
88 88
89 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader); 89 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader);
90 90
91 // Sets meta data that will be uploaded along with the log and also written 91 // Sets meta data that will be uploaded along with the log and also written
92 // in the beginning of the log. Must be called on the IO thread before calling 92 // in the beginning of the log. Must be called on the IO thread before calling
93 // StartLogging. 93 // StartLogging.
94 void SetMetaData(scoped_ptr<MetaDataMap> meta_data, 94 void SetMetaData(scoped_ptr<MetaDataMap> meta_data,
95 const GenericDoneCallback& callback); 95 const GenericDoneCallback& callback);
96 96
97 // Opens a log and starts logging. Must be called on the IO thread. 97 // Opens a log and starts logging. Must be called on the IO thread.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // Starts an audio debug recording. The recording lasts the given |delay|, 157 // Starts an audio debug recording. The recording lasts the given |delay|,
158 // unless |delay| is zero, in which case recording will continue until 158 // unless |delay| is zero, in which case recording will continue until
159 // StopAudioDebugRecordings() is explicitly invoked. 159 // StopAudioDebugRecordings() is explicitly invoked.
160 // |callback| is invoked once recording stops. If |delay| is zero 160 // |callback| is invoked once recording stops. If |delay| is zero
161 // |callback| is invoked once recording starts. 161 // |callback| is invoked once recording starts.
162 // If a recording was already in progress, |error_callback| is invoked instead 162 // If a recording was already in progress, |error_callback| is invoked instead
163 // of |callback|. 163 // of |callback|.
164 void StartAudioDebugRecordings( 164 void StartAudioDebugRecordings(
165 content::RenderProcessHost* host, 165 content::RenderProcessHost* host,
166 base::TimeDelta delay, 166 base::TimeDelta delay,
167 const AudioDebugRecordingsCallback& callback, 167 const TimeLimitedRecordingCallback& callback,
168 const AudioDebugRecordingsErrorCallback& error_callback); 168 const TimeLimitedRecordingErrorCallback& error_callback);
169 169
170 // Stops an audio debug recording. |callback| is invoked once recording 170 // Stops an audio debug recording. |callback| is invoked once recording
171 // stops. If no recording was in progress, |error_callback| is invoked instead 171 // stops. If no recording was in progress, |error_callback| is invoked instead
172 // of |callback|. 172 // of |callback|.
173 void StopAudioDebugRecordings( 173 void StopAudioDebugRecordings(
174 content::RenderProcessHost* host, 174 content::RenderProcessHost* host,
175 const AudioDebugRecordingsCallback& callback, 175 const TimeLimitedRecordingCallback& callback,
176 const AudioDebugRecordingsErrorCallback& error_callback); 176 const TimeLimitedRecordingErrorCallback& error_callback);
177
178 // Starts an RTC event log. The call writes the most recent events to a
Henrik Grunell 2016/02/01 13:58:13 This class was originally only for the WebRTC nati
terelius1 2016/02/16 20:09:12 Done.
179 // file and then starts logging events for the given |delay|.
180 // If |delay| is zero, the logging will continue until StopRtcEventLogging()
181 // is explicitly invoked.
182 // |callback| is invoked once recording stops. If |delay| is zero
183 // |callback| is invoked once recording starts.
184 // If a recording was already in progress, |error_callback| is invoked instead
185 // of |callback|.
186 void StartRtcEventLogging(
187 content::RenderProcessHost* host,
188 base::TimeDelta delay,
189 const TimeLimitedRecordingCallback& callback,
190 const TimeLimitedRecordingErrorCallback& error_callback);
191
192 // Stops an RTC event log. |callback| is invoked once recording
193 // stops. If no recording was in progress, |error_callback| is invoked instead
194 // of |callback|.
195 void StopRtcEventLogging(
196 content::RenderProcessHost* host,
197 const TimeLimitedRecordingCallback& callback,
198 const TimeLimitedRecordingErrorCallback& error_callback);
177 199
178 private: 200 private:
179 // States used for protecting from function calls made at non-allowed points 201 // States used for protecting from function calls made at non-allowed points
180 // in time. For example, StartLogging() is only allowed in CLOSED state. 202 // in time. For example, StartLogging() is only allowed in CLOSED state.
181 // Transitions: SetMetaData(): CLOSED -> CLOSED. 203 // Transitions: SetMetaData(): CLOSED -> CLOSED.
182 // StartLogging(): CLOSED -> STARTING. 204 // StartLogging(): CLOSED -> STARTING.
183 // Start done: STARTING -> STARTED. 205 // Start done: STARTING -> STARTED.
184 // StopLogging(): STARTED -> STOPPING. 206 // StopLogging(): STARTED -> STOPPING.
185 // Stop done: STOPPING -> STOPPED. 207 // Stop done: STOPPING -> STOPPED.
186 // UploadLog(): STOPPED -> UPLOADING. 208 // UploadLog(): STOPPED -> UPLOADING.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 280
259 void FireGenericDoneCallback( 281 void FireGenericDoneCallback(
260 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, 282 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback,
261 bool success, 283 bool success,
262 const std::string& error_message); 284 const std::string& error_message);
263 285
264 // Helper for starting audio debug recordings. 286 // Helper for starting audio debug recordings.
265 void DoStartAudioDebugRecordings( 287 void DoStartAudioDebugRecordings(
266 content::RenderProcessHost* host, 288 content::RenderProcessHost* host,
267 base::TimeDelta delay, 289 base::TimeDelta delay,
268 const AudioDebugRecordingsCallback& callback, 290 const TimeLimitedRecordingCallback& callback,
269 const AudioDebugRecordingsErrorCallback& error_callback, 291 const TimeLimitedRecordingErrorCallback& error_callback,
270 const base::FilePath& log_directory); 292 const base::FilePath& log_directory);
271 293
272 // Helper for stopping audio debug recordings. 294 // Helper for stopping audio debug recordings.
273 void DoStopAudioDebugRecordings( 295 void DoStopAudioDebugRecordings(
274 content::RenderProcessHost* host, 296 content::RenderProcessHost* host,
275 bool is_manual_stop, 297 bool is_manual_stop,
276 uint64_t audio_debug_recordings_id, 298 uint64_t audio_debug_recordings_id,
277 const AudioDebugRecordingsCallback& callback, 299 const TimeLimitedRecordingCallback& callback,
278 const AudioDebugRecordingsErrorCallback& error_callback, 300 const TimeLimitedRecordingErrorCallback& error_callback,
301 const base::FilePath& log_directory);
302
303 // Helper for starting RTC event logs.
304 void DoStartRtcEventLogging(
305 content::RenderProcessHost* host,
306 base::TimeDelta delay,
307 const TimeLimitedRecordingCallback& callback,
308 const TimeLimitedRecordingErrorCallback& error_callback,
309 const base::FilePath& log_directory);
310
311 // Helper for stopping RTC event logs.
312 void DoStopRtcEventLogging(
313 content::RenderProcessHost* host,
314 bool is_manual_stop,
315 uint64_t audio_debug_recordings_id,
316 const TimeLimitedRecordingCallback& callback,
317 const TimeLimitedRecordingErrorCallback& error_callback,
279 const base::FilePath& log_directory); 318 const base::FilePath& log_directory);
280 319
281 scoped_ptr<WebRtcLogBuffer> log_buffer_; 320 scoped_ptr<WebRtcLogBuffer> log_buffer_;
282 321
283 // The profile associated with our renderer process. 322 // The profile associated with our renderer process.
284 Profile* const profile_; 323 Profile* const profile_;
285 324
286 // These are only accessed on the IO thread, except when in STARTING state. In 325 // These are only accessed on the IO thread, except when in STARTING state. In
287 // this state we are protected since entering any function that alters the 326 // this state we are protected since entering any function that alters the
288 // state is not allowed. 327 // state is not allowed.
(...skipping 29 matching lines...) Expand all
318 // A pointer to the log uploader that's shared for all profiles. 357 // A pointer to the log uploader that's shared for all profiles.
319 // Ownership lies with the browser process. 358 // Ownership lies with the browser process.
320 WebRtcLogUploader* const log_uploader_; 359 WebRtcLogUploader* const log_uploader_;
321 360
322 // Must be accessed on the UI thread. 361 // Must be accessed on the UI thread.
323 bool is_audio_debug_recordings_in_progress_; 362 bool is_audio_debug_recordings_in_progress_;
324 363
325 // This counter allows saving each debug recording in separate files. 364 // This counter allows saving each debug recording in separate files.
326 uint64_t current_audio_debug_recordings_id_; 365 uint64_t current_audio_debug_recordings_id_;
327 366
367 // Must be accessed on the UI thread.
368 bool is_rtc_event_logging_in_progress_;
369
370 // This counter allows saving each log in a separate file.
371 uint64_t current_rtc_event_log_id_;
372
328 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); 373 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
329 }; 374 };
330 375
331 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 376 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698