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 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 rtc::scoped_ptr<IceMessage> msg; | 996 rtc::scoped_ptr<IceMessage> msg; |
997 std::string remote_ufrag; | 997 std::string remote_ufrag; |
998 const rtc::SocketAddress& addr(remote_candidate_.address()); | 998 const rtc::SocketAddress& addr(remote_candidate_.address()); |
999 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { | 999 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { |
1000 // The packet did not parse as a valid STUN message | 1000 // The packet did not parse as a valid STUN message |
1001 | 1001 |
1002 // If this connection is readable, then pass along the packet. | 1002 // If this connection is readable, then pass along the packet. |
1003 if (read_state_ == STATE_READABLE) { | 1003 if (read_state_ == STATE_READABLE) { |
1004 // readable means data from this address is acceptable | 1004 // readable means data from this address is acceptable |
1005 // Send it on! | 1005 // Send it on! |
1006 | |
1007 last_data_received_ = rtc::Time(); | 1006 last_data_received_ = rtc::Time(); |
1008 recv_rate_tracker_.Update(size); | 1007 recv_rate_tracker_.Update(size); |
1009 SignalReadPacket(this, data, size, packet_time); | 1008 SignalReadPacket(this, data, size, packet_time); |
1010 | 1009 |
1011 // If timed out sending writability checks, start up again | 1010 // If timed out sending writability checks, start up again |
1012 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { | 1011 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { |
1013 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " | 1012 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " |
1014 << "Resetting state to STATE_WRITE_INIT."; | 1013 << "Resetting state to STATE_WRITE_INIT."; |
1015 set_write_state(STATE_WRITE_INIT); | 1014 set_write_state(STATE_WRITE_INIT); |
1016 } | 1015 } |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 } | 1436 } |
1438 } | 1437 } |
1439 | 1438 |
1440 void Connection::OnMessage(rtc::Message *pmsg) { | 1439 void Connection::OnMessage(rtc::Message *pmsg) { |
1441 ASSERT(pmsg->message_id == MSG_DELETE); | 1440 ASSERT(pmsg->message_id == MSG_DELETE); |
1442 LOG_J(LS_INFO, this) << "Connection deleted due to read or write timeout"; | 1441 LOG_J(LS_INFO, this) << "Connection deleted due to read or write timeout"; |
1443 SignalDestroyed(this); | 1442 SignalDestroyed(this); |
1444 delete this; | 1443 delete this; |
1445 } | 1444 } |
1446 | 1445 |
| 1446 uint32 Connection::last_received() { |
| 1447 return std::max(last_data_received_, |
| 1448 std::max(last_ping_received_, last_ping_response_received_)); |
| 1449 } |
| 1450 |
1447 size_t Connection::recv_bytes_second() { | 1451 size_t Connection::recv_bytes_second() { |
1448 return recv_rate_tracker_.units_second(); | 1452 return recv_rate_tracker_.units_second(); |
1449 } | 1453 } |
1450 | 1454 |
1451 size_t Connection::recv_total_bytes() { | 1455 size_t Connection::recv_total_bytes() { |
1452 return recv_rate_tracker_.total_units(); | 1456 return recv_rate_tracker_.total_units(); |
1453 } | 1457 } |
1454 | 1458 |
1455 size_t Connection::sent_bytes_second() { | 1459 size_t Connection::sent_bytes_second() { |
1456 return send_rate_tracker_.units_second(); | 1460 return send_rate_tracker_.units_second(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 ASSERT(sent < 0); | 1555 ASSERT(sent < 0); |
1552 error_ = port_->GetError(); | 1556 error_ = port_->GetError(); |
1553 sent_packets_discarded_++; | 1557 sent_packets_discarded_++; |
1554 } else { | 1558 } else { |
1555 send_rate_tracker_.Update(sent); | 1559 send_rate_tracker_.Update(sent); |
1556 } | 1560 } |
1557 return sent; | 1561 return sent; |
1558 } | 1562 } |
1559 | 1563 |
1560 } // namespace cricket | 1564 } // namespace cricket |
OLD | NEW |