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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "chrome/browser/media/rtp_dump_type.h" | 10 #include "chrome/browser/media/rtp_dump_type.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // - Informs the handler in the render process when to stop logging. | 70 // - Informs the handler in the render process when to stop logging. |
71 // - Closes the shared memory (and thereby discarding it) or triggers uploading | 71 // - Closes the shared memory (and thereby discarding it) or triggers uploading |
72 // of the log. | 72 // of the log. |
73 // - Detects when channel, i.e. renderer, is going away and possibly triggers | 73 // - Detects when channel, i.e. renderer, is going away and possibly triggers |
74 // uploading the log. | 74 // uploading the log. |
75 class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { | 75 class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { |
76 public: | 76 public: |
77 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; | 77 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; |
78 typedef base::Callback<void(bool, const std::string&, const std::string&)> | 78 typedef base::Callback<void(bool, const std::string&, const std::string&)> |
79 UploadDoneCallback; | 79 UploadDoneCallback; |
| 80 typedef base::Callback<void(const std::string&)> |
| 81 AudioDebugRecordingsErrorCallback; |
| 82 typedef base::Callback<void(const std::string&, bool, bool)> |
| 83 AudioDebugRecordingsCallback; |
80 | 84 |
81 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader); | 85 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader); |
82 | 86 |
83 // 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 |
84 // 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 |
85 // StartLogging. | 89 // StartLogging. |
86 void SetMetaData(scoped_ptr<MetaDataMap> meta_data, | 90 void SetMetaData(scoped_ptr<MetaDataMap> meta_data, |
87 const GenericDoneCallback& callback); | 91 const GenericDoneCallback& callback); |
88 | 92 |
89 // 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... |
139 // done. | 143 // done. |
140 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback); | 144 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback); |
141 | 145 |
142 // 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 |
143 // thread. | 147 // thread. |
144 void OnRtpPacket(scoped_ptr<uint8[]> packet_header, | 148 void OnRtpPacket(scoped_ptr<uint8[]> packet_header, |
145 size_t header_length, | 149 size_t header_length, |
146 size_t packet_length, | 150 size_t packet_length, |
147 bool incoming); | 151 bool incoming); |
148 | 152 |
| 153 // Starts an audio debug recording. The recording lasts the given |delay|, |
| 154 // unless |delay| is zero, in which case recording will continue until |
| 155 // StopAudioDebugRecordings() is explicitly invoked. |
| 156 // |callback| is invoked once recording stops. If |delay| is zero |
| 157 // |callback| is invoked once recording starts. |
| 158 // If a recording was already in progress, |error_callback| is invoked instead |
| 159 // of |callback|. |
| 160 void StartAudioDebugRecordings( |
| 161 content::RenderProcessHost* host, |
| 162 base::TimeDelta delay, |
| 163 const AudioDebugRecordingsCallback& callback, |
| 164 const AudioDebugRecordingsErrorCallback& error_callback); |
| 165 |
| 166 // Stops an audio debug recording. |callback| is invoked once recording |
| 167 // stops. If no recording was in progress, |error_callback| is invoked instead |
| 168 // of |callback|. |
| 169 void StopAudioDebugRecordings( |
| 170 content::RenderProcessHost* host, |
| 171 const AudioDebugRecordingsCallback& callback, |
| 172 const AudioDebugRecordingsErrorCallback& error_callback); |
| 173 |
149 private: | 174 private: |
150 // States used for protecting from function calls made at non-allowed points | 175 // States used for protecting from function calls made at non-allowed points |
151 // in time. For example, StartLogging() is only allowed in CLOSED state. | 176 // in time. For example, StartLogging() is only allowed in CLOSED state. |
152 // Transitions: SetMetaData(): CLOSED -> CLOSED. | 177 // Transitions: SetMetaData(): CLOSED -> CLOSED. |
153 // StartLogging(): CLOSED -> STARTING. | 178 // StartLogging(): CLOSED -> STARTING. |
154 // Start done: STARTING -> STARTED. | 179 // Start done: STARTING -> STARTED. |
155 // StopLogging(): STARTED -> STOPPING. | 180 // StopLogging(): STARTED -> STOPPING. |
156 // Stop done: STOPPING -> STOPPED. | 181 // Stop done: STOPPING -> STOPPED. |
157 // UploadLog(): STOPPED -> UPLOADING. | 182 // UploadLog(): STOPPED -> UPLOADING. |
158 // Upload done: UPLOADING -> CLOSED. | 183 // Upload done: UPLOADING -> CLOSED. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 size_t packet_length, | 250 size_t packet_length, |
226 bool incoming); | 251 bool incoming); |
227 | 252 |
228 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths); | 253 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths); |
229 | 254 |
230 void FireGenericDoneCallback( | 255 void FireGenericDoneCallback( |
231 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, | 256 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, |
232 bool success, | 257 bool success, |
233 const std::string& error_message); | 258 const std::string& error_message); |
234 | 259 |
| 260 // Helper for starting audio debug recordings. |
| 261 void DoStartAudioDebugRecordings( |
| 262 content::RenderProcessHost* host, |
| 263 base::TimeDelta delay, |
| 264 const AudioDebugRecordingsCallback& callback, |
| 265 const AudioDebugRecordingsErrorCallback& error_callback, |
| 266 base::FilePath log_directory); |
| 267 |
| 268 // Helper for stopping audio debug recordings. |
| 269 void DoStopAudioDebugRecordings( |
| 270 content::RenderProcessHost* host, |
| 271 bool is_manual_stop, |
| 272 uint64_t audio_debug_recordings_id, |
| 273 const AudioDebugRecordingsCallback& callback, |
| 274 const AudioDebugRecordingsErrorCallback& error_callback, |
| 275 base::FilePath log_directory); |
| 276 |
235 scoped_ptr<WebRtcLogBuffer> log_buffer_; | 277 scoped_ptr<WebRtcLogBuffer> log_buffer_; |
236 | 278 |
237 // The profile associated with our renderer process. | 279 // The profile associated with our renderer process. |
238 Profile* const profile_; | 280 Profile* const profile_; |
239 | 281 |
240 // These are only accessed on the IO thread, except when in STARTING state. In | 282 // These are only accessed on the IO thread, except when in STARTING state. In |
241 // this state we are protected since entering any function that alters the | 283 // this state we are protected since entering any function that alters the |
242 // state is not allowed. | 284 // state is not allowed. |
243 scoped_ptr<MetaDataMap> meta_data_; | 285 scoped_ptr<MetaDataMap> meta_data_; |
244 | 286 |
(...skipping 21 matching lines...) Expand all Loading... |
266 // The RTP dump handler responsible for creating the RTP header dump files. | 308 // The RTP dump handler responsible for creating the RTP header dump files. |
267 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_; | 309 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_; |
268 | 310 |
269 // The callback to call when StopRtpDump is called. | 311 // The callback to call when StopRtpDump is called. |
270 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_; | 312 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_; |
271 | 313 |
272 // A pointer to the log uploader that's shared for all profiles. | 314 // A pointer to the log uploader that's shared for all profiles. |
273 // Ownership lies with the browser process. | 315 // Ownership lies with the browser process. |
274 WebRtcLogUploader* const log_uploader_; | 316 WebRtcLogUploader* const log_uploader_; |
275 | 317 |
| 318 // Must be accessed on the UI thread. |
| 319 bool is_audio_debug_recordings_in_progress_; |
| 320 |
| 321 // This counter allows saving each debug recording in separate files. |
| 322 uint64_t current_audio_debug_recordings_id_; |
| 323 |
276 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); | 324 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); |
277 }; | 325 }; |
278 | 326 |
279 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ | 327 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ |
OLD | NEW |