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_ |
(...skipping 13 matching lines...) Expand all Loading... |
24 class QuicStreamFactory; | 24 class QuicStreamFactory; |
25 | 25 |
26 class NET_EXPORT_PRIVATE QuicClientSession : public QuicSession { | 26 class NET_EXPORT_PRIVATE QuicClientSession : public QuicSession { |
27 public: | 27 public: |
28 // Constructs a new session which will own |connection| and |helper|, but | 28 // Constructs a new session which will own |connection| and |helper|, but |
29 // not |stream_factory|, which must outlive this session. | 29 // not |stream_factory|, which must outlive this session. |
30 // TODO(rch): decouple the factory from the session via a Delegate interface. | 30 // TODO(rch): decouple the factory from the session via a Delegate interface. |
31 QuicClientSession(QuicConnection* connection, | 31 QuicClientSession(QuicConnection* connection, |
32 QuicConnectionHelper* helper, | 32 QuicConnectionHelper* helper, |
33 QuicStreamFactory* stream_factory, | 33 QuicStreamFactory* stream_factory, |
34 const std::string& server_hostname, | 34 const std::string& server_hostname); |
35 NetLog* net_log); | |
36 | 35 |
37 virtual ~QuicClientSession(); | 36 virtual ~QuicClientSession(); |
38 | 37 |
39 // QuicSession methods: | 38 // QuicSession methods: |
40 virtual QuicReliableClientStream* CreateOutgoingReliableStream() OVERRIDE; | 39 virtual QuicReliableClientStream* CreateOutgoingReliableStream() OVERRIDE; |
41 virtual QuicCryptoClientStream* GetCryptoStream() OVERRIDE; | 40 virtual QuicCryptoClientStream* GetCryptoStream() OVERRIDE; |
42 virtual void CloseStream(QuicStreamId stream_id) OVERRIDE; | 41 virtual void CloseStream(QuicStreamId stream_id) OVERRIDE; |
43 virtual void OnCryptoHandshakeComplete(QuicErrorCode error) OVERRIDE; | 42 virtual void OnCryptoHandshakeComplete(QuicErrorCode error) OVERRIDE; |
44 | 43 |
45 // Performs a crypto handshake with the server. | 44 // Performs a crypto handshake with the server. |
46 int CryptoConnect(const CompletionCallback& callback); | 45 int CryptoConnect(const CompletionCallback& callback); |
47 | 46 |
48 // Causes the QuicConnectionHelper to start reading from the socket | 47 // Causes the QuicConnectionHelper to start reading from the socket |
49 // and passing the data along to the QuicConnection. | 48 // and passing the data along to the QuicConnection. |
50 void StartReading(); | 49 void StartReading(); |
51 | 50 |
52 // Close the session because of |error|. | 51 // Close the session because of |error|. |
53 void CloseSessionOnError(int error); | 52 void CloseSessionOnError(int error); |
54 | 53 |
55 base::Value* GetInfoAsValue(const HostPortPair& pair) const; | 54 base::Value* GetInfoAsValue(const HostPortPair& pair) const; |
56 | 55 |
57 const BoundNetLog& net_log() const { return net_log_; } | |
58 | |
59 protected: | 56 protected: |
60 // QuicSession methods: | 57 // QuicSession methods: |
61 virtual ReliableQuicStream* CreateIncomingReliableStream( | 58 virtual ReliableQuicStream* CreateIncomingReliableStream( |
62 QuicStreamId id) OVERRIDE; | 59 QuicStreamId id) OVERRIDE; |
63 | 60 |
64 private: | 61 private: |
65 // A completion callback invoked when a read completes. | 62 // A completion callback invoked when a read completes. |
66 void OnReadComplete(int result); | 63 void OnReadComplete(int result); |
67 | 64 |
68 base::WeakPtrFactory<QuicClientSession> weak_factory_; | 65 base::WeakPtrFactory<QuicClientSession> weak_factory_; |
69 QuicCryptoClientStream crypto_stream_; | 66 QuicCryptoClientStream crypto_stream_; |
70 scoped_ptr<QuicConnectionHelper> helper_; | 67 scoped_ptr<QuicConnectionHelper> helper_; |
71 QuicStreamFactory* stream_factory_; | 68 QuicStreamFactory* stream_factory_; |
72 scoped_refptr<IOBufferWithSize> read_buffer_; | 69 scoped_refptr<IOBufferWithSize> read_buffer_; |
73 bool read_pending_; | 70 bool read_pending_; |
74 CompletionCallback callback_; | 71 CompletionCallback callback_; |
75 size_t num_total_streams_; | |
76 BoundNetLog net_log_; | |
77 | 72 |
78 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); | 73 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); |
79 }; | 74 }; |
80 | 75 |
81 } // namespace net | 76 } // namespace net |
82 | 77 |
83 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ | 78 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ |
OLD | NEW |