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/hash_tables.h" | 15 #include "base/hash_tables.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/quic/quic_connection_logger.h" | 17 #include "net/quic/quic_connection_logger.h" |
18 #include "net/quic/quic_crypto_client_stream.h" | 18 #include "net/quic/quic_crypto_client_stream.h" |
19 #include "net/quic/quic_reliable_client_stream.h" | 19 #include "net/quic/quic_reliable_client_stream.h" |
20 #include "net/quic/quic_session.h" | 20 #include "net/quic/quic_session.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 class DatagramClientSocket; | 24 class DatagramClientSocket; |
25 class QuicConnectionHelper; | 25 class QuicConnectionHelper; |
26 class QuicCryptoClientStreamFactory; | 26 class QuicCryptoClientStreamFactory; |
27 class QuicStreamFactory; | 27 class QuicStreamFactory; |
28 | 28 |
| 29 namespace test { |
| 30 class QuicClientSessionPeer; |
| 31 } // namespace test |
| 32 |
29 class NET_EXPORT_PRIVATE QuicClientSession : public QuicSession { | 33 class NET_EXPORT_PRIVATE QuicClientSession : public QuicSession { |
30 public: | 34 public: |
31 // Constructs a new session which will own |connection| and |helper|, but | 35 // Constructs a new session which will own |connection| and |helper|, but |
32 // not |stream_factory|, which must outlive this session. | 36 // not |stream_factory|, which must outlive this session. |
33 // TODO(rch): decouple the factory from the session via a Delegate interface. | 37 // TODO(rch): decouple the factory from the session via a Delegate interface. |
34 QuicClientSession(QuicConnection* connection, | 38 QuicClientSession(QuicConnection* connection, |
35 DatagramClientSocket* socket, | 39 DatagramClientSocket* socket, |
36 QuicStreamFactory* stream_factory, | 40 QuicStreamFactory* stream_factory, |
37 QuicCryptoClientStreamFactory* crypto_client_stream_factory, | 41 QuicCryptoClientStreamFactory* crypto_client_stream_factory, |
38 const std::string& server_hostname, | 42 const std::string& server_hostname, |
| 43 const QuicConfig& config, |
39 QuicCryptoClientConfig* crypto_config, | 44 QuicCryptoClientConfig* crypto_config, |
40 NetLog* net_log); | 45 NetLog* net_log); |
41 | 46 |
42 virtual ~QuicClientSession(); | 47 virtual ~QuicClientSession(); |
43 | 48 |
44 // QuicSession methods: | 49 // QuicSession methods: |
45 virtual QuicReliableClientStream* CreateOutgoingReliableStream() OVERRIDE; | 50 virtual QuicReliableClientStream* CreateOutgoingReliableStream() OVERRIDE; |
46 virtual QuicCryptoClientStream* GetCryptoStream() OVERRIDE; | 51 virtual QuicCryptoClientStream* GetCryptoStream() OVERRIDE; |
47 virtual void CloseStream(QuicStreamId stream_id) OVERRIDE; | 52 virtual void CloseStream(QuicStreamId stream_id) OVERRIDE; |
48 virtual void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) OVERRIDE; | 53 virtual void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) OVERRIDE; |
(...skipping 14 matching lines...) Expand all Loading... |
63 base::Value* GetInfoAsValue(const HostPortPair& pair) const; | 68 base::Value* GetInfoAsValue(const HostPortPair& pair) const; |
64 | 69 |
65 const BoundNetLog& net_log() const { return net_log_; } | 70 const BoundNetLog& net_log() const { return net_log_; } |
66 | 71 |
67 protected: | 72 protected: |
68 // QuicSession methods: | 73 // QuicSession methods: |
69 virtual ReliableQuicStream* CreateIncomingReliableStream( | 74 virtual ReliableQuicStream* CreateIncomingReliableStream( |
70 QuicStreamId id) OVERRIDE; | 75 QuicStreamId id) OVERRIDE; |
71 | 76 |
72 private: | 77 private: |
| 78 friend class test::QuicClientSessionPeer; |
73 // A completion callback invoked when a read completes. | 79 // A completion callback invoked when a read completes. |
74 void OnReadComplete(int result); | 80 void OnReadComplete(int result); |
75 | 81 |
76 base::WeakPtrFactory<QuicClientSession> weak_factory_; | 82 base::WeakPtrFactory<QuicClientSession> weak_factory_; |
77 // config_ contains non-crypto configuration options negotiated in the crypto | |
78 // handshake. | |
79 QuicConfig config_; | |
80 scoped_ptr<QuicCryptoClientStream> crypto_stream_; | 83 scoped_ptr<QuicCryptoClientStream> crypto_stream_; |
81 QuicStreamFactory* stream_factory_; | 84 QuicStreamFactory* stream_factory_; |
82 scoped_ptr<DatagramClientSocket> socket_; | 85 scoped_ptr<DatagramClientSocket> socket_; |
83 scoped_refptr<IOBufferWithSize> read_buffer_; | 86 scoped_refptr<IOBufferWithSize> read_buffer_; |
84 bool read_pending_; | 87 bool read_pending_; |
85 CompletionCallback callback_; | 88 CompletionCallback callback_; |
86 size_t num_total_streams_; | 89 size_t num_total_streams_; |
87 BoundNetLog net_log_; | 90 BoundNetLog net_log_; |
88 QuicConnectionLogger logger_; | 91 QuicConnectionLogger logger_; |
89 | 92 |
90 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); | 93 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace net | 96 } // namespace net |
94 | 97 |
95 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ | 98 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ |
OLD | NEW |