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_chromium_client_session.h" | 5 #include "net/quic/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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (!connection()->connected()) { | 388 if (!connection()->connected()) { |
389 DVLOG(1) << "Already closed."; | 389 DVLOG(1) << "Already closed."; |
390 return ERR_CONNECTION_CLOSED; | 390 return ERR_CONNECTION_CLOSED; |
391 } | 391 } |
392 | 392 |
393 if (going_away_) { | 393 if (going_away_) { |
394 RecordUnexpectedOpenStreams(TRY_CREATE_STREAM); | 394 RecordUnexpectedOpenStreams(TRY_CREATE_STREAM); |
395 return ERR_CONNECTION_CLOSED; | 395 return ERR_CONNECTION_CLOSED; |
396 } | 396 } |
397 | 397 |
398 if (GetNumOpenOutgoingStreams() < get_max_open_streams()) { | 398 if (GetNumOpenOutgoingStreams() < max_open_outgoing_streams()) { |
399 *stream = CreateOutgoingReliableStreamImpl(); | 399 *stream = CreateOutgoingReliableStreamImpl(); |
400 return OK; | 400 return OK; |
401 } | 401 } |
402 | 402 |
403 stream_requests_.push_back(request); | 403 stream_requests_.push_back(request); |
404 return ERR_IO_PENDING; | 404 return ERR_IO_PENDING; |
405 } | 405 } |
406 | 406 |
407 void QuicChromiumClientSession::CancelRequest(StreamRequest* request) { | 407 void QuicChromiumClientSession::CancelRequest(StreamRequest* request) { |
408 // Remove |request| from the queue while preserving the order of the | 408 // Remove |request| from the queue while preserving the order of the |
409 // other elements. | 409 // other elements. |
410 StreamRequestQueue::iterator it = | 410 StreamRequestQueue::iterator it = |
411 std::find(stream_requests_.begin(), stream_requests_.end(), request); | 411 std::find(stream_requests_.begin(), stream_requests_.end(), request); |
412 if (it != stream_requests_.end()) { | 412 if (it != stream_requests_.end()) { |
413 it = stream_requests_.erase(it); | 413 it = stream_requests_.erase(it); |
414 } | 414 } |
415 } | 415 } |
416 | 416 |
417 QuicChromiumClientStream* | 417 QuicChromiumClientStream* |
418 QuicChromiumClientSession::CreateOutgoingDynamicStream(SpdyPriority priority) { | 418 QuicChromiumClientSession::CreateOutgoingDynamicStream(SpdyPriority priority) { |
419 if (!crypto_stream_->encryption_established()) { | 419 if (!crypto_stream_->encryption_established()) { |
420 DVLOG(1) << "Encryption not active so no outgoing stream created."; | 420 DVLOG(1) << "Encryption not active so no outgoing stream created."; |
421 return nullptr; | 421 return nullptr; |
422 } | 422 } |
423 if (GetNumOpenOutgoingStreams() >= get_max_open_streams()) { | 423 if (GetNumOpenOutgoingStreams() >= max_open_outgoing_streams()) { |
424 DVLOG(1) << "Failed to create a new outgoing stream. " | 424 DVLOG(1) << "Failed to create a new outgoing stream. " |
425 << "Already " << GetNumOpenOutgoingStreams() << " open."; | 425 << "Already " << GetNumOpenOutgoingStreams() << " open."; |
426 return nullptr; | 426 return nullptr; |
427 } | 427 } |
428 if (goaway_received()) { | 428 if (goaway_received()) { |
429 DVLOG(1) << "Failed to create a new outgoing stream. " | 429 DVLOG(1) << "Failed to create a new outgoing stream. " |
430 << "Already received goaway."; | 430 << "Already received goaway."; |
431 return nullptr; | 431 return nullptr; |
432 } | 432 } |
433 if (going_away_) { | 433 if (going_away_) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 } | 591 } |
592 | 592 |
593 void QuicChromiumClientSession::SendRstStream(QuicStreamId id, | 593 void QuicChromiumClientSession::SendRstStream(QuicStreamId id, |
594 QuicRstStreamErrorCode error, | 594 QuicRstStreamErrorCode error, |
595 QuicStreamOffset bytes_written) { | 595 QuicStreamOffset bytes_written) { |
596 QuicSpdySession::SendRstStream(id, error, bytes_written); | 596 QuicSpdySession::SendRstStream(id, error, bytes_written); |
597 OnClosedStream(); | 597 OnClosedStream(); |
598 } | 598 } |
599 | 599 |
600 void QuicChromiumClientSession::OnClosedStream() { | 600 void QuicChromiumClientSession::OnClosedStream() { |
601 if (GetNumOpenOutgoingStreams() < get_max_open_streams() && | 601 if (GetNumOpenOutgoingStreams() < max_open_outgoing_streams() && |
602 !stream_requests_.empty() && crypto_stream_->encryption_established() && | 602 !stream_requests_.empty() && crypto_stream_->encryption_established() && |
603 !goaway_received() && !going_away_ && connection()->connected()) { | 603 !goaway_received() && !going_away_ && connection()->connected()) { |
604 StreamRequest* request = stream_requests_.front(); | 604 StreamRequest* request = stream_requests_.front(); |
605 stream_requests_.pop_front(); | 605 stream_requests_.pop_front(); |
606 request->OnRequestCompleteSuccess(CreateOutgoingReliableStreamImpl()); | 606 request->OnRequestCompleteSuccess(CreateOutgoingReliableStreamImpl()); |
607 } | 607 } |
608 | 608 |
609 if (GetNumOpenOutgoingStreams() == 0) { | 609 if (GetNumOpenOutgoingStreams() == 0) { |
610 stream_factory_->OnIdleSession(this); | 610 stream_factory_->OnIdleSession(this); |
611 } | 611 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 } | 1019 } |
1020 | 1020 |
1021 const DatagramClientSocket* QuicChromiumClientSession::GetDefaultSocket() | 1021 const DatagramClientSocket* QuicChromiumClientSession::GetDefaultSocket() |
1022 const { | 1022 const { |
1023 DCHECK(sockets_.back().get() != nullptr); | 1023 DCHECK(sockets_.back().get() != nullptr); |
1024 // The most recently added socket is the currently active one. | 1024 // The most recently added socket is the currently active one. |
1025 return sockets_.back().get(); | 1025 return sockets_.back().get(); |
1026 } | 1026 } |
1027 | 1027 |
1028 } // namespace net | 1028 } // namespace net |
OLD | NEW |