| Index: webrtc/p2p/base/p2ptransportchannel.cc
|
| diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
|
| index cce20f4abb35490923065d7093ad3f0d94f273da..2de303a14a3f50e10cdcdd901999cb2f5606b3e6 100644
|
| --- a/webrtc/p2p/base/p2ptransportchannel.cc
|
| +++ b/webrtc/p2p/base/p2ptransportchannel.cc
|
| @@ -286,23 +286,26 @@ void P2PTransportChannel::SetIceTiebreaker(uint64 tiebreaker) {
|
| tiebreaker_ = tiebreaker;
|
| }
|
|
|
| -// Currently a channel is considered ICE completed once there is no
|
| -// more than one connection per Network. This works for a single NIC
|
| -// with both IPv4 and IPv6 enabled. However, this condition won't
|
| -// happen when there are multiple NICs and all of them have
|
| -// connectivity.
|
| -// TODO(guoweis): Change Completion to be driven by a channel level
|
| -// timer.
|
| +// A channel is considered ICE completed once there is at most one active
|
| +// connection per network and at least one active connection.
|
| TransportChannelState P2PTransportChannel::GetState() const {
|
| - std::set<rtc::Network*> networks;
|
| + if (!had_connection_) {
|
| + return TransportChannelState::STATE_INIT;
|
| + }
|
|
|
| - if (connections_.empty()) {
|
| - return had_connection_ ? TransportChannelState::STATE_FAILED
|
| - : TransportChannelState::STATE_INIT;
|
| + std::vector<Connection*> active_connections;
|
| + for (Connection* connection : connections_) {
|
| + if (connection->Active()) {
|
| + active_connections.push_back(connection);
|
| + }
|
| + }
|
| + if (active_connections.empty()) {
|
| + return TransportChannelState::STATE_FAILED;
|
| }
|
|
|
| - for (uint32 i = 0; i < connections_.size(); ++i) {
|
| - rtc::Network* network = connections_[i]->port()->Network();
|
| + std::set<rtc::Network*> networks;
|
| + for (Connection* connection : active_connections) {
|
| + rtc::Network* network = connection->port()->Network();
|
| if (networks.find(network) == networks.end()) {
|
| networks.insert(network);
|
| } else {
|
| @@ -312,8 +315,8 @@ TransportChannelState P2PTransportChannel::GetState() const {
|
| return TransportChannelState::STATE_CONNECTING;
|
| }
|
| }
|
| - LOG_J(LS_VERBOSE, this) << "Ice is completed for this channel.";
|
|
|
| + LOG_J(LS_VERBOSE, this) << "Ice is completed for this channel.";
|
| return TransportChannelState::STATE_COMPLETED;
|
| }
|
|
|
| @@ -872,8 +875,7 @@ bool P2PTransportChannel::GetStats(ConnectionInfos *infos) {
|
| infos->clear();
|
|
|
| std::vector<Connection *>::const_iterator it;
|
| - for (it = connections_.begin(); it != connections_.end(); ++it) {
|
| - Connection* connection = *it;
|
| + for (Connection* connection : connections_) {
|
| ConnectionInfo info;
|
| info.best_connection = (best_connection_ == connection);
|
| info.receiving = connection->receiving();
|
|
|