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: Split the logging handler into one for audio recordings and one for event logs 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // - Informs the handler in the render process when to stop logging. 74 // - Informs the handler in the render process when to stop logging.
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
85 AudioDebugRecordingsErrorCallback; 85 // Key used to attach the handler to the RenderProcessHost.
86 typedef base::Callback<void(const std::string&, bool, bool)> 86 static const char kWebRtcLoggingHandlerHostKey[];
87 AudioDebugRecordingsCallback;
88 87
89 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader); 88 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader);
90 89
91 // Sets meta data that will be uploaded along with the log and also written 90 // 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 91 // in the beginning of the log. Must be called on the IO thread before calling
93 // StartLogging. 92 // StartLogging.
94 void SetMetaData(scoped_ptr<MetaDataMap> meta_data, 93 void SetMetaData(scoped_ptr<MetaDataMap> meta_data,
95 const GenericDoneCallback& callback); 94 const GenericDoneCallback& callback);
96 95
97 // Opens a log and starts logging. Must be called on the IO thread. 96 // Opens a log and starts logging. Must be called on the IO thread.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // should be stopped. |callback| will be called when stopping the dump is 145 // should be stopped. |callback| will be called when stopping the dump is
147 // done. 146 // done.
148 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback); 147 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback);
149 148
150 // Called when an RTP packet is sent or received. Must be called on the UI 149 // Called when an RTP packet is sent or received. Must be called on the UI
151 // thread. 150 // thread.
152 void OnRtpPacket(scoped_ptr<uint8_t[]> packet_header, 151 void OnRtpPacket(scoped_ptr<uint8_t[]> packet_header,
153 size_t header_length, 152 size_t header_length,
154 size_t packet_length, 153 size_t packet_length,
155 bool incoming); 154 bool incoming);
156
157 // Starts an audio debug recording. The recording lasts the given |delay|,
158 // unless |delay| is zero, in which case recording will continue until
159 // StopAudioDebugRecordings() is explicitly invoked.
160 // |callback| is invoked once recording stops. If |delay| is zero
161 // |callback| is invoked once recording starts.
162 // If a recording was already in progress, |error_callback| is invoked instead
163 // of |callback|.
164 void StartAudioDebugRecordings(
Henrik Grunell 2016/02/23 15:29:11 Thanks for moving this out!
terelius-chromium 2016/03/02 10:01:10 Acknowledged.
165 content::RenderProcessHost* host,
166 base::TimeDelta delay,
167 const AudioDebugRecordingsCallback& callback,
168 const AudioDebugRecordingsErrorCallback& error_callback);
169
170 // Stops an audio debug recording. |callback| is invoked once recording
171 // stops. If no recording was in progress, |error_callback| is invoked instead
172 // of |callback|.
173 void StopAudioDebugRecordings(
174 content::RenderProcessHost* host,
175 const AudioDebugRecordingsCallback& callback,
176 const AudioDebugRecordingsErrorCallback& error_callback);
177
178 private: 155 private:
179 // States used for protecting from function calls made at non-allowed points 156 // States used for protecting from function calls made at non-allowed points
180 // in time. For example, StartLogging() is only allowed in CLOSED state. 157 // in time. For example, StartLogging() is only allowed in CLOSED state.
181 // Transitions: SetMetaData(): CLOSED -> CLOSED. 158 // Transitions: SetMetaData(): CLOSED -> CLOSED.
182 // StartLogging(): CLOSED -> STARTING. 159 // StartLogging(): CLOSED -> STARTING.
183 // Start done: STARTING -> STARTED. 160 // Start done: STARTING -> STARTED.
184 // StopLogging(): STARTED -> STOPPING. 161 // StopLogging(): STARTED -> STOPPING.
185 // Stop done: STOPPING -> STOPPED. 162 // Stop done: STOPPING -> STOPPED.
186 // UploadLog(): STOPPED -> UPLOADING. 163 // UploadLog(): STOPPED -> UPLOADING.
187 // Upload done: UPLOADING -> CLOSED. 164 // Upload done: UPLOADING -> CLOSED.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 size_t packet_length, 231 size_t packet_length,
255 bool incoming); 232 bool incoming);
256 233
257 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths); 234 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths);
258 235
259 void FireGenericDoneCallback( 236 void FireGenericDoneCallback(
260 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, 237 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback,
261 bool success, 238 bool success,
262 const std::string& error_message); 239 const std::string& error_message);
263 240
264 // Helper for starting audio debug recordings.
265 void DoStartAudioDebugRecordings(
266 content::RenderProcessHost* host,
267 base::TimeDelta delay,
268 const AudioDebugRecordingsCallback& callback,
269 const AudioDebugRecordingsErrorCallback& error_callback,
270 const base::FilePath& log_directory);
271
272 // Helper for stopping audio debug recordings.
273 void DoStopAudioDebugRecordings(
274 content::RenderProcessHost* host,
275 bool is_manual_stop,
276 uint64_t audio_debug_recordings_id,
277 const AudioDebugRecordingsCallback& callback,
278 const AudioDebugRecordingsErrorCallback& error_callback,
279 const base::FilePath& log_directory);
280
281 scoped_ptr<WebRtcLogBuffer> log_buffer_; 241 scoped_ptr<WebRtcLogBuffer> log_buffer_;
282 242
283 // The profile associated with our renderer process. 243 // The profile associated with our renderer process.
284 Profile* const profile_; 244 Profile* const profile_;
285 245
286 // These are only accessed on the IO thread, except when in STARTING state. In 246 // 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 247 // this state we are protected since entering any function that alters the
288 // state is not allowed. 248 // state is not allowed.
289 scoped_ptr<MetaDataMap> meta_data_; 249 scoped_ptr<MetaDataMap> meta_data_;
290 250
(...skipping 21 matching lines...) Expand all
312 // The RTP dump handler responsible for creating the RTP header dump files. 272 // The RTP dump handler responsible for creating the RTP header dump files.
313 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_; 273 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_;
314 274
315 // The callback to call when StopRtpDump is called. 275 // The callback to call when StopRtpDump is called.
316 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_; 276 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_;
317 277
318 // A pointer to the log uploader that's shared for all profiles. 278 // A pointer to the log uploader that's shared for all profiles.
319 // Ownership lies with the browser process. 279 // Ownership lies with the browser process.
320 WebRtcLogUploader* const log_uploader_; 280 WebRtcLogUploader* const log_uploader_;
321 281
322 // Must be accessed on the UI thread.
323 bool is_audio_debug_recordings_in_progress_;
324
325 // This counter allows saving each debug recording in separate files.
326 uint64_t current_audio_debug_recordings_id_;
327
328 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); 282 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
329 }; 283 };
330 284
331 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 285 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698