Chromium Code Reviews| 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 NetLog::TYPE_QUIC_SESSION, | 48 NetLog::TYPE_QUIC_SESSION, |
| 49 NetLog::StringCallback("host", &server_hostname)); | 49 NetLog::StringCallback("host", &server_hostname)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 QuicClientSession::~QuicClientSession() { | 52 QuicClientSession::~QuicClientSession() { |
| 53 connection()->set_debug_visitor(NULL); | 53 connection()->set_debug_visitor(NULL); |
| 54 net_log_.EndEvent(NetLog::TYPE_QUIC_SESSION); | 54 net_log_.EndEvent(NetLog::TYPE_QUIC_SESSION); |
| 55 } | 55 } |
| 56 | 56 |
| 57 QuicReliableClientStream* QuicClientSession::CreateOutgoingReliableStream() { | 57 QuicReliableClientStream* QuicClientSession::CreateOutgoingReliableStream() { |
| 58 if (!crypto_stream_->handshake_complete()) { | 58 if (!crypto_stream_->encryption_established()) { |
| 59 DLOG(INFO) << "Crypto handshake not complete, no outgoing stream created."; | 59 DLOG(INFO) << "Encryption not active so no outgoing stream created."; |
| 60 return NULL; | 60 return NULL; |
| 61 } | 61 } |
| 62 if (GetNumOpenStreams() >= get_max_open_streams()) { | 62 if (GetNumOpenStreams() >= get_max_open_streams()) { |
| 63 DLOG(INFO) << "Failed to create a new outgoing stream. " | 63 DLOG(INFO) << "Failed to create a new outgoing stream. " |
| 64 << "Already " << GetNumOpenStreams() << " open."; | 64 << "Already " << GetNumOpenStreams() << " open."; |
| 65 return NULL; | 65 return NULL; |
| 66 } | 66 } |
| 67 if (goaway_received()) { | 67 if (goaway_received()) { |
| 68 DLOG(INFO) << "Failed to create a new outgoing stream. " | 68 DLOG(INFO) << "Failed to create a new outgoing stream. " |
| 69 << "Already received goaway."; | 69 << "Already received goaway."; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 80 return crypto_stream_.get(); | 80 return crypto_stream_.get(); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 int QuicClientSession::CryptoConnect(const CompletionCallback& callback) { | 83 int QuicClientSession::CryptoConnect(const CompletionCallback& callback) { |
| 84 if (!crypto_stream_->CryptoConnect()) { | 84 if (!crypto_stream_->CryptoConnect()) { |
| 85 // TODO(wtc): change crypto_stream_.CryptoConnect() to return a | 85 // TODO(wtc): change crypto_stream_.CryptoConnect() to return a |
| 86 // QuicErrorCode and map it to a net error code. | 86 // QuicErrorCode and map it to a net error code. |
| 87 return ERR_CONNECTION_FAILED; | 87 return ERR_CONNECTION_FAILED; |
| 88 } | 88 } |
| 89 | 89 |
| 90 if (IsCryptoHandshakeComplete()) { | 90 if (IsCryptoHandshakeConfirmed()) { |
| 91 return OK; | 91 return OK; |
| 92 } | 92 } |
| 93 | 93 |
| 94 callback_ = callback; | 94 callback_ = callback; |
| 95 return ERR_IO_PENDING; | 95 return ERR_IO_PENDING; |
| 96 } | 96 } |
| 97 | 97 |
| 98 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream( | 98 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream( |
| 99 QuicStreamId id) { | 99 QuicStreamId id) { |
| 100 DLOG(ERROR) << "Server push not supported"; | 100 DLOG(ERROR) << "Server push not supported"; |
| 101 return NULL; | 101 return NULL; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void QuicClientSession::CloseStream(QuicStreamId stream_id) { | 104 void QuicClientSession::CloseStream(QuicStreamId stream_id) { |
| 105 QuicSession::CloseStream(stream_id); | 105 QuicSession::CloseStream(stream_id); |
| 106 | 106 |
| 107 if (GetNumOpenStreams() == 0) { | 107 if (GetNumOpenStreams() == 0) { |
| 108 stream_factory_->OnIdleSession(this); | 108 stream_factory_->OnIdleSession(this); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 void QuicClientSession::OnCryptoHandshakeComplete(QuicErrorCode error) { | 112 void QuicClientSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { |
| 113 if (!callback_.is_null()) { | 113 if (!callback_.is_null()) { |
| 114 callback_.Run(error == QUIC_NO_ERROR ? OK : ERR_UNEXPECTED); | 114 // TODO(rtenneti): how should we handle ENCRYPTION_FIRST_ESTABLISHED event? |
|
wtc
2013/04/25 00:39:19
I don't understand this TODO comment. Could you el
Ryan Hamilton
2013/04/25 17:59:45
I believe we should handle this even by executing
ramant (doing other things)
2013/04/26 19:29:54
Will upload a separate CL for unit test of 0RTT.
D
| |
| 115 callback_.Run(event == ENCRYPTION_REESTABLISHED ? ERR_UNEXPECTED : OK); | |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 void QuicClientSession::StartReading() { | 119 void QuicClientSession::StartReading() { |
| 119 if (read_pending_) { | 120 if (read_pending_) { |
| 120 return; | 121 return; |
| 121 } | 122 } |
| 122 read_pending_ = true; | 123 read_pending_ = true; |
| 123 int rv = socket_->Read(read_buffer_, read_buffer_->size(), | 124 int rv = socket_->Read(read_buffer_, read_buffer_->size(), |
| 124 base::Bind(&QuicClientSession::OnReadComplete, | 125 base::Bind(&QuicClientSession::OnReadComplete, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 connection()->ProcessUdpPacket(local_address, peer_address, packet); | 177 connection()->ProcessUdpPacket(local_address, peer_address, packet); |
| 177 if (!connection()->connected()) { | 178 if (!connection()->connected()) { |
| 178 stream_factory_->OnSessionClose(this); | 179 stream_factory_->OnSessionClose(this); |
| 179 return; | 180 return; |
| 180 } | 181 } |
| 181 StartReading(); | 182 StartReading(); |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 | 185 |
| 185 } // namespace net | 186 } // namespace net |
| OLD | NEW |