OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_HOST_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_HOST_H_ |
| 7 |
| 8 #include <unordered_set> |
| 9 |
| 10 #include "base/files/file_path.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 // This class is used to active and disable WebRTC event logs on each of the |
| 15 // peer connections in the render process. To be able to do this, it needs to |
| 16 // keep track of all the PeerConnections in the render process. |
| 17 class WebRTCEventLogHost { |
| 18 public: |
| 19 explicit WebRTCEventLogHost(int render_process_id); |
| 20 ~WebRTCEventLogHost(); |
| 21 |
| 22 // Starts an RTC event log for each peerconnection on the render process. |
| 23 // A base file_path can be supplied, which will be extended to include several |
| 24 // identifiers to ensure uniqueness. If a recording was already in progress, |
| 25 // this call will return false and have no other effect. Should be called |
| 26 // from the Browser UI thread. |
| 27 bool StartWebRTCEventLog(const base::FilePath& file_path); |
| 28 |
| 29 // Stops recording an RTC event log for each peerconnection on the render |
| 30 // process. If no recording was in progress, this call will return false. |
| 31 bool StopWebRTCEventLog(); |
| 32 |
| 33 // This function should be used to notify the WebRTCEventLogHost object that a |
| 34 // PeerConnection was created in the corresponding render process. |
| 35 void PeerConnectionAdded(int peer_connection_local_id); |
| 36 |
| 37 // This function should be used to notify the WebRTCEventLogHost object that a |
| 38 // PeerConnection was removed in the corresponding render process. |
| 39 void PeerConnectionRemoved(int peer_connection_local_id); |
| 40 |
| 41 private: |
| 42 // The render process ID that this object is associated with. |
| 43 const int render_process_id_; |
| 44 |
| 45 // In case new PeerConnections are created during logging, the path is needed |
| 46 // to enable logging for them. |
| 47 base::FilePath base_file_path_; |
| 48 |
| 49 // The local identifiers of all the currently active PeerConnections. |
| 50 std::unordered_set<int> active_peer_connection_local_id_; |
| 51 |
| 52 // Number of active log files that have been opened. Since this class is only |
| 53 // accessed from the Browser UI thread, it is safe to access this from every |
| 54 // instance of the class. |
| 55 static int number_active_log_files_; |
| 56 |
| 57 // Track if the RTC event log is currently active. |
| 58 bool rtc_event_logging_enabled_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(WebRTCEventLogHost); |
| 61 }; |
| 62 |
| 63 } // namespace content |
| 64 |
| 65 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_HOST_H_ |
OLD | NEW |