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_client_session.h" | 5 #include "net/quic/quic_client_session.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 NUM_HANDSHAKE_STATES = 4 | 87 NUM_HANDSHAKE_STATES = 4 |
88 }; | 88 }; |
89 | 89 |
90 void RecordHandshakeState(HandshakeState state) { | 90 void RecordHandshakeState(HandshakeState state) { |
91 UMA_HISTOGRAM_ENUMERATION("Net.QuicHandshakeState", state, | 91 UMA_HISTOGRAM_ENUMERATION("Net.QuicHandshakeState", state, |
92 NUM_HANDSHAKE_STATES); | 92 NUM_HANDSHAKE_STATES); |
93 } | 93 } |
94 | 94 |
95 } // namespace | 95 } // namespace |
96 | 96 |
97 QuicClientSession::StreamRequest::StreamRequest() : stream_(NULL) {} | 97 QuicClientSession::StreamRequest::StreamRequest() : stream_(nullptr) {} |
98 | 98 |
99 QuicClientSession::StreamRequest::~StreamRequest() { | 99 QuicClientSession::StreamRequest::~StreamRequest() { |
100 CancelRequest(); | 100 CancelRequest(); |
101 } | 101 } |
102 | 102 |
103 int QuicClientSession::StreamRequest::StartRequest( | 103 int QuicClientSession::StreamRequest::StartRequest( |
104 const base::WeakPtr<QuicClientSession>& session, | 104 const base::WeakPtr<QuicClientSession>& session, |
105 QuicReliableClientStream** stream, | 105 QuicReliableClientStream** stream, |
106 const CompletionCallback& callback) { | 106 const CompletionCallback& callback) { |
107 session_ = session; | 107 session_ = session; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 while (!streams()->empty() || | 190 while (!streams()->empty() || |
191 !observers_.empty() || | 191 !observers_.empty() || |
192 !stream_requests_.empty()) { | 192 !stream_requests_.empty()) { |
193 // The session must be closed before it is destroyed. | 193 // The session must be closed before it is destroyed. |
194 DCHECK(streams()->empty()); | 194 DCHECK(streams()->empty()); |
195 CloseAllStreams(ERR_UNEXPECTED); | 195 CloseAllStreams(ERR_UNEXPECTED); |
196 DCHECK(observers_.empty()); | 196 DCHECK(observers_.empty()); |
197 CloseAllObservers(ERR_UNEXPECTED); | 197 CloseAllObservers(ERR_UNEXPECTED); |
198 | 198 |
199 connection()->set_debug_visitor(NULL); | 199 connection()->set_debug_visitor(nullptr); |
200 net_log_.EndEvent(NetLog::TYPE_QUIC_SESSION); | 200 net_log_.EndEvent(NetLog::TYPE_QUIC_SESSION); |
201 | 201 |
202 while (!stream_requests_.empty()) { | 202 while (!stream_requests_.empty()) { |
203 StreamRequest* request = stream_requests_.front(); | 203 StreamRequest* request = stream_requests_.front(); |
204 stream_requests_.pop_front(); | 204 stream_requests_.pop_front(); |
205 request->OnRequestCompleteFailure(ERR_ABORTED); | 205 request->OnRequestCompleteFailure(ERR_ABORTED); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 if (connection()->connected()) { | 209 if (connection()->connected()) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 StreamRequestQueue::iterator it = | 354 StreamRequestQueue::iterator it = |
355 std::find(stream_requests_.begin(), stream_requests_.end(), request); | 355 std::find(stream_requests_.begin(), stream_requests_.end(), request); |
356 if (it != stream_requests_.end()) { | 356 if (it != stream_requests_.end()) { |
357 it = stream_requests_.erase(it); | 357 it = stream_requests_.erase(it); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 QuicReliableClientStream* QuicClientSession::CreateOutgoingDataStream() { | 361 QuicReliableClientStream* QuicClientSession::CreateOutgoingDataStream() { |
362 if (!crypto_stream_->encryption_established()) { | 362 if (!crypto_stream_->encryption_established()) { |
363 DVLOG(1) << "Encryption not active so no outgoing stream created."; | 363 DVLOG(1) << "Encryption not active so no outgoing stream created."; |
364 return NULL; | 364 return nullptr; |
365 } | 365 } |
366 if (GetNumOpenStreams() >= get_max_open_streams()) { | 366 if (GetNumOpenStreams() >= get_max_open_streams()) { |
367 DVLOG(1) << "Failed to create a new outgoing stream. " | 367 DVLOG(1) << "Failed to create a new outgoing stream. " |
368 << "Already " << GetNumOpenStreams() << " open."; | 368 << "Already " << GetNumOpenStreams() << " open."; |
369 return NULL; | 369 return nullptr; |
370 } | 370 } |
371 if (goaway_received()) { | 371 if (goaway_received()) { |
372 DVLOG(1) << "Failed to create a new outgoing stream. " | 372 DVLOG(1) << "Failed to create a new outgoing stream. " |
373 << "Already received goaway."; | 373 << "Already received goaway."; |
374 return NULL; | 374 return nullptr; |
375 } | 375 } |
376 if (going_away_) { | 376 if (going_away_) { |
377 RecordUnexpectedOpenStreams(CREATE_OUTGOING_RELIABLE_STREAM); | 377 RecordUnexpectedOpenStreams(CREATE_OUTGOING_RELIABLE_STREAM); |
378 return NULL; | 378 return nullptr; |
379 } | 379 } |
380 return CreateOutgoingReliableStreamImpl(); | 380 return CreateOutgoingReliableStreamImpl(); |
381 } | 381 } |
382 | 382 |
383 QuicReliableClientStream* | 383 QuicReliableClientStream* |
384 QuicClientSession::CreateOutgoingReliableStreamImpl() { | 384 QuicClientSession::CreateOutgoingReliableStreamImpl() { |
385 DCHECK(connection()->connected()); | 385 DCHECK(connection()->connected()); |
386 QuicReliableClientStream* stream = | 386 QuicReliableClientStream* stream = |
387 new QuicReliableClientStream(GetNextStreamId(), this, net_log_); | 387 new QuicReliableClientStream(GetNextStreamId(), this, net_log_); |
388 ActivateStream(stream); | 388 ActivateStream(stream); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 return true; | 503 return true; |
504 } | 504 } |
505 | 505 |
506 return SpdySession::CanPool(transport_security_state_, ssl_info, | 506 return SpdySession::CanPool(transport_security_state_, ssl_info, |
507 server_host_port_.host(), hostname); | 507 server_host_port_.host(), hostname); |
508 } | 508 } |
509 | 509 |
510 QuicDataStream* QuicClientSession::CreateIncomingDataStream( | 510 QuicDataStream* QuicClientSession::CreateIncomingDataStream( |
511 QuicStreamId id) { | 511 QuicStreamId id) { |
512 DLOG(ERROR) << "Server push not supported"; | 512 DLOG(ERROR) << "Server push not supported"; |
513 return NULL; | 513 return nullptr; |
514 } | 514 } |
515 | 515 |
516 void QuicClientSession::CloseStream(QuicStreamId stream_id) { | 516 void QuicClientSession::CloseStream(QuicStreamId stream_id) { |
517 ReliableQuicStream* stream = GetStream(stream_id); | 517 ReliableQuicStream* stream = GetStream(stream_id); |
518 if (stream) { | 518 if (stream) { |
519 logger_->UpdateReceivedFrameCounts( | 519 logger_->UpdateReceivedFrameCounts( |
520 stream_id, stream->num_frames_received(), | 520 stream_id, stream->num_frames_received(), |
521 stream->num_duplicate_frames_received()); | 521 stream->num_duplicate_frames_received()); |
522 } | 522 } |
523 QuicSession::CloseStream(stream_id); | 523 QuicSession::CloseStream(stream_id); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 return; | 863 return; |
864 | 864 |
865 // TODO(rch): re-enable this code once beta is cut. | 865 // TODO(rch): re-enable this code once beta is cut. |
866 // if (stream_factory_) | 866 // if (stream_factory_) |
867 // stream_factory_->OnSessionConnectTimeout(this); | 867 // stream_factory_->OnSessionConnectTimeout(this); |
868 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); | 868 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); |
869 // DCHECK_EQ(0u, GetNumOpenStreams()); | 869 // DCHECK_EQ(0u, GetNumOpenStreams()); |
870 } | 870 } |
871 | 871 |
872 } // namespace net | 872 } // namespace net |
OLD | NEW |