| OLD | NEW |
| 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 #include "content/browser/media/webrtc/webrtc_eventlog_host.h" | 5 #include "content/browser/media/webrtc/webrtc_eventlog_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (webrtc_internals->IsEventLogRecordingsEnabled()) | 71 if (webrtc_internals->IsEventLogRecordingsEnabled()) |
| 72 StartWebRTCEventLog(webrtc_internals->GetEventLogFilePath()); | 72 StartWebRTCEventLog(webrtc_internals->GetEventLogFilePath()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 WebRTCEventLogHost::~WebRTCEventLogHost() { | 75 WebRTCEventLogHost::~WebRTCEventLogHost() { |
| 76 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 76 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void WebRTCEventLogHost::PeerConnectionAdded(int peer_connection_local_id) { | 79 void WebRTCEventLogHost::PeerConnectionAdded(int peer_connection_local_id) { |
| 80 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 80 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 81 DCHECK(std::find(active_peer_connection_local_ids_.begin(), | 81 if (std::find(active_peer_connection_local_ids_.begin(), |
| 82 active_peer_connection_local_ids_.end(), | 82 active_peer_connection_local_ids_.end(), |
| 83 peer_connection_local_id) == | 83 peer_connection_local_id) == |
| 84 active_peer_connection_local_ids_.end()); | 84 active_peer_connection_local_ids_.end()) { |
| 85 active_peer_connection_local_ids_.push_back(peer_connection_local_id); | 85 active_peer_connection_local_ids_.push_back(peer_connection_local_id); |
| 86 if (rtc_event_logging_enabled_ && | 86 if (rtc_event_logging_enabled_ && |
| 87 number_active_log_files_ < kMaxNumberLogFiles) { | 87 number_active_log_files_ < kMaxNumberLogFiles) { |
| 88 StartEventLogForPeerConnection(peer_connection_local_id); | 88 StartEventLogForPeerConnection(peer_connection_local_id); |
| 89 } |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 | 92 |
| 92 void WebRTCEventLogHost::PeerConnectionRemoved(int peer_connection_local_id) { | 93 void WebRTCEventLogHost::PeerConnectionRemoved(int peer_connection_local_id) { |
| 93 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 94 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 94 const auto found = std::find(active_peer_connection_local_ids_.begin(), | 95 const auto found = std::find(active_peer_connection_local_ids_.begin(), |
| 95 active_peer_connection_local_ids_.end(), | 96 active_peer_connection_local_ids_.end(), |
| 96 peer_connection_local_id); | 97 peer_connection_local_id); |
| 97 DCHECK(found != active_peer_connection_local_ids_.end()); | 98 if (found != active_peer_connection_local_ids_.end()) { |
| 98 active_peer_connection_local_ids_.erase(found); | 99 active_peer_connection_local_ids_.erase(found); |
| 100 } |
| 99 } | 101 } |
| 100 | 102 |
| 101 bool WebRTCEventLogHost::StartWebRTCEventLog(const base::FilePath& file_path) { | 103 bool WebRTCEventLogHost::StartWebRTCEventLog(const base::FilePath& file_path) { |
| 102 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 104 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 103 if (rtc_event_logging_enabled_) | 105 if (rtc_event_logging_enabled_) |
| 104 return false; | 106 return false; |
| 105 rtc_event_logging_enabled_ = true; | 107 rtc_event_logging_enabled_ = true; |
| 106 base_file_path_ = file_path; | 108 base_file_path_ = file_path; |
| 107 for (int local_id : active_peer_connection_local_ids_) | 109 for (int local_id : active_peer_connection_local_ids_) |
| 108 StartEventLogForPeerConnection(local_id); | 110 StartEventLogForPeerConnection(local_id); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (rph) { | 150 if (rph) { |
| 149 rph->Send(new PeerConnectionTracker_StartEventLog(peer_connection_local_id, | 151 rph->Send(new PeerConnectionTracker_StartEventLog(peer_connection_local_id, |
| 150 file_for_transit)); | 152 file_for_transit)); |
| 151 } else { | 153 } else { |
| 152 --number_active_log_files_; | 154 --number_active_log_files_; |
| 153 IPC::PlatformFileForTransitToFile(file_for_transit).Close(); | 155 IPC::PlatformFileForTransitToFile(file_for_transit).Close(); |
| 154 } | 156 } |
| 155 } | 157 } |
| 156 | 158 |
| 157 } // namespace content | 159 } // namespace content |
| OLD | NEW |