Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1150 Connection* old_best_connection = best_connection_; | 1150 Connection* old_best_connection = best_connection_; |
| 1151 best_connection_ = conn; | 1151 best_connection_ = conn; |
| 1152 if (best_connection_) { | 1152 if (best_connection_) { |
| 1153 if (old_best_connection) { | 1153 if (old_best_connection) { |
| 1154 LOG_J(LS_INFO, this) << "Previous best connection: " | 1154 LOG_J(LS_INFO, this) << "Previous best connection: " |
| 1155 << old_best_connection->ToString(); | 1155 << old_best_connection->ToString(); |
| 1156 } | 1156 } |
| 1157 LOG_J(LS_INFO, this) << "New best connection: " | 1157 LOG_J(LS_INFO, this) << "New best connection: " |
| 1158 << best_connection_->ToString(); | 1158 << best_connection_->ToString(); |
| 1159 SignalRouteChange(this, best_connection_->remote_candidate()); | 1159 SignalRouteChange(this, best_connection_->remote_candidate()); |
| 1160 if (NetworkChanged(old_best_connection, best_connection_)) { | |
| 1161 SignalNetworkChanged(this, best_connection_->port()->Network()->id(), 0); | |
| 1162 } | |
|
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
| |
| 1163 | |
| 1160 } else { | 1164 } else { |
| 1161 LOG_J(LS_INFO, this) << "No best connection"; | 1165 LOG_J(LS_INFO, this) << "No best connection"; |
| 1162 } | 1166 } |
| 1163 } | 1167 } |
| 1164 | 1168 |
| 1169 bool P2PTransportChannel::NetworkChanged(const Connection* old_conn, | |
| 1170 const Connection* new_conn) const { | |
| 1171 ASSERT(new_conn != nullptr); | |
| 1172 // Occasionally the best connection may be removed and a new connection is | |
| 1173 // chosen afterwards, so |old_conn| may be nullptr. | |
| 1174 if (old_conn == nullptr) { | |
| 1175 return true; | |
| 1176 } | |
| 1177 // A unique network should have been created for each network key, which is | |
| 1178 // generated from the network interface name, ip prefix, and ip prefix length. | |
| 1179 return old_conn->port()->Network() != new_conn->port()->Network(); | |
| 1180 } | |
| 1181 | |
| 1165 // Warning: UpdateState should eventually be called whenever a connection | 1182 // Warning: UpdateState should eventually be called whenever a connection |
| 1166 // is added, deleted, or the write state of any connection changes so that the | 1183 // is added, deleted, or the write state of any connection changes so that the |
| 1167 // transport controller will get the up-to-date channel state. However it | 1184 // transport controller will get the up-to-date channel state. However it |
| 1168 // should not be called too often; in the case that multiple connection states | 1185 // should not be called too often; in the case that multiple connection states |
| 1169 // change, it should be called after all the connection states have changed. For | 1186 // change, it should be called after all the connection states have changed. For |
| 1170 // example, we call this at the end of SortConnections. | 1187 // example, we call this at the end of SortConnections. |
| 1171 void P2PTransportChannel::UpdateState() { | 1188 void P2PTransportChannel::UpdateState() { |
| 1172 state_ = ComputeState(); | 1189 state_ = ComputeState(); |
| 1173 | 1190 |
| 1174 bool writable = best_connection_ && best_connection_->writable(); | 1191 bool writable = best_connection_ && best_connection_->writable(); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1614 | 1631 |
| 1615 // During the initial state when nothing has been pinged yet, return the first | 1632 // During the initial state when nothing has been pinged yet, return the first |
| 1616 // one in the ordered |connections_|. | 1633 // one in the ordered |connections_|. |
| 1617 return *(std::find_if(connections_.begin(), connections_.end(), | 1634 return *(std::find_if(connections_.begin(), connections_.end(), |
| 1618 [conn1, conn2](Connection* conn) { | 1635 [conn1, conn2](Connection* conn) { |
| 1619 return conn == conn1 || conn == conn2; | 1636 return conn == conn1 || conn == conn2; |
| 1620 })); | 1637 })); |
| 1621 } | 1638 } |
| 1622 | 1639 |
| 1623 } // namespace cricket | 1640 } // namespace cricket |
| OLD | NEW |