| 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); |
| 35 | 36 |
| 36 virtual ~QuicClientSession(); | 37 virtual ~QuicClientSession(); |
| 37 | 38 |
| 38 // QuicSession methods: | 39 // QuicSession methods: |
| 39 virtual QuicReliableClientStream* CreateOutgoingReliableStream() OVERRIDE; | 40 virtual QuicReliableClientStream* CreateOutgoingReliableStream() OVERRIDE; |
| 40 virtual QuicCryptoClientStream* GetCryptoStream() OVERRIDE; | 41 virtual QuicCryptoClientStream* GetCryptoStream() OVERRIDE; |
| 41 virtual void CloseStream(QuicStreamId stream_id) OVERRIDE; | 42 virtual void CloseStream(QuicStreamId stream_id) OVERRIDE; |
| 42 virtual void OnCryptoHandshakeComplete(QuicErrorCode error) OVERRIDE; | 43 virtual void OnCryptoHandshakeComplete(QuicErrorCode error) OVERRIDE; |
| 43 | 44 |
| 44 // Performs a crypto handshake with the server. | 45 // Performs a crypto handshake with the server. |
| 45 int CryptoConnect(const CompletionCallback& callback); | 46 int CryptoConnect(const CompletionCallback& callback); |
| 46 | 47 |
| 47 // Causes the QuicConnectionHelper to start reading from the socket | 48 // Causes the QuicConnectionHelper to start reading from the socket |
| 48 // and passing the data along to the QuicConnection. | 49 // and passing the data along to the QuicConnection. |
| 49 void StartReading(); | 50 void StartReading(); |
| 50 | 51 |
| 51 // Close the session because of |error|. | 52 // Close the session because of |error|. |
| 52 void CloseSessionOnError(int error); | 53 void CloseSessionOnError(int error); |
| 53 | 54 |
| 54 base::Value* GetInfoAsValue(const HostPortPair& pair) const; | 55 base::Value* GetInfoAsValue(const HostPortPair& pair) const; |
| 55 | 56 |
| 57 const BoundNetLog& net_log() const { return net_log_; } |
| 58 |
| 56 protected: | 59 protected: |
| 57 // QuicSession methods: | 60 // QuicSession methods: |
| 58 virtual ReliableQuicStream* CreateIncomingReliableStream( | 61 virtual ReliableQuicStream* CreateIncomingReliableStream( |
| 59 QuicStreamId id) OVERRIDE; | 62 QuicStreamId id) OVERRIDE; |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 // A completion callback invoked when a read completes. | 65 // A completion callback invoked when a read completes. |
| 63 void OnReadComplete(int result); | 66 void OnReadComplete(int result); |
| 64 | 67 |
| 65 base::WeakPtrFactory<QuicClientSession> weak_factory_; | 68 base::WeakPtrFactory<QuicClientSession> weak_factory_; |
| 66 QuicCryptoClientStream crypto_stream_; | 69 QuicCryptoClientStream crypto_stream_; |
| 67 scoped_ptr<QuicConnectionHelper> helper_; | 70 scoped_ptr<QuicConnectionHelper> helper_; |
| 68 QuicStreamFactory* stream_factory_; | 71 QuicStreamFactory* stream_factory_; |
| 69 scoped_refptr<IOBufferWithSize> read_buffer_; | 72 scoped_refptr<IOBufferWithSize> read_buffer_; |
| 70 bool read_pending_; | 73 bool read_pending_; |
| 71 CompletionCallback callback_; | 74 CompletionCallback callback_; |
| 75 size_t num_total_streams_; |
| 76 BoundNetLog net_log_; |
| 72 | 77 |
| 73 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); | 78 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); |
| 74 }; | 79 }; |
| 75 | 80 |
| 76 } // namespace net | 81 } // namespace net |
| 77 | 82 |
| 78 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ | 83 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ |
| OLD | NEW |