Chromium Code Reviews| Index: webrtc/p2p/client/basicportallocator.cc |
| diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc |
| index 5e4930c1cb39a29ec4ff15b9dfae84d10e3ccb3a..46c28926c8db4e5ce844d0de6e6d268a589aaed2 100644 |
| --- a/webrtc/p2p/client/basicportallocator.cc |
| +++ b/webrtc/p2p/client/basicportallocator.cc |
| @@ -695,12 +695,12 @@ void BasicPortAllocatorSession::OnCandidateReady( |
| // Note: We should check whether any candidates may become ready after this |
| // because there we will check whether the candidate is generated by the ready |
| // ports, which may include this port. |
| - bool pruned_port = false; |
| + bool pruned = false; |
| if (CandidatePairable(c, port) && !data->has_pairable_candidate()) { |
| data->set_has_pairable_candidate(true); |
| if (prune_turn_ports_ && port->Type() == RELAY_PORT_TYPE) { |
| - pruned_port = PruneTurnPorts(port); |
| + pruned = PruneTurnPorts(port); |
| } |
| // If the current port is not pruned yet, SignalPortReady. |
| if (!data->pruned()) { |
| @@ -726,7 +726,7 @@ void BasicPortAllocatorSession::OnCandidateReady( |
| } |
| // If we have pruned any port, maybe need to signal port allocation done. |
| - if (pruned_port) { |
| + if (pruned) { |
| MaybeSignalCandidatesAllocationDone(); |
| } |
| } |
| @@ -745,7 +745,6 @@ Port* BasicPortAllocatorSession::GetBestTurnPortForNetwork( |
| } |
| bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) { |
| - bool pruned_port = false; |
| // Note: We determine the same network based only on their network names. So |
| // if an IPv4 address and an IPv6 address have the same network name, they |
| // are considered the same network here. |
| @@ -754,18 +753,24 @@ bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) { |
| // |port| is already in the list of ports, so the best port cannot be nullptr. |
| RTC_CHECK(best_turn_port != nullptr); |
| + bool pruned = false; |
| + std::vector<PortInterface*> pruned_ports; |
| for (PortData& data : ports_) { |
| if (data.port()->Network()->name() == network_name && |
| data.port()->Type() == RELAY_PORT_TYPE && !data.pruned() && |
| ComparePort(data.port(), best_turn_port) < 0) { |
| data.set_pruned(); |
| - pruned_port = true; |
| + pruned = true; |
| if (data.port() != newly_pairable_turn_port) { |
| - SignalPortPruned(this, data.port()); |
| + pruned_ports.push_back(data.port()); |
| } |
| } |
| } |
| - return pruned_port; |
| + if (!pruned_ports.empty()) { |
| + LOG(LS_INFO) << "Pruned " << pruned_ports.size() << " ports"; |
| + SignalPortsPruned(this, pruned_ports); |
| + } |
| + return pruned; |
| } |
| void BasicPortAllocatorSession::OnPortComplete(Port* port) { |
| @@ -946,7 +951,8 @@ void BasicPortAllocatorSession::RemovePortsAndCandidates( |
| } |
| } |
| if (!ports_to_remove.empty()) { |
| - SignalPortsRemoved(this, ports_to_remove); |
| + LOG(LS_INFO) << "Removed " << ports_to_remove.size() << " ports"; |
| + SignalPortsPruned(this, ports_to_remove); |
| } |
| if (!candidates_to_remove.empty()) { |
| SignalCandidatesRemoved(this, candidates_to_remove); |
|
honghaiz3
2016/07/27 21:31:26
It is a little strange to call PortsPruned but Can
|