| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 | 1555 |
| 1556 void QuicConnection::Flush() { | 1556 void QuicConnection::Flush() { |
| 1557 packet_generator_.FlushAllQueuedFrames(); | 1557 packet_generator_.FlushAllQueuedFrames(); |
| 1558 } | 1558 } |
| 1559 | 1559 |
| 1560 bool QuicConnection::HasQueuedData() const { | 1560 bool QuicConnection::HasQueuedData() const { |
| 1561 return pending_version_negotiation_packet_ || | 1561 return pending_version_negotiation_packet_ || |
| 1562 !queued_packets_.empty() || packet_generator_.HasQueuedFrames(); | 1562 !queued_packets_.empty() || packet_generator_.HasQueuedFrames(); |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 bool QuicConnection::CanWriteStreamData() { |
| 1566 if (HasQueuedData()) { |
| 1567 return false; |
| 1568 } |
| 1569 |
| 1570 IsHandshake pending_handshake = visitor_->HasPendingHandshake() ? |
| 1571 IS_HANDSHAKE : NOT_HANDSHAKE; |
| 1572 // Sending queued packets may have caused the socket to become write blocked, |
| 1573 // or the congestion manager to prohibit sending. If we've sent everything |
| 1574 // we had queued and we're still not blocked, let the visitor know it can |
| 1575 // write more. |
| 1576 return ShouldGeneratePacket(NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, |
| 1577 pending_handshake); |
| 1578 } |
| 1579 |
| 1565 void QuicConnection::SetIdleNetworkTimeout(QuicTime::Delta timeout) { | 1580 void QuicConnection::SetIdleNetworkTimeout(QuicTime::Delta timeout) { |
| 1566 if (timeout < idle_network_timeout_) { | 1581 if (timeout < idle_network_timeout_) { |
| 1567 idle_network_timeout_ = timeout; | 1582 idle_network_timeout_ = timeout; |
| 1568 CheckForTimeout(); | 1583 CheckForTimeout(); |
| 1569 } else { | 1584 } else { |
| 1570 idle_network_timeout_ = timeout; | 1585 idle_network_timeout_ = timeout; |
| 1571 } | 1586 } |
| 1572 } | 1587 } |
| 1573 | 1588 |
| 1574 void QuicConnection::SetOverallConnectionTimeout(QuicTime::Delta timeout) { | 1589 void QuicConnection::SetOverallConnectionTimeout(QuicTime::Delta timeout) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 // If we changed the generator's batch state, restore original batch state. | 1664 // If we changed the generator's batch state, restore original batch state. |
| 1650 if (!already_in_batch_mode_) { | 1665 if (!already_in_batch_mode_) { |
| 1651 DVLOG(1) << "Leaving Batch Mode."; | 1666 DVLOG(1) << "Leaving Batch Mode."; |
| 1652 connection_->packet_generator_.FinishBatchOperations(); | 1667 connection_->packet_generator_.FinishBatchOperations(); |
| 1653 } | 1668 } |
| 1654 DCHECK_EQ(already_in_batch_mode_, | 1669 DCHECK_EQ(already_in_batch_mode_, |
| 1655 connection_->packet_generator_.InBatchMode()); | 1670 connection_->packet_generator_.InBatchMode()); |
| 1656 } | 1671 } |
| 1657 | 1672 |
| 1658 } // namespace net | 1673 } // namespace net |
| OLD | NEW |