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 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <iterator> | 11 #include <iterator> |
12 #include <limits> | 12 #include <limits> |
13 #include <memory> | 13 #include <memory> |
14 #include <set> | 14 #include <set> |
15 #include <utility> | 15 #include <utility> |
16 | 16 |
17 #include "base/format_macros.h" | 17 #include "base/format_macros.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
21 #include "base/metrics/histogram_macros.h" | |
21 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
24 #include "net/quic/crypto/crypto_protocol.h" | 25 #include "net/quic/crypto/crypto_protocol.h" |
25 #include "net/quic/crypto/quic_decrypter.h" | 26 #include "net/quic/crypto/quic_decrypter.h" |
26 #include "net/quic/crypto/quic_encrypter.h" | 27 #include "net/quic/crypto/quic_encrypter.h" |
27 #include "net/quic/proto/cached_network_parameters.pb.h" | 28 #include "net/quic/proto/cached_network_parameters.pb.h" |
28 #include "net/quic/quic_bandwidth.h" | 29 #include "net/quic/quic_bandwidth.h" |
29 #include "net/quic/quic_bug_tracker.h" | 30 #include "net/quic/quic_bug_tracker.h" |
30 #include "net/quic/quic_config.h" | 31 #include "net/quic/quic_config.h" |
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2066 packet_generator_.FlushAllQueuedFrames(); | 2067 packet_generator_.FlushAllQueuedFrames(); |
2067 } | 2068 } |
2068 | 2069 |
2069 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) { | 2070 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) { |
2070 if (!connected_) { | 2071 if (!connected_) { |
2071 DVLOG(1) << "Connection is already closed."; | 2072 DVLOG(1) << "Connection is already closed."; |
2072 return; | 2073 return; |
2073 } | 2074 } |
2074 connected_ = false; | 2075 connected_ = false; |
2075 DCHECK(visitor_ != nullptr); | 2076 DCHECK(visitor_ != nullptr); |
2076 visitor_->OnConnectionClosed(error, from_peer); | 2077 // TODO(rtenneti): crbug.com/546668. A temporary fix. Added a check for null |
2078 // |visitor_| to fix crash bug. Delete |visitor_| check and histogram after | |
2079 // fix is merged. | |
2080 if (visitor_) { | |
Alexander Potapenko
2016/02/07 08:40:18
Drive-by nit: this check is inconsistent with othe
ramant (doing other things)
2016/02/09 00:10:34
Done. Uploaded the following CL. Thanks.
https:/
| |
2081 visitor_->OnConnectionClosed(error, from_peer); | |
2082 } else { | |
2083 UMA_HISTOGRAM_BOOLEAN("Net.QuicCloseConnection.NullVisitor", true); | |
2084 } | |
2077 if (debug_visitor_ != nullptr) { | 2085 if (debug_visitor_ != nullptr) { |
2078 debug_visitor_->OnConnectionClosed(error, from_peer); | 2086 debug_visitor_->OnConnectionClosed(error, from_peer); |
2079 } | 2087 } |
2080 // Cancel the alarms so they don't trigger any action now that the | 2088 // Cancel the alarms so they don't trigger any action now that the |
2081 // connection is closed. | 2089 // connection is closed. |
2082 ack_alarm_->Cancel(); | 2090 ack_alarm_->Cancel(); |
2083 ping_alarm_->Cancel(); | 2091 ping_alarm_->Cancel(); |
2084 fec_alarm_->Cancel(); | 2092 fec_alarm_->Cancel(); |
2085 resume_writes_alarm_->Cancel(); | 2093 resume_writes_alarm_->Cancel(); |
2086 retransmission_alarm_->Cancel(); | 2094 retransmission_alarm_->Cancel(); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2441 void QuicConnection::OnPathClosed(QuicPathId path_id) { | 2449 void QuicConnection::OnPathClosed(QuicPathId path_id) { |
2442 // Stop receiving packets on this path. | 2450 // Stop receiving packets on this path. |
2443 framer_.OnPathClosed(path_id); | 2451 framer_.OnPathClosed(path_id); |
2444 } | 2452 } |
2445 | 2453 |
2446 bool QuicConnection::ack_frame_updated() const { | 2454 bool QuicConnection::ack_frame_updated() const { |
2447 return received_packet_manager_.ack_frame_updated(); | 2455 return received_packet_manager_.ack_frame_updated(); |
2448 } | 2456 } |
2449 | 2457 |
2450 } // namespace net | 2458 } // namespace net |
OLD | NEW |