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/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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "net/quic/quic_connection_helper.h" | 16 #include "net/quic/quic_connection_helper.h" |
| 17 #include "net/quic/quic_crypto_client_stream_factory.h" | 17 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 18 #include "net/quic/quic_default_packet_writer.h" | 18 #include "net/quic/quic_default_packet_writer.h" |
| 19 #include "net/quic/quic_session_key.h" | |
| 19 #include "net/quic/quic_stream_factory.h" | 20 #include "net/quic/quic_stream_factory.h" |
| 20 #include "net/ssl/ssl_info.h" | 21 #include "net/ssl/ssl_info.h" |
| 21 #include "net/udp/datagram_client_socket.h" | 22 #include "net/udp/datagram_client_socket.h" |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 // Note: these values must be kept in sync with the corresponding values in: | 28 // Note: these values must be kept in sync with the corresponding values in: |
| 28 // tools/metrics/histograms/histograms.xml | 29 // tools/metrics/histograms/histograms.xml |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 session_.reset(); | 80 session_.reset(); |
| 80 ResetAndReturn(&callback_).Run(rv); | 81 ResetAndReturn(&callback_).Run(rv); |
| 81 } | 82 } |
| 82 | 83 |
| 83 QuicClientSession::QuicClientSession( | 84 QuicClientSession::QuicClientSession( |
| 84 QuicConnection* connection, | 85 QuicConnection* connection, |
| 85 scoped_ptr<DatagramClientSocket> socket, | 86 scoped_ptr<DatagramClientSocket> socket, |
| 86 scoped_ptr<QuicDefaultPacketWriter> writer, | 87 scoped_ptr<QuicDefaultPacketWriter> writer, |
| 87 QuicStreamFactory* stream_factory, | 88 QuicStreamFactory* stream_factory, |
| 88 QuicCryptoClientStreamFactory* crypto_client_stream_factory, | 89 QuicCryptoClientStreamFactory* crypto_client_stream_factory, |
| 89 const string& server_hostname, | 90 const QuicSessionKey& session_key, |
| 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 session_key, this, crypto_config) : |
| 109 new QuicCryptoClientStream(server_hostname, this, crypto_config)); | 110 new QuicCryptoClientStream( |
| 111 session_key, 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", &session_key.host_port_pair().host())); |
|
wtc
2014/03/13 22:22:03
Nit: perhaps QuicSessionKey should provide a host(
ramant (doing other things)
2014/03/13 23:46:36
Done.
| |
| 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. |
| 120 DCHECK(streams()->empty()); | 122 DCHECK(streams()->empty()); |
| 121 CloseAllStreams(ERR_UNEXPECTED); | 123 CloseAllStreams(ERR_UNEXPECTED); |
| 122 DCHECK(observers_.empty()); | 124 DCHECK(observers_.empty()); |
| 123 CloseAllObservers(ERR_UNEXPECTED); | 125 CloseAllObservers(ERR_UNEXPECTED); |
| 124 | 126 |
| 125 connection()->set_debug_visitor(NULL); | 127 connection()->set_debug_visitor(NULL); |
| (...skipping 441 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 |