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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 ResetAndReturn(&callback_).Run(rv); | 80 ResetAndReturn(&callback_).Run(rv); |
81 } | 81 } |
82 | 82 |
83 QuicClientSession::QuicClientSession( | 83 QuicClientSession::QuicClientSession( |
84 QuicConnection* connection, | 84 QuicConnection* connection, |
85 scoped_ptr<DatagramClientSocket> socket, | 85 scoped_ptr<DatagramClientSocket> socket, |
86 scoped_ptr<QuicDefaultPacketWriter> writer, | 86 scoped_ptr<QuicDefaultPacketWriter> writer, |
87 QuicStreamFactory* stream_factory, | 87 QuicStreamFactory* stream_factory, |
88 QuicCryptoClientStreamFactory* crypto_client_stream_factory, | 88 QuicCryptoClientStreamFactory* crypto_client_stream_factory, |
89 const string& server_hostname, | 89 const string& server_hostname, |
| 90 uint16 server_port, |
90 const QuicConfig& config, | 91 const QuicConfig& config, |
91 QuicCryptoClientConfig* crypto_config, | 92 QuicCryptoClientConfig* crypto_config, |
92 NetLog* net_log) | 93 NetLog* net_log) |
93 : QuicSession(connection, config), | 94 : QuicSession(connection, config), |
94 require_confirmation_(false), | 95 require_confirmation_(false), |
95 stream_factory_(stream_factory), | 96 stream_factory_(stream_factory), |
96 socket_(socket.Pass()), | 97 socket_(socket.Pass()), |
97 writer_(writer.Pass()), | 98 writer_(writer.Pass()), |
98 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), | 99 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), |
99 read_pending_(false), | 100 read_pending_(false), |
100 num_total_streams_(0), | 101 num_total_streams_(0), |
101 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), | 102 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), |
102 logger_(net_log_), | 103 logger_(net_log_), |
103 num_packets_read_(0), | 104 num_packets_read_(0), |
104 weak_factory_(this) { | 105 weak_factory_(this) { |
105 crypto_stream_.reset( | 106 crypto_stream_.reset( |
106 crypto_client_stream_factory ? | 107 crypto_client_stream_factory ? |
107 crypto_client_stream_factory->CreateQuicCryptoClientStream( | 108 crypto_client_stream_factory->CreateQuicCryptoClientStream( |
108 server_hostname, this, crypto_config) : | 109 server_hostname, server_port, this, crypto_config) : |
109 new QuicCryptoClientStream(server_hostname, this, crypto_config)); | 110 new QuicCryptoClientStream( |
| 111 server_hostname, server_port, this, crypto_config)); |
110 | 112 |
111 connection->set_debug_visitor(&logger_); | 113 connection->set_debug_visitor(&logger_); |
112 // TODO(rch): pass in full host port proxy pair | 114 // TODO(rch): pass in full host port proxy pair |
113 net_log_.BeginEvent( | 115 net_log_.BeginEvent( |
114 NetLog::TYPE_QUIC_SESSION, | 116 NetLog::TYPE_QUIC_SESSION, |
115 NetLog::StringCallback("host", &server_hostname)); | 117 NetLog::StringCallback("host", &server_hostname)); |
116 } | 118 } |
117 | 119 |
118 QuicClientSession::~QuicClientSession() { | 120 QuicClientSession::~QuicClientSession() { |
119 // The session must be closed before it is destroyed. | 121 // The session must be closed before it is destroyed. |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 } | 569 } |
568 | 570 |
569 void QuicClientSession::NotifyFactoryOfSessionClosed() { | 571 void QuicClientSession::NotifyFactoryOfSessionClosed() { |
570 DCHECK_EQ(0u, GetNumOpenStreams()); | 572 DCHECK_EQ(0u, GetNumOpenStreams()); |
571 // Will delete |this|. | 573 // Will delete |this|. |
572 if (stream_factory_) | 574 if (stream_factory_) |
573 stream_factory_->OnSessionClosed(this); | 575 stream_factory_->OnSessionClosed(this); |
574 } | 576 } |
575 | 577 |
576 } // namespace net | 578 } // namespace net |
OLD | NEW |