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

Side by Side Diff: chrome/browser/media/webrtc_event_log_handler.h

Issue 1855193002: Move the call to enable the WebRTC event log from PeerConnectionFactory to PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduced WebRTCCallbackInterface. Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_EVENT_LOG_HANDLER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_EVENT_LOG_HANDLER_H_
6 #define CHROME_BROWSER_MEDIA_WEBRTC_EVENT_LOG_HANDLER_H_ 6 #define CHROME_BROWSER_MEDIA_WEBRTC_EVENT_LOG_HANDLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <set>
11 #include <string> 12 #include <string>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 19
19 namespace content { 20 namespace content {
20 class RenderProcessHost; 21 class RenderProcessHost;
21 } // namespace content 22 } // namespace content
22 class Profile; 23 class Profile;
23 24
24 // WebRtcEventLogHandler provides an interface to start and stop 25 // WebRtcEventLogHandler provides an interface to start and stop
25 // the WebRTC event log. 26 // the WebRTC event log.
26 class WebRtcEventLogHandler 27 class WebRtcEventLogHandler
27 : public base::RefCountedThreadSafe<WebRtcEventLogHandler> { 28 : public base::RefCountedThreadSafe<WebRtcEventLogHandler> {
28 public: 29 public:
29 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; 30 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback;
30 typedef base::Callback<void(const std::string&)> RecordingErrorCallback; 31 typedef base::Callback<void(const std::string&)> RecordingErrorCallback;
31 typedef base::Callback<void(const std::string&, bool, bool)> 32 typedef base::Callback<void(const std::string&, bool, bool)>
32 RecordingDoneCallback; 33 RecordingDoneCallback;
33 34
34 // Key used to attach the handler to the RenderProcessHost. 35 // Key used to attach the handler to the RenderProcessHost.
35 static const char kWebRtcEventLogHandlerKey[]; 36 static const char kWebRtcEventLogHandlerKey[];
36 37
37 explicit WebRtcEventLogHandler(Profile* profile); 38 WebRtcEventLogHandler(int process_id, Profile* profile);
38 39
39 // Starts an RTC event log. The call writes the most recent events to a 40 // Starts an RTC event log for each peerconnection on the specified |host|.
40 // file and then starts logging events for the given |delay|. 41 // The call writes the most recent events to a file and then starts logging
42 // events for the given |delay|.
41 // If |delay| is zero, the logging will continue until 43 // If |delay| is zero, the logging will continue until
42 // StopWebRtcEventLogging() 44 // StopWebRtcEventLogging()
43 // is explicitly invoked. 45 // is explicitly invoked.
44 // |callback| is invoked once recording stops. If |delay| is zero 46 // |callback| is invoked once recording stops. If |delay| is zero
45 // |callback| is invoked once recording starts. 47 // |callback| is invoked once recording starts.
46 // If a recording was already in progress, |error_callback| is invoked instead 48 // If a recording was already in progress, |error_callback| is invoked instead
47 // of |callback|. 49 // of |callback|.
48 void StartWebRtcEventLogging(content::RenderProcessHost* host, 50 void StartWebRtcEventLogging(content::RenderProcessHost* host,
49 base::TimeDelta delay, 51 base::TimeDelta delay,
50 const RecordingDoneCallback& callback, 52 const RecordingDoneCallback& callback,
51 const RecordingErrorCallback& error_callback); 53 const RecordingErrorCallback& error_callback);
52 54
55 // Starts an RTC event log for each peerconnection on the specified |host|.
56 // A base file_path can be supplied, which will be extended to include several
57 // identifiers to ensure uniqueness. If a recording was already in progress,
58 // this call will be ignored.
59 void StartWebRtcEventLogging(content::RenderProcessHost* host,
60 const base::FilePath& file_path);
61
53 // Stops an RTC event log. |callback| is invoked once recording 62 // Stops an RTC event log. |callback| is invoked once recording
54 // stops. If no recording was in progress, |error_callback| is invoked instead 63 // stops. If no recording was in progress, |error_callback| is invoked instead
55 // of |callback|. 64 // of |callback|.
56 void StopWebRtcEventLogging(content::RenderProcessHost* host, 65 void StopWebRtcEventLogging(content::RenderProcessHost* host,
57 const RecordingDoneCallback& callback, 66 const RecordingDoneCallback& callback,
58 const RecordingErrorCallback& error_callback); 67 const RecordingErrorCallback& error_callback);
59 68
69 // Stops an RTC event log for each peerconnection on the specified |host|.
70 // If no recording was in progress, this call has no effect.
71 void StopWebRtcEventLogging(content::RenderProcessHost* host);
72
73 // Signal that a PeerConnection was added to the RenderProcessHost
74 // identified by |process_id|.
75 void OnPeerConnectionAdded(int process_id, int connection_id);
76
77 // Signal that a PeerConnection was removed from the RenderProcessHost
78 // identified by |process_id|.
79 void OnPeerConnectionRemoved(int process_id, int connection_id);
80
60 private: 81 private:
61 friend class base::RefCountedThreadSafe<WebRtcEventLogHandler>; 82 friend class base::RefCountedThreadSafe<WebRtcEventLogHandler>;
62 virtual ~WebRtcEventLogHandler(); 83 virtual ~WebRtcEventLogHandler();
63 84
64 base::FilePath GetLogDirectoryAndEnsureExists(); 85 base::FilePath GetLogDirectoryAndEnsureExists();
65 86
66 // Helper for starting RTC event logs. 87 // Helper for starting RTC event logs.
67 void DoStartWebRtcEventLogging(content::RenderProcessHost* host, 88 void DoStartWebRtcEventLogging(content::RenderProcessHost* host,
68 base::TimeDelta delay, 89 base::TimeDelta delay,
69 const RecordingDoneCallback& callback, 90 const RecordingDoneCallback& callback,
70 const RecordingErrorCallback& error_callback, 91 const RecordingErrorCallback& error_callback,
71 const base::FilePath& log_directory); 92 const base::FilePath& log_directory);
72 93
73 // Helper for stopping RTC event logs. 94 // Helper for stopping RTC event logs.
74 void DoStopWebRtcEventLogging(content::RenderProcessHost* host, 95 void DoStopWebRtcEventLogging(content::RenderProcessHost* host,
75 bool is_manual_stop, 96 bool is_manual_stop,
76 uint64_t audio_debug_recordings_id, 97 uint64_t audio_debug_recordings_id,
77 const RecordingDoneCallback& callback, 98 const RecordingDoneCallback& callback,
78 const RecordingErrorCallback& error_callback, 99 const RecordingErrorCallback& error_callback,
79 const base::FilePath& log_directory); 100 const base::FilePath& log_directory);
80 101
81 // The profile associated with our renderer process. 102 // The profile associated with our renderer process.
82 Profile* const profile_; 103 Profile* const profile_;
83 104
84 // Must be accessed on the UI thread. 105 // Must be accessed on the UI thread.
85 bool is_rtc_event_logging_in_progress_; 106 bool is_rtc_event_logging_in_progress_;
86 107
108 // In case new PeerConnections are created during logging, the path is needed
109 // to enable logging for them.
110 base::FilePath base_file_path_;
111
112 // The local identifiers of all the currently active PeerConnections.
113 std::set<int> active_peer_connection_local_id_;
114
115 // Number of log files that can still be created before the maximum is
116 // reached. Each time a log file is opened, this value is decreased by one.
117 int number_log_files_;
118
87 // This counter allows saving each log in a separate file. 119 // This counter allows saving each log in a separate file.
88 uint64_t current_rtc_event_log_id_; 120 uint64_t current_rtc_event_log_id_;
89 121
90 base::ThreadChecker thread_checker_; 122 base::ThreadChecker thread_checker_;
91 DISALLOW_COPY_AND_ASSIGN(WebRtcEventLogHandler); 123 DISALLOW_COPY_AND_ASSIGN(WebRtcEventLogHandler);
92 }; 124 };
93 125
94 #endif // CHROME_BROWSER_MEDIA_WEBRTC_EVENT_LOG_HANDLER_H_ 126 #endif // CHROME_BROWSER_MEDIA_WEBRTC_EVENT_LOG_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698