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 <vector> |
| 9 |
| 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/common/content_export.h" |
| 13 #include "ipc/ipc_platform_file.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 // This class is used to enable and disable WebRTC event logs on each of the |
| 18 // PeerConnections in the render process. This class and all its members should |
| 19 // only be accessed from the Browser UI thread. |
| 20 class CONTENT_EXPORT WebRTCEventLogHost { |
| 21 public: |
| 22 explicit WebRTCEventLogHost(int render_process_id); |
| 23 ~WebRTCEventLogHost(); |
| 24 |
| 25 // Starts an RTC event log for all current and future PeerConnections on the |
| 26 // render process. A base file_path can be supplied, which will be extended to |
| 27 // include several identifiers to ensure uniqueness. If a recording was |
| 28 // already in progress, this call will return false and have no other effect. |
| 29 bool StartWebRTCEventLog(const base::FilePath& file_path); |
| 30 |
| 31 // Stops recording an RTC event log for each PeerConnection on the render |
| 32 // process. If no recording was in progress, this call will return false. |
| 33 bool StopWebRTCEventLog(); |
| 34 |
| 35 // This function should be used to notify the WebRTCEventLogHost object that a |
| 36 // PeerConnection was created in the corresponding render process. |
| 37 void PeerConnectionAdded(int peer_connection_local_id); |
| 38 |
| 39 // This function should be used to notify the WebRTCEventLogHost object that a |
| 40 // PeerConnection was removed in the corresponding render process. |
| 41 void PeerConnectionRemoved(int peer_connection_local_id); |
| 42 |
| 43 private: |
| 44 // Actually start the eventlog for a single PeerConnection using the path |
| 45 // stored in base_file_path_. |
| 46 bool StartEventLogForPeerConnection(int peer_connection_local_id); |
| 47 |
| 48 // Send the platform file to the render process using an IPC message. |
| 49 void SendEventLogFileToRenderer(int peer_connection_local_id, |
| 50 IPC::PlatformFileForTransit file_for_transit); |
| 51 |
| 52 // The render process ID that this object is associated with. |
| 53 const int render_process_id_; |
| 54 |
| 55 // In case new PeerConnections are created during logging, the path is needed |
| 56 // to enable logging for them. |
| 57 base::FilePath base_file_path_; |
| 58 |
| 59 // The local identifiers of all the currently active PeerConnections. |
| 60 std::vector<int> active_peer_connection_local_ids_; |
| 61 |
| 62 // Number of active log files that have been opened. |
| 63 static int number_active_log_files_; |
| 64 |
| 65 // Track if the RTC event log is currently active. |
| 66 bool rtc_event_logging_enabled_; |
| 67 |
| 68 base::WeakPtrFactory<WebRTCEventLogHost> weak_ptr_factory_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(WebRTCEventLogHost); |
| 71 }; |
| 72 |
| 73 } // namespace content |
| 74 |
| 75 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_HOST_H_ |
OLD | NEW |