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

Unified Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2093623004: Add config to prune TURN ports (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add all tests and fix a bug to set port type Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index 1eb63c5e69577269d7f0a8783a37c640246d337f..567ce7900437db4bc4f8a27002aaaa5c3ede1326 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -125,6 +125,8 @@ void P2PTransportChannel::AddAllocatorSession(
session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
+ session->SignalPortDeprecated.connect(this,
+ &P2PTransportChannel::OnPortDeprecated);
session->SignalCandidatesReady.connect(
this, &P2PTransportChannel::OnCandidatesReady);
session->SignalCandidatesAllocationDone.connect(
@@ -1626,7 +1628,7 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
std::remove(removed_ports_.begin(), removed_ports_.end(), port),
removed_ports_.end());
- LOG(INFO) << "Removed port from p2p socket: "
+ LOG(INFO) << "Removed port because it is destroyed: "
<< static_cast<int>(ports_.size()) << " remaining";
}
@@ -1636,20 +1638,34 @@ void P2PTransportChannel::OnPortNetworkInactive(PortInterface* port) {
if (!config_.gather_continually) {
return;
}
+ RemovePort(port);
+ LOG(INFO) << "Removed port because its network is inactive : "
+ << port->ToString() << " " << ports_.size() << " remaining";
+ std::vector<Candidate> candidates = port->Candidates();
+ for (Candidate& candidate : candidates) {
+ candidate.set_transport_name(transport_name());
+ }
+ SignalCandidatesRemoved(this, candidates);
+}
+
+void P2PTransportChannel::OnPortDeprecated(PortAllocatorSession* session,
+ PortInterface* port) {
+ if (session != allocator_session()) {
pthatcher1 2016/06/27 20:35:54 Can you comment on why we need this? Will this ha
honghaiz3 2016/06/28 01:49:25 Perhaps this is not needed. If this is from the p
+ return;
+ }
+ RemovePort(port);
+ LOG(INFO) << "Removed port because it is deprecated: " << port->ToString()
+ << " " << ports_.size() << " remaining";
+}
+
+void P2PTransportChannel::RemovePort(PortInterface* port) {
auto it = std::find(ports_.begin(), ports_.end(), port);
// Don't need to do anything if the port has been deleted from the port list.
if (it == ports_.end()) {
return;
}
- removed_ports_.push_back(*it);
ports_.erase(it);
- LOG(INFO) << "Removed port due to inactive networks: " << ports_.size()
- << " remaining";
- std::vector<Candidate> candidates = port->Candidates();
- for (Candidate& candidate : candidates) {
- candidate.set_transport_name(transport_name());
- }
- SignalCandidatesRemoved(this, candidates);
+ removed_ports_.push_back(port);
}
// We data is available, let listeners know

Powered by Google App Engine
This is Rietveld 408576698