| 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" |
| 11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| 12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 13 #include "net/quic/quic_connection_helper.h" | 13 #include "net/quic/quic_connection_helper.h" |
| 14 #include "net/quic/quic_crypto_client_stream_factory.h" | 14 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 15 #include "net/quic/quic_stream_factory.h" | 15 #include "net/quic/quic_stream_factory.h" |
| 16 #include "net/udp/datagram_client_socket.h" | 16 #include "net/udp/datagram_client_socket.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 QuicClientSession::QuicClientSession( | 20 QuicClientSession::QuicClientSession( |
| 21 QuicConnection* connection, | 21 QuicConnection* connection, |
| 22 DatagramClientSocket* socket, | 22 DatagramClientSocket* socket, |
| 23 QuicStreamFactory* stream_factory, | 23 QuicStreamFactory* stream_factory, |
| 24 QuicCryptoClientStreamFactory* crypto_client_stream_factory, | 24 QuicCryptoClientStreamFactory* crypto_client_stream_factory, |
| 25 const string& server_hostname, | 25 const string& server_hostname, |
| 26 QuicCryptoClientConfig* crypto_config, |
| 26 NetLog* net_log) | 27 NetLog* net_log) |
| 27 : QuicSession(connection, false), | 28 : QuicSession(connection, false), |
| 28 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 29 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| 29 ALLOW_THIS_IN_INITIALIZER_LIST(crypto_stream_( | |
| 30 crypto_client_stream_factory ? | |
| 31 crypto_client_stream_factory->CreateQuicCryptoClientStream( | |
| 32 this, server_hostname) : | |
| 33 new QuicCryptoClientStream(this, server_hostname))), | |
| 34 stream_factory_(stream_factory), | 30 stream_factory_(stream_factory), |
| 35 socket_(socket), | 31 socket_(socket), |
| 36 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), | 32 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), |
| 37 read_pending_(false), | 33 read_pending_(false), |
| 38 num_total_streams_(0), | 34 num_total_streams_(0), |
| 39 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), | 35 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), |
| 40 logger_(net_log_) { | 36 logger_(net_log_) { |
| 37 config_.SetDefaults(); |
| 38 crypto_stream_.reset( |
| 39 crypto_client_stream_factory ? |
| 40 crypto_client_stream_factory->CreateQuicCryptoClientStream( |
| 41 server_hostname, config_, this, crypto_config) : |
| 42 new QuicCryptoClientStream( |
| 43 server_hostname, config_, this, crypto_config)); |
| 44 |
| 41 connection->set_debug_visitor(&logger_); | 45 connection->set_debug_visitor(&logger_); |
| 42 // TODO(rch): pass in full host port proxy pair | 46 // TODO(rch): pass in full host port proxy pair |
| 43 net_log_.BeginEvent( | 47 net_log_.BeginEvent( |
| 44 NetLog::TYPE_QUIC_SESSION, | 48 NetLog::TYPE_QUIC_SESSION, |
| 45 NetLog::StringCallback("host", &server_hostname)); | 49 NetLog::StringCallback("host", &server_hostname)); |
| 46 } | 50 } |
| 47 | 51 |
| 48 QuicClientSession::~QuicClientSession() { | 52 QuicClientSession::~QuicClientSession() { |
| 49 connection()->set_debug_visitor(NULL); | 53 connection()->set_debug_visitor(NULL); |
| 50 net_log_.EndEvent(NetLog::TYPE_QUIC_SESSION); | 54 net_log_.EndEvent(NetLog::TYPE_QUIC_SESSION); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 connection()->ProcessUdpPacket(local_address, peer_address, packet); | 176 connection()->ProcessUdpPacket(local_address, peer_address, packet); |
| 173 if (!connection()->connected()) { | 177 if (!connection()->connected()) { |
| 174 stream_factory_->OnSessionClose(this); | 178 stream_factory_->OnSessionClose(this); |
| 175 return; | 179 return; |
| 176 } | 180 } |
| 177 StartReading(); | 181 StartReading(); |
| 178 } | 182 } |
| 179 } | 183 } |
| 180 | 184 |
| 181 } // namespace net | 185 } // namespace net |
| OLD | NEW |