Chromium Code Reviews| Index: webrtc/p2p/base/p2ptransportchannel.cc |
| diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc |
| index 759fd461db20f4fd67f52a7575ed359a4dec2b18..f50bd9b8af65162dc430fd31d54a7e23c8494489 100644 |
| --- a/webrtc/p2p/base/p2ptransportchannel.cc |
| +++ b/webrtc/p2p/base/p2ptransportchannel.cc |
| @@ -1157,11 +1157,28 @@ void P2PTransportChannel::SwitchBestConnectionTo(Connection* conn) { |
| LOG_J(LS_INFO, this) << "New best connection: " |
| << best_connection_->ToString(); |
| SignalRouteChange(this, best_connection_->remote_candidate()); |
| + if (NetworkChanged(old_best_connection, best_connection_)) { |
| + SignalNetworkChanged(this, best_connection_->port()->Network()->id(), 0); |
| + } |
|
pthatcher1
2016/03/16 21:22:03
I think we could use a helper method called GetNet
honghaiz3
2016/03/17 03:38:27
Instead of Optional and CandidatePair, I just pass
|
| + |
| } else { |
| LOG_J(LS_INFO, this) << "No best connection"; |
| } |
| } |
| +bool P2PTransportChannel::NetworkChanged(const Connection* old_conn, |
| + const Connection* new_conn) const { |
| + ASSERT(new_conn != nullptr); |
| + // Occasionally the best connection may be removed and a new connection is |
| + // chosen afterwards, so |old_conn| may be nullptr. |
| + if (old_conn == nullptr) { |
| + return true; |
| + } |
| + // A unique network should have been created for each network key, which is |
| + // generated from the network interface name, ip prefix, and ip prefix length. |
| + return old_conn->port()->Network() != new_conn->port()->Network(); |
| +} |
| + |
| // Warning: UpdateState should eventually be called whenever a connection |
| // is added, deleted, or the write state of any connection changes so that the |
| // transport controller will get the up-to-date channel state. However it |