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

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: Fix bug in current time-limited audio debug recordings. Created 4 years, 8 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
11 #include <map>
12 #include <string>
13 #include <vector>
14
11 #include "base/macros.h" 15 #include "base/macros.h"
12 #include "base/memory/shared_memory.h" 16 #include "base/memory/shared_memory.h"
13 #include "build/build_config.h" 17 #include "build/build_config.h"
14 #include "chrome/browser/media/rtp_dump_type.h" 18 #include "chrome/browser/media/rtp_dump_type.h"
15 #include "chrome/browser/media/webrtc_rtp_dump_handler.h" 19 #include "chrome/browser/media/webrtc_rtp_dump_handler.h"
16 #include "chrome/common/media/webrtc_logging_message_data.h" 20 #include "chrome/common/media/webrtc_logging_message_data.h"
17 #include "chrome/common/partial_circular_buffer.h" 21 #include "chrome/common/partial_circular_buffer.h"
18 #include "content/public/browser/browser_message_filter.h" 22 #include "content/public/browser/browser_message_filter.h"
19 #include "content/public/browser/render_process_host.h" 23 #include "content/public/browser/render_process_host.h"
20 #include "net/base/network_interfaces.h" 24 #include "net/base/network_interfaces.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // - Informs the handler in the render process when to stop logging. 78 // - Informs the handler in the render process when to stop logging.
75 // - Closes the shared memory (and thereby discarding it) or triggers uploading 79 // - Closes the shared memory (and thereby discarding it) or triggers uploading
76 // of the log. 80 // of the log.
77 // - Detects when channel, i.e. renderer, is going away and possibly triggers 81 // - Detects when channel, i.e. renderer, is going away and possibly triggers
78 // uploading the log. 82 // uploading the log.
79 class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { 83 class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
80 public: 84 public:
81 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; 85 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback;
82 typedef base::Callback<void(bool, const std::string&, const std::string&)> 86 typedef base::Callback<void(bool, const std::string&, const std::string&)>
83 UploadDoneCallback; 87 UploadDoneCallback;
84 typedef base::Callback<void(const std::string&)> 88
85 AudioDebugRecordingsErrorCallback; 89 // Key used to attach the handler to the RenderProcessHost.
86 typedef base::Callback<void(const std::string&, bool, bool)> 90 static const char kWebRtcLoggingHandlerHostKey[];
87 AudioDebugRecordingsCallback;
88 91
89 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader); 92 WebRtcLoggingHandlerHost(Profile* profile, WebRtcLogUploader* log_uploader);
90 93
91 // Sets meta data that will be uploaded along with the log and also written 94 // 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 95 // in the beginning of the log. Must be called on the IO thread before calling
93 // StartLogging. 96 // StartLogging.
94 void SetMetaData(scoped_ptr<MetaDataMap> meta_data, 97 void SetMetaData(scoped_ptr<MetaDataMap> meta_data,
95 const GenericDoneCallback& callback); 98 const GenericDoneCallback& callback);
96 99
97 // Opens a log and starts logging. Must be called on the IO thread. 100 // 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
147 // done. 150 // done.
148 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback); 151 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback);
149 152
150 // Called when an RTP packet is sent or received. Must be called on the UI 153 // Called when an RTP packet is sent or received. Must be called on the UI
151 // thread. 154 // thread.
152 void OnRtpPacket(scoped_ptr<uint8_t[]> packet_header, 155 void OnRtpPacket(scoped_ptr<uint8_t[]> packet_header,
153 size_t header_length, 156 size_t header_length,
154 size_t packet_length, 157 size_t packet_length,
155 bool incoming); 158 bool incoming);
156 159
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: 160 private:
179 // States used for protecting from function calls made at non-allowed points 161 // States used for protecting from function calls made at non-allowed points
180 // in time. For example, StartLogging() is only allowed in CLOSED state. 162 // in time. For example, StartLogging() is only allowed in CLOSED state.
181 // Transitions: SetMetaData(): CLOSED -> CLOSED. 163 // Transitions: SetMetaData(): CLOSED -> CLOSED.
182 // StartLogging(): CLOSED -> STARTING. 164 // StartLogging(): CLOSED -> STARTING.
183 // Start done: STARTING -> STARTED. 165 // Start done: STARTING -> STARTED.
184 // StopLogging(): STARTED -> STOPPING. 166 // StopLogging(): STARTED -> STOPPING.
185 // Stop done: STOPPING -> STOPPED. 167 // Stop done: STOPPING -> STOPPED.
186 // UploadLog(): STOPPED -> UPLOADING. 168 // UploadLog(): STOPPED -> UPLOADING.
187 // Upload done: UPLOADING -> CLOSED. 169 // Upload done: UPLOADING -> CLOSED.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 size_t packet_length, 236 size_t packet_length,
255 bool incoming); 237 bool incoming);
256 238
257 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths); 239 bool ReleaseRtpDumps(WebRtcLogPaths* log_paths);
258 240
259 void FireGenericDoneCallback( 241 void FireGenericDoneCallback(
260 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, 242 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback,
261 bool success, 243 bool success,
262 const std::string& error_message); 244 const std::string& error_message);
263 245
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_; 246 scoped_ptr<WebRtcLogBuffer> log_buffer_;
282 247
283 // The profile associated with our renderer process. 248 // The profile associated with our renderer process.
284 Profile* const profile_; 249 Profile* const profile_;
285 250
286 // These are only accessed on the IO thread, except when in STARTING state. In 251 // 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 252 // this state we are protected since entering any function that alters the
288 // state is not allowed. 253 // state is not allowed.
289 scoped_ptr<MetaDataMap> meta_data_; 254 scoped_ptr<MetaDataMap> meta_data_;
290 255
(...skipping 21 matching lines...) Expand all
312 // The RTP dump handler responsible for creating the RTP header dump files. 277 // The RTP dump handler responsible for creating the RTP header dump files.
313 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_; 278 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_;
314 279
315 // The callback to call when StopRtpDump is called. 280 // The callback to call when StopRtpDump is called.
316 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_; 281 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_;
317 282
318 // A pointer to the log uploader that's shared for all profiles. 283 // A pointer to the log uploader that's shared for all profiles.
319 // Ownership lies with the browser process. 284 // Ownership lies with the browser process.
320 WebRtcLogUploader* const log_uploader_; 285 WebRtcLogUploader* const log_uploader_;
321 286
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); 287 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
329 }; 288 };
330 289
331 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 290 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698