Chromium Code Reviews| Index: webrtc/p2p/base/port.cc | 
| diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc | 
| index 903f13d7a6ad360187efeb81f0a745d53c225e94..38afb4b97fb970ec9cb4494c257980d694142e45 100644 | 
| --- a/webrtc/p2p/base/port.cc | 
| +++ b/webrtc/p2p/base/port.cc | 
| @@ -776,8 +776,12 @@ class ConnectionRequest : public StunRequest { | 
| // priority = (2^24)*(type preference) + | 
| // (2^8)*(local preference) + | 
| // (2^0)*(256 - component ID) | 
| + uint32_t type_preference = | 
| + (connection_->local_candidate().protocol() == TCP_PROTOCOL_NAME) | 
| + ? ICE_TYPE_PREFERENCE_PRFLX_TCP | 
| + : ICE_TYPE_PREFERENCE_PRFLX; | 
| 
 
pthatcher1
2016/08/08 22:20:30
It seems like it would make sense to make this fix
 
 | 
| uint32_t prflx_priority = | 
| - ICE_TYPE_PREFERENCE_PRFLX << 24 | | 
| + type_preference << 24 | | 
| (connection_->local_candidate().priority() & 0x00FFFFFF); | 
| request->AddAttribute( | 
| new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); | 
| @@ -1325,7 +1329,7 @@ void Connection::OnConnectionRequestResponse(ConnectionRequest* request, | 
| stats_.recv_ping_responses++; | 
| - MaybeAddPrflxCandidate(request, response); | 
| + MaybeUpdateLocalCandidate(request, response); | 
| } | 
| void Connection::OnConnectionRequestErrorResponse(ConnectionRequest* request, | 
| @@ -1434,8 +1438,8 @@ ConnectionInfo Connection::stats() { | 
| return stats_; | 
| } | 
| -void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request, | 
| - StunMessage* response) { | 
| +void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request, | 
| + StunMessage* response) { | 
| // RFC 5245 | 
| // The agent checks the mapped address from the STUN response. If the | 
| // transport address does not match any of the local candidates that the | 
| @@ -1450,16 +1454,18 @@ void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request, | 
| return; | 
| } | 
| - bool known_addr = false; | 
| for (size_t i = 0; i < port_->Candidates().size(); ++i) { | 
| if (port_->Candidates()[i].address() == addr->GetAddress()) { | 
| - known_addr = true; | 
| - break; | 
| + if (local_candidate_index_ != i) { | 
| + LOG_J(LS_INFO, this) << "Updating local candidate type to srflx."; | 
| + local_candidate_index_ = i; | 
| + // SignalStateChange to force a re-sort in P2PTransportChannel as this | 
| + // Connection's local candidate has changed. | 
| + SignalStateChange(this); | 
| + } | 
| + return; | 
| } | 
| } | 
| - if (known_addr) { | 
| - return; | 
| - } | 
| // RFC 5245 | 
| // Its priority is set equal to the value of the PRIORITY attribute | 
| @@ -1495,6 +1501,7 @@ void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request, | 
| new_local_candidate.set_network_cost(local_candidate().network_cost()); | 
| // Change the local candidate of this Connection to the new prflx candidate. | 
| + LOG_J(LS_INFO, this) << "Updating local candidate type to prflx."; | 
| local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); | 
| // SignalStateChange to force a re-sort in P2PTransportChannel as this |