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/chromium/quic_chromium_client_session.h" | 5 #include "net/quic/chromium/quic_chromium_client_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 if (!going_away_) | 314 if (!going_away_) |
315 RecordUnexpectedNotGoingAway(DESTRUCTOR); | 315 RecordUnexpectedNotGoingAway(DESTRUCTOR); |
316 | 316 |
317 while (!dynamic_streams().empty() || !observers_.empty() || | 317 while (!dynamic_streams().empty() || !observers_.empty() || |
318 !stream_requests_.empty()) { | 318 !stream_requests_.empty()) { |
319 // The session must be closed before it is destroyed. | 319 // The session must be closed before it is destroyed. |
320 DCHECK(dynamic_streams().empty()); | 320 DCHECK(dynamic_streams().empty()); |
321 CloseAllStreams(ERR_UNEXPECTED); | 321 CloseAllStreams(ERR_UNEXPECTED); |
322 DCHECK(observers_.empty()); | 322 DCHECK(observers_.empty()); |
323 CloseAllObservers(ERR_UNEXPECTED); | 323 CloseAllObservers(ERR_UNEXPECTED); |
| 324 CancelAllRequests(ERR_UNEXPECTED); |
324 | 325 |
325 connection()->set_debug_visitor(nullptr); | 326 connection()->set_debug_visitor(nullptr); |
326 | |
327 UMA_HISTOGRAM_COUNTS_1000("Net.QuicSession.AbortedPendingStreamRequests", | |
328 stream_requests_.size()); | |
329 | |
330 while (!stream_requests_.empty()) { | |
331 StreamRequest* request = stream_requests_.front(); | |
332 stream_requests_.pop_front(); | |
333 request->OnRequestCompleteFailure(ERR_ABORTED); | |
334 } | |
335 } | 327 } |
336 | 328 |
337 if (connection()->connected()) { | 329 if (connection()->connected()) { |
338 // Ensure that the connection is closed by the time the session is | 330 // Ensure that the connection is closed by the time the session is |
339 // destroyed. | 331 // destroyed. |
340 connection()->CloseConnection(QUIC_INTERNAL_ERROR, "session torn down", | 332 connection()->CloseConnection(QUIC_INTERNAL_ERROR, "session torn down", |
341 ConnectionCloseBehavior::SILENT_CLOSE); | 333 ConnectionCloseBehavior::SILENT_CLOSE); |
342 } | 334 } |
343 | 335 |
344 if (IsEncryptionEstablished()) | 336 if (IsEncryptionEstablished()) |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 if (!callback_.is_null()) { | 998 if (!callback_.is_null()) { |
1007 base::ResetAndReturn(&callback_).Run(ERR_QUIC_PROTOCOL_ERROR); | 999 base::ResetAndReturn(&callback_).Run(ERR_QUIC_PROTOCOL_ERROR); |
1008 } | 1000 } |
1009 | 1001 |
1010 for (auto& socket : sockets_) { | 1002 for (auto& socket : sockets_) { |
1011 socket->Close(); | 1003 socket->Close(); |
1012 } | 1004 } |
1013 DCHECK(dynamic_streams().empty()); | 1005 DCHECK(dynamic_streams().empty()); |
1014 CloseAllStreams(ERR_UNEXPECTED); | 1006 CloseAllStreams(ERR_UNEXPECTED); |
1015 CloseAllObservers(ERR_UNEXPECTED); | 1007 CloseAllObservers(ERR_UNEXPECTED); |
| 1008 CancelAllRequests(ERR_CONNECTION_CLOSED); |
1016 NotifyFactoryOfSessionClosedLater(); | 1009 NotifyFactoryOfSessionClosedLater(); |
1017 } | 1010 } |
1018 | 1011 |
1019 void QuicChromiumClientSession::OnSuccessfulVersionNegotiation( | 1012 void QuicChromiumClientSession::OnSuccessfulVersionNegotiation( |
1020 const QuicVersion& version) { | 1013 const QuicVersion& version) { |
1021 logger_->OnSuccessfulVersionNegotiation(version); | 1014 logger_->OnSuccessfulVersionNegotiation(version); |
1022 QuicSpdySession::OnSuccessfulVersionNegotiation(version); | 1015 QuicSpdySession::OnSuccessfulVersionNegotiation(version); |
1023 | 1016 |
1024 ObserverSet::iterator it = observers_.begin(); | 1017 ObserverSet::iterator it = observers_.begin(); |
1025 while (it != observers_.end()) { | 1018 while (it != observers_.end()) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 } | 1256 } |
1264 | 1257 |
1265 void QuicChromiumClientSession::CloseAllObservers(int net_error) { | 1258 void QuicChromiumClientSession::CloseAllObservers(int net_error) { |
1266 while (!observers_.empty()) { | 1259 while (!observers_.empty()) { |
1267 Observer* observer = *observers_.begin(); | 1260 Observer* observer = *observers_.begin(); |
1268 observers_.erase(observer); | 1261 observers_.erase(observer); |
1269 observer->OnSessionClosed(net_error, port_migration_detected_); | 1262 observer->OnSessionClosed(net_error, port_migration_detected_); |
1270 } | 1263 } |
1271 } | 1264 } |
1272 | 1265 |
| 1266 void QuicChromiumClientSession::CancelAllRequests(int net_error) { |
| 1267 UMA_HISTOGRAM_COUNTS_1000("Net.QuicSession.AbortedPendingStreamRequests", |
| 1268 stream_requests_.size()); |
| 1269 |
| 1270 while (!stream_requests_.empty()) { |
| 1271 StreamRequest* request = stream_requests_.front(); |
| 1272 stream_requests_.pop_front(); |
| 1273 request->OnRequestCompleteFailure(net_error); |
| 1274 } |
| 1275 } |
| 1276 |
1273 std::unique_ptr<base::Value> QuicChromiumClientSession::GetInfoAsValue( | 1277 std::unique_ptr<base::Value> QuicChromiumClientSession::GetInfoAsValue( |
1274 const std::set<HostPortPair>& aliases) { | 1278 const std::set<HostPortPair>& aliases) { |
1275 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 1279 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
1276 dict->SetString("version", QuicVersionToString(connection()->version())); | 1280 dict->SetString("version", QuicVersionToString(connection()->version())); |
1277 dict->SetInteger("open_streams", GetNumOpenOutgoingStreams()); | 1281 dict->SetInteger("open_streams", GetNumOpenOutgoingStreams()); |
1278 std::unique_ptr<base::ListValue> stream_list(new base::ListValue()); | 1282 std::unique_ptr<base::ListValue> stream_list(new base::ListValue()); |
1279 for (DynamicStreamMap::const_iterator it = dynamic_streams().begin(); | 1283 for (DynamicStreamMap::const_iterator it = dynamic_streams().begin(); |
1280 it != dynamic_streams().end(); ++it) { | 1284 it != dynamic_streams().end(); ++it) { |
1281 stream_list->AppendString(base::UintToString(it->second->id())); | 1285 stream_list->AppendString(base::UintToString(it->second->id())); |
1282 } | 1286 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 } | 1497 } |
1494 | 1498 |
1495 size_t QuicChromiumClientSession::EstimateMemoryUsage() const { | 1499 size_t QuicChromiumClientSession::EstimateMemoryUsage() const { |
1496 // TODO(xunjieli): Estimate |crypto_stream_|, QuicSpdySession's | 1500 // TODO(xunjieli): Estimate |crypto_stream_|, QuicSpdySession's |
1497 // QuicHeaderList, QuicSession's QuiCWriteBlockedList, open streams and | 1501 // QuicHeaderList, QuicSession's QuiCWriteBlockedList, open streams and |
1498 // unacked packet map. | 1502 // unacked packet map. |
1499 return base::trace_event::EstimateMemoryUsage(packet_readers_); | 1503 return base::trace_event::EstimateMemoryUsage(packet_readers_); |
1500 } | 1504 } |
1501 | 1505 |
1502 } // namespace net | 1506 } // namespace net |
OLD | NEW |