OLD | NEW |
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 Loading... |
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&)> | |
85 AudioDebugRecordingsErrorCallback; | |
86 typedef base::Callback<void(const std::string&, bool, bool)> | |
87 AudioDebugRecordingsCallback; | |
88 | 84 |
89 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader); | 85 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader); |
90 | 86 |
91 // Sets meta data that will be uploaded along with the log and also written | 87 // 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 | 88 // in the beginning of the log. Must be called on the IO thread before calling |
93 // StartLogging. | 89 // StartLogging. |
94 void SetMetaData(scoped_ptr<MetaDataMap> meta_data, | 90 void SetMetaData(scoped_ptr<MetaDataMap> meta_data, |
95 const GenericDoneCallback& callback); | 91 const GenericDoneCallback& callback); |
96 | 92 |
97 // Opens a log and starts logging. Must be called on the IO thread. | 93 // Opens a log and starts logging. Must be called on the IO thread. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // done. | 143 // done. |
148 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback); | 144 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback); |
149 | 145 |
150 // Called when an RTP packet is sent or received. Must be called on the UI | 146 // Called when an RTP packet is sent or received. Must be called on the UI |
151 // thread. | 147 // thread. |
152 void OnRtpPacket(scoped_ptr<uint8_t[]> packet_header, | 148 void OnRtpPacket(scoped_ptr<uint8_t[]> packet_header, |
153 size_t header_length, | 149 size_t header_length, |
154 size_t packet_length, | 150 size_t packet_length, |
155 bool incoming); | 151 bool incoming); |
156 | 152 |
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( | |
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: | 153 private: |
179 // States used for protecting from function calls made at non-allowed points | 154 // States used for protecting from function calls made at non-allowed points |
180 // in time. For example, StartLogging() is only allowed in CLOSED state. | 155 // in time. For example, StartLogging() is only allowed in CLOSED state. |
181 // Transitions: SetMetaData(): CLOSED -> CLOSED. | 156 // Transitions: SetMetaData(): CLOSED -> CLOSED. |
182 // StartLogging(): CLOSED -> STARTING. | 157 // StartLogging(): CLOSED -> STARTING. |
183 // Start done: STARTING -> STARTED. | 158 // Start done: STARTING -> STARTED. |
184 // StopLogging(): STARTED -> STOPPING. | 159 // StopLogging(): STARTED -> STOPPING. |
185 // Stop done: STOPPING -> STOPPED. | 160 // Stop done: STOPPING -> STOPPED. |
186 // UploadLog(): STOPPED -> UPLOADING. | 161 // UploadLog(): STOPPED -> UPLOADING. |
187 // Upload done: UPLOADING -> CLOSED. | 162 // Upload done: UPLOADING -> CLOSED. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 size_t packet_length, | 229 size_t packet_length, |
255 bool incoming); | 230 bool incoming); |
256 | 231 |
257 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths); | 232 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths); |
258 | 233 |
259 void FireGenericDoneCallback( | 234 void FireGenericDoneCallback( |
260 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, | 235 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, |
261 bool success, | 236 bool success, |
262 const std::string& error_message); | 237 const std::string& error_message); |
263 | 238 |
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_; | 239 scoped_ptr<WebRtcLogBuffer> log_buffer_; |
282 | 240 |
283 // The profile associated with our renderer process. | 241 // The profile associated with our renderer process. |
284 Profile* const profile_; | 242 Profile* const profile_; |
285 | 243 |
286 // These are only accessed on the IO thread, except when in STARTING state. In | 244 // 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 | 245 // this state we are protected since entering any function that alters the |
288 // state is not allowed. | 246 // state is not allowed. |
289 scoped_ptr<MetaDataMap> meta_data_; | 247 scoped_ptr<MetaDataMap> meta_data_; |
290 | 248 |
(...skipping 21 matching lines...) Expand all Loading... |
312 // The RTP dump handler responsible for creating the RTP header dump files. | 270 // The RTP dump handler responsible for creating the RTP header dump files. |
313 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_; | 271 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_; |
314 | 272 |
315 // The callback to call when StopRtpDump is called. | 273 // The callback to call when StopRtpDump is called. |
316 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_; | 274 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_; |
317 | 275 |
318 // A pointer to the log uploader that's shared for all profiles. | 276 // A pointer to the log uploader that's shared for all profiles. |
319 // Ownership lies with the browser process. | 277 // Ownership lies with the browser process. |
320 WebRtcLogUploader* const log_uploader_; | 278 WebRtcLogUploader* const log_uploader_; |
321 | 279 |
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); | 280 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); |
329 }; | 281 }; |
330 | 282 |
331 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ | 283 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ |
OLD | NEW |