| 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 // A client specific QuicSession subclass. This class owns the underlying | 5 // A client specific QuicSession subclass. This class owns the underlying |
| 6 // QuicConnection and QuicConnectionHelper objects. The connection stores | 6 // QuicConnection and QuicConnectionHelper objects. The connection stores |
| 7 // a non-owning pointer to the helper so this session needs to ensure that | 7 // a non-owning pointer to the helper so this session needs to ensure that |
| 8 // the helper outlives the connection. | 8 // the helper outlives the connection. |
| 9 | 9 |
| 10 #ifndef NET_QUIC_QUIC_CLIENT_SESSION_H_ | 10 #ifndef NET_QUIC_QUIC_CLIENT_SESSION_H_ |
| 11 #define NET_QUIC_QUIC_CLIENT_SESSION_H_ | 11 #define NET_QUIC_QUIC_CLIENT_SESSION_H_ |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
| 20 #include "net/proxy/proxy_server.h" | 20 #include "net/proxy/proxy_server.h" |
| 21 #include "net/quic/quic_client_session_base.h" | 21 #include "net/quic/quic_client_session_base.h" |
| 22 #include "net/quic/quic_connection_logger.h" | 22 #include "net/quic/quic_connection_logger.h" |
| 23 #include "net/quic/quic_crypto_client_stream.h" | 23 #include "net/quic/quic_crypto_client_stream.h" |
| 24 #include "net/quic/quic_packet_reader.h" |
| 24 #include "net/quic/quic_protocol.h" | 25 #include "net/quic/quic_protocol.h" |
| 25 #include "net/quic/quic_reliable_client_stream.h" | 26 #include "net/quic/quic_reliable_client_stream.h" |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 | 29 |
| 29 class CertVerifyResult; | 30 class CertVerifyResult; |
| 30 class DatagramClientSocket; | 31 class DatagramClientSocket; |
| 31 class QuicConnectionHelper; | 32 class QuicConnectionHelper; |
| 32 class QuicCryptoClientStreamFactory; | 33 class QuicCryptoClientStreamFactory; |
| 33 class QuicServerId; | 34 class QuicServerId; |
| 34 class QuicServerInfo; | 35 class QuicServerInfo; |
| 35 class QuicStreamFactory; | 36 class QuicStreamFactory; |
| 36 class SSLInfo; | 37 class SSLInfo; |
| 37 class TransportSecurityState; | 38 class TransportSecurityState; |
| 38 | 39 |
| 39 namespace test { | 40 namespace test { |
| 40 class QuicClientSessionPeer; | 41 class QuicClientSessionPeer; |
| 41 } // namespace test | 42 } // namespace test |
| 42 | 43 |
| 43 class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase { | 44 class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase, |
| 45 public QuicPacketReader::Visitor { |
| 44 public: | 46 public: |
| 45 // An interface for observing events on a session. | 47 // An interface for observing events on a session. |
| 46 class NET_EXPORT_PRIVATE Observer { | 48 class NET_EXPORT_PRIVATE Observer { |
| 47 public: | 49 public: |
| 48 virtual ~Observer() {} | 50 virtual ~Observer() {} |
| 49 virtual void OnCryptoHandshakeConfirmed() = 0; | 51 virtual void OnCryptoHandshakeConfirmed() = 0; |
| 50 virtual void OnSessionClosed(int error) = 0; | 52 virtual void OnSessionClosed(int error) = 0; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 // A helper class used to manage a request to create a stream. | 55 // A helper class used to manage a request to create a stream. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 143 |
| 142 // QuicClientSessionBase methods: | 144 // QuicClientSessionBase methods: |
| 143 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; | 145 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; |
| 144 void OnProofVerifyDetailsAvailable( | 146 void OnProofVerifyDetailsAvailable( |
| 145 const ProofVerifyDetails& verify_details) override; | 147 const ProofVerifyDetails& verify_details) override; |
| 146 | 148 |
| 147 // QuicConnectionVisitorInterface methods: | 149 // QuicConnectionVisitorInterface methods: |
| 148 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override; | 150 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override; |
| 149 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; | 151 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; |
| 150 | 152 |
| 153 // QuicPacketReader::Visitor methods: |
| 154 void OnReadError(int result) override; |
| 155 bool OnPacket(const QuicEncryptedPacket& packet, |
| 156 IPEndPoint local_address, |
| 157 IPEndPoint peer_address) override; |
| 158 |
| 151 // Performs a crypto handshake with the server. | 159 // Performs a crypto handshake with the server. |
| 152 int CryptoConnect(bool require_confirmation, | 160 int CryptoConnect(bool require_confirmation, |
| 153 const CompletionCallback& callback); | 161 const CompletionCallback& callback); |
| 154 | 162 |
| 155 // Resumes a crypto handshake with the server after a timeout. | 163 // Resumes a crypto handshake with the server after a timeout. |
| 156 int ResumeCryptoConnect(const CompletionCallback& callback); | 164 int ResumeCryptoConnect(const CompletionCallback& callback); |
| 157 | 165 |
| 158 // Causes the QuicConnectionHelper to start reading from the socket | 166 // Causes the QuicConnectionHelper to start reading from the socket |
| 159 // and passing the data along to the QuicConnection. | 167 // and passing the data along to the QuicConnection. |
| 160 void StartReading(); | 168 void StartReading(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // delete |this|. | 229 // delete |this|. |
| 222 void NotifyFactoryOfSessionClosed(); | 230 void NotifyFactoryOfSessionClosed(); |
| 223 | 231 |
| 224 void OnConnectTimeout(); | 232 void OnConnectTimeout(); |
| 225 | 233 |
| 226 QuicServerId server_id_; | 234 QuicServerId server_id_; |
| 227 bool require_confirmation_; | 235 bool require_confirmation_; |
| 228 scoped_ptr<QuicCryptoClientStream> crypto_stream_; | 236 scoped_ptr<QuicCryptoClientStream> crypto_stream_; |
| 229 QuicStreamFactory* stream_factory_; | 237 QuicStreamFactory* stream_factory_; |
| 230 scoped_ptr<DatagramClientSocket> socket_; | 238 scoped_ptr<DatagramClientSocket> socket_; |
| 231 scoped_refptr<IOBufferWithSize> read_buffer_; | |
| 232 TransportSecurityState* transport_security_state_; | 239 TransportSecurityState* transport_security_state_; |
| 233 scoped_ptr<QuicServerInfo> server_info_; | 240 scoped_ptr<QuicServerInfo> server_info_; |
| 234 scoped_ptr<CertVerifyResult> cert_verify_result_; | 241 scoped_ptr<CertVerifyResult> cert_verify_result_; |
| 235 std::string pinning_failure_log_; | 242 std::string pinning_failure_log_; |
| 236 ObserverSet observers_; | 243 ObserverSet observers_; |
| 237 StreamRequestQueue stream_requests_; | 244 StreamRequestQueue stream_requests_; |
| 238 bool read_pending_; | |
| 239 CompletionCallback callback_; | 245 CompletionCallback callback_; |
| 240 size_t num_total_streams_; | 246 size_t num_total_streams_; |
| 241 base::TaskRunner* task_runner_; | 247 base::TaskRunner* task_runner_; |
| 242 BoundNetLog net_log_; | 248 BoundNetLog net_log_; |
| 249 QuicPacketReader packet_reader_; |
| 243 base::TimeTicks dns_resolution_end_time_; | 250 base::TimeTicks dns_resolution_end_time_; |
| 244 base::TimeTicks handshake_start_; // Time the handshake was started. | 251 base::TimeTicks handshake_start_; // Time the handshake was started. |
| 245 scoped_ptr<QuicConnectionLogger> logger_; | 252 scoped_ptr<QuicConnectionLogger> logger_; |
| 246 // Number of packets read in the current read loop. | |
| 247 size_t num_packets_read_; | |
| 248 // True when the session is going away, and streams may no longer be created | 253 // True when the session is going away, and streams may no longer be created |
| 249 // on this session. Existing stream will continue to be processed. | 254 // on this session. Existing stream will continue to be processed. |
| 250 bool going_away_; | 255 bool going_away_; |
| 251 base::WeakPtrFactory<QuicClientSession> weak_factory_; | 256 base::WeakPtrFactory<QuicClientSession> weak_factory_; |
| 252 | 257 |
| 253 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); | 258 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); |
| 254 }; | 259 }; |
| 255 | 260 |
| 256 } // namespace net | 261 } // namespace net |
| 257 | 262 |
| 258 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ | 263 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ |
| OLD | NEW |