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 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 ScopedPacketBundler ack_bundler(this, SEND_ACK); | 1608 ScopedPacketBundler ack_bundler(this, SEND_ACK); |
1609 QuicConnectionCloseFrame* frame = new QuicConnectionCloseFrame(); | 1609 QuicConnectionCloseFrame* frame = new QuicConnectionCloseFrame(); |
1610 frame->error_code = error; | 1610 frame->error_code = error; |
1611 frame->error_details = details; | 1611 frame->error_details = details; |
1612 packet_generator_.AddControlFrame(QuicFrame(frame)); | 1612 packet_generator_.AddControlFrame(QuicFrame(frame)); |
1613 Flush(); | 1613 Flush(); |
1614 } | 1614 } |
1615 | 1615 |
1616 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) { | 1616 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) { |
1617 DCHECK(connected_); | 1617 DCHECK(connected_); |
| 1618 if (!connected_) { |
| 1619 return; |
| 1620 } |
1618 connected_ = false; | 1621 connected_ = false; |
1619 visitor_->OnConnectionClosed(error, from_peer); | 1622 visitor_->OnConnectionClosed(error, from_peer); |
1620 // Cancel the alarms so they don't trigger any action now that the | 1623 // Cancel the alarms so they don't trigger any action now that the |
1621 // connection is closed. | 1624 // connection is closed. |
1622 ack_alarm_->Cancel(); | 1625 ack_alarm_->Cancel(); |
1623 resume_writes_alarm_->Cancel(); | 1626 resume_writes_alarm_->Cancel(); |
1624 retransmission_alarm_->Cancel(); | 1627 retransmission_alarm_->Cancel(); |
1625 send_alarm_->Cancel(); | 1628 send_alarm_->Cancel(); |
1626 timeout_alarm_->Cancel(); | 1629 timeout_alarm_->Cancel(); |
1627 } | 1630 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 // If we changed the generator's batch state, restore original batch state. | 1780 // If we changed the generator's batch state, restore original batch state. |
1778 if (!already_in_batch_mode_) { | 1781 if (!already_in_batch_mode_) { |
1779 DVLOG(1) << "Leaving Batch Mode."; | 1782 DVLOG(1) << "Leaving Batch Mode."; |
1780 connection_->packet_generator_.FinishBatchOperations(); | 1783 connection_->packet_generator_.FinishBatchOperations(); |
1781 } | 1784 } |
1782 DCHECK_EQ(already_in_batch_mode_, | 1785 DCHECK_EQ(already_in_batch_mode_, |
1783 connection_->packet_generator_.InBatchMode()); | 1786 connection_->packet_generator_.InBatchMode()); |
1784 } | 1787 } |
1785 | 1788 |
1786 } // namespace net | 1789 } // namespace net |
OLD | NEW |