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.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/quic/quic_connection_helper.h" | 14 #include "net/quic/quic_connection_helper.h" |
15 #include "net/quic/quic_crypto_client_stream_factory.h" | 15 #include "net/quic/quic_crypto_client_stream_factory.h" |
16 #include "net/quic/quic_stream_factory.h" | 16 #include "net/quic/quic_stream_factory.h" |
17 #include "net/udp/datagram_client_socket.h" | 17 #include "net/udp/datagram_client_socket.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 QuicClientSession::QuicClientSession( | 21 QuicClientSession::QuicClientSession( |
22 QuicConnection* connection, | 22 QuicConnection* connection, |
23 DatagramClientSocket* socket, | 23 DatagramClientSocket* socket, |
24 QuicStreamFactory* stream_factory, | 24 QuicStreamFactory* stream_factory, |
25 QuicCryptoClientStreamFactory* crypto_client_stream_factory, | 25 QuicCryptoClientStreamFactory* crypto_client_stream_factory, |
26 const string& server_hostname, | 26 const string& server_hostname, |
| 27 const QuicConfig& config, |
27 QuicCryptoClientConfig* crypto_config, | 28 QuicCryptoClientConfig* crypto_config, |
28 NetLog* net_log) | 29 NetLog* net_log) |
29 : QuicSession(connection, false), | 30 : QuicSession(connection, config, false), |
30 weak_factory_(this), | 31 weak_factory_(this), |
31 stream_factory_(stream_factory), | 32 stream_factory_(stream_factory), |
32 socket_(socket), | 33 socket_(socket), |
33 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), | 34 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), |
34 read_pending_(false), | 35 read_pending_(false), |
35 num_total_streams_(0), | 36 num_total_streams_(0), |
36 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), | 37 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), |
37 logger_(net_log_) { | 38 logger_(net_log_) { |
38 config_.SetDefaults(); | 39 QuicSession::config()->SetDefaults(); |
39 crypto_stream_.reset( | 40 crypto_stream_.reset( |
40 crypto_client_stream_factory ? | 41 crypto_client_stream_factory ? |
41 crypto_client_stream_factory->CreateQuicCryptoClientStream( | 42 crypto_client_stream_factory->CreateQuicCryptoClientStream( |
42 server_hostname, config_, this, crypto_config) : | 43 server_hostname, this, crypto_config) : |
43 new QuicCryptoClientStream( | 44 new QuicCryptoClientStream(server_hostname, this, crypto_config)); |
44 server_hostname, config_, this, crypto_config)); | |
45 | 45 |
46 connection->set_debug_visitor(&logger_); | 46 connection->set_debug_visitor(&logger_); |
47 // TODO(rch): pass in full host port proxy pair | 47 // TODO(rch): pass in full host port proxy pair |
48 net_log_.BeginEvent( | 48 net_log_.BeginEvent( |
49 NetLog::TYPE_QUIC_SESSION, | 49 NetLog::TYPE_QUIC_SESSION, |
50 NetLog::StringCallback("host", &server_hostname)); | 50 NetLog::StringCallback("host", &server_hostname)); |
51 } | 51 } |
52 | 52 |
53 QuicClientSession::~QuicClientSession() { | 53 QuicClientSession::~QuicClientSession() { |
54 DCHECK(callback_.is_null()); | 54 DCHECK(callback_.is_null()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // use a weak pointer to be safe. | 198 // use a weak pointer to be safe. |
199 connection()->ProcessUdpPacket(local_address, peer_address, packet); | 199 connection()->ProcessUdpPacket(local_address, peer_address, packet); |
200 if (!connection()->connected()) { | 200 if (!connection()->connected()) { |
201 stream_factory_->OnSessionClose(this); | 201 stream_factory_->OnSessionClose(this); |
202 return; | 202 return; |
203 } | 203 } |
204 StartReading(); | 204 StartReading(); |
205 } | 205 } |
206 | 206 |
207 } // namespace net | 207 } // namespace net |
OLD | NEW |