Index: webrtc/p2p/client/basicportallocator.cc |
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc |
index 20fc84a38a22fc05eeed1942a1231a1ba94aaf27..2b72fec396dfc931aa076b48ea9390cfa31498d6 100644 |
--- a/webrtc/p2p/client/basicportallocator.cc |
+++ b/webrtc/p2p/client/basicportallocator.cc |
@@ -215,6 +215,22 @@ void BasicPortAllocatorSession::ClearGettingPorts() { |
sequences_[i]->Stop(); |
} |
+void BasicPortAllocatorSession::GetPortsOnNetworks( |
+ const std::vector<rtc::Network*>* networks) { |
+ // Mark the networks on existing allocation sequences as inactive so that |
+ // ports will always be allocated on the given networks. |
+ for (AllocationSequence* sequence : sequences_) { |
+ if (!sequence->network_inactive() && |
+ (!networks || |
+ std::find(networks->begin(), networks->end(), sequence->network()) != |
+ networks->end())) { |
+ sequence->OnNetworkInactivated(); |
pthatcher1
2016/06/07 18:54:34
It feels like we are confounding two separate thin
|
+ } |
+ } |
+ |
+ StartGettingPorts(); |
pthatcher1
2016/06/07 18:54:34
And the Restart() above would mean we don't need t
|
+} |
+ |
std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const { |
std::vector<PortInterface*> ret; |
for (const PortData& port : ports_) { |
@@ -243,6 +259,18 @@ std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const { |
return candidates; |
} |
+std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates( |
pthatcher1
2016/06/07 18:54:34
Is it really so bad if the caller calls ReadyCandi
|
+ PortInterface* port) const { |
+ std::vector<Candidate> candidates; |
+ for (const Candidate& candidate : port->Candidates()) { |
+ if (!CheckCandidateFilter(candidate)) { |
+ continue; |
+ } |
+ candidates.push_back(SanitizeRelatedAddress(candidate)); |
+ } |
+ return candidates; |
+} |
+ |
Candidate BasicPortAllocatorSession::SanitizeRelatedAddress( |
const Candidate& c) const { |
Candidate copy = c; |
@@ -501,10 +529,10 @@ void BasicPortAllocatorSession::OnNetworksChanged() { |
for (AllocationSequence* sequence : sequences_) { |
// Remove the network from the allocation sequence if it is not in |
// |networks|. |
- if (!sequence->network_removed() && |
+ if (!sequence->network_inactive() && |
pthatcher1
2016/06/07 18:54:34
I liked calling this removed before and I'd like t
|
std::find(networks.begin(), networks.end(), sequence->network()) == |
networks.end()) { |
- sequence->OnNetworkRemoved(); |
+ sequence->OnNetworkInactivated(); |
} |
} |
@@ -793,10 +821,10 @@ void AllocationSequence::Clear() { |
turn_ports_.clear(); |
} |
-void AllocationSequence::OnNetworkRemoved() { |
+void AllocationSequence::OnNetworkInactivated() { |
// Stop the allocation sequence if its network is gone. |
+ network_inactive_ = true; |
Stop(); |
- network_removed_ = true; |
} |
AllocationSequence::~AllocationSequence() { |
@@ -805,8 +833,8 @@ AllocationSequence::~AllocationSequence() { |
void AllocationSequence::DisableEquivalentPhases(rtc::Network* network, |
PortConfiguration* config, uint32_t* flags) { |
- if (network_removed_) { |
- // If the network of this allocation sequence has ever gone away, |
+ if (network_inactive_) { |
+ // If the network of this allocation sequence has ever become inactive, |
// it won't be equivalent to the new network. |
return; |
} |