| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 263   c.set_network_type(network_->type()); | 263   c.set_network_type(network_->type()); | 
| 264   c.set_related_address(related_address); | 264   c.set_related_address(related_address); | 
| 265   candidates_.push_back(c); | 265   candidates_.push_back(c); | 
| 266   SignalCandidateReady(this, c); | 266   SignalCandidateReady(this, c); | 
| 267 | 267 | 
| 268   if (final) { | 268   if (final) { | 
| 269     SignalPortComplete(this); | 269     SignalPortComplete(this); | 
| 270   } | 270   } | 
| 271 } | 271 } | 
| 272 | 272 | 
| 273 void Port::AddConnection(Connection* conn) { | 273 void Port::AddOrReplaceConnection(Connection* conn) { | 
| 274   connections_[conn->remote_candidate().address()] = conn; | 274   auto ret = connections_.insert( | 
|  | 275       std::make_pair(conn->remote_candidate().address(), conn)); | 
|  | 276   // If there is a different connection on the same remote address, replace | 
|  | 277   // it with the new one and destroy the old one. | 
|  | 278   if (ret.second == false && ret.first->second != conn) { | 
|  | 279     LOG_J(LS_WARNING, this) | 
|  | 280         << "A new connection was created on an existing remote address. " | 
|  | 281         << "New remote candidate: " << conn->remote_candidate().ToString(); | 
|  | 282     ret.first->second->Destroy(); | 
|  | 283     ret.first->second = conn; | 
|  | 284   } | 
| 275   conn->SignalDestroyed.connect(this, &Port::OnConnectionDestroyed); | 285   conn->SignalDestroyed.connect(this, &Port::OnConnectionDestroyed); | 
| 276   SignalConnectionCreated(this, conn); | 286   SignalConnectionCreated(this, conn); | 
| 277 } | 287 } | 
| 278 | 288 | 
| 279 void Port::OnReadPacket( | 289 void Port::OnReadPacket( | 
| 280     const char* data, size_t size, const rtc::SocketAddress& addr, | 290     const char* data, size_t size, const rtc::SocketAddress& addr, | 
| 281     ProtocolType proto) { | 291     ProtocolType proto) { | 
| 282   // If the user has enabled port packets, just hand this over. | 292   // If the user has enabled port packets, just hand this over. | 
| 283   if (enable_port_packets_) { | 293   if (enable_port_packets_) { | 
| 284     SignalReadPacket(this, data, size, addr); | 294     SignalReadPacket(this, data, size, addr); | 
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 680 } | 690 } | 
| 681 | 691 | 
| 682 void Port::EnablePortPackets() { | 692 void Port::EnablePortPackets() { | 
| 683   enable_port_packets_ = true; | 693   enable_port_packets_ = true; | 
| 684 } | 694 } | 
| 685 | 695 | 
| 686 void Port::OnConnectionDestroyed(Connection* conn) { | 696 void Port::OnConnectionDestroyed(Connection* conn) { | 
| 687   AddressMap::iterator iter = | 697   AddressMap::iterator iter = | 
| 688       connections_.find(conn->remote_candidate().address()); | 698       connections_.find(conn->remote_candidate().address()); | 
| 689   ASSERT(iter != connections_.end()); | 699   ASSERT(iter != connections_.end()); | 
|  | 700   if (iter->second != conn) { | 
|  | 701     // If the deleted connection is different than what we have now, ignore it. | 
|  | 702     return; | 
|  | 703   } | 
| 690   connections_.erase(iter); | 704   connections_.erase(iter); | 
|  | 705   HandleConnectionDestroyed(conn); | 
| 691 | 706 | 
| 692   // On the controlled side, ports time out after all connections fail. | 707   // On the controlled side, ports time out after all connections fail. | 
| 693   // Note: If a new connection is added after this message is posted, but it | 708   // Note: If a new connection is added after this message is posted, but it | 
| 694   // fails and is removed before kPortTimeoutDelay, then this message will | 709   // fails and is removed before kPortTimeoutDelay, then this message will | 
| 695   // still cause the Port to be destroyed. | 710   // still cause the Port to be destroyed. | 
| 696   if (dead()) { | 711   if (dead()) { | 
| 697     thread_->PostDelayed(timeout_delay_, this, MSG_DEAD); | 712     thread_->PostDelayed(timeout_delay_, this, MSG_DEAD); | 
| 698   } | 713   } | 
| 699 } | 714 } | 
| 700 | 715 | 
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1505     ASSERT(sent < 0); | 1520     ASSERT(sent < 0); | 
| 1506     error_ = port_->GetError(); | 1521     error_ = port_->GetError(); | 
| 1507     sent_packets_discarded_++; | 1522     sent_packets_discarded_++; | 
| 1508   } else { | 1523   } else { | 
| 1509     send_rate_tracker_.AddSamples(sent); | 1524     send_rate_tracker_.AddSamples(sent); | 
| 1510   } | 1525   } | 
| 1511   return sent; | 1526   return sent; | 
| 1512 } | 1527 } | 
| 1513 | 1528 | 
| 1514 }  // namespace cricket | 1529 }  // namespace cricket | 
| OLD | NEW | 
|---|