| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // |stream_factory|, which must outlive this session. | 91 // |stream_factory|, which must outlive this session. |
| 92 // TODO(rch): decouple the factory from the session via a Delegate interface. | 92 // TODO(rch): decouple the factory from the session via a Delegate interface. |
| 93 QuicClientSession(QuicConnection* connection, | 93 QuicClientSession(QuicConnection* connection, |
| 94 scoped_ptr<DatagramClientSocket> socket, | 94 scoped_ptr<DatagramClientSocket> socket, |
| 95 QuicStreamFactory* stream_factory, | 95 QuicStreamFactory* stream_factory, |
| 96 TransportSecurityState* transport_security_state, | 96 TransportSecurityState* transport_security_state, |
| 97 scoped_ptr<QuicServerInfo> server_info, | 97 scoped_ptr<QuicServerInfo> server_info, |
| 98 const QuicConfig& config, | 98 const QuicConfig& config, |
| 99 base::TaskRunner* task_runner, | 99 base::TaskRunner* task_runner, |
| 100 NetLog* net_log); | 100 NetLog* net_log); |
| 101 virtual ~QuicClientSession(); | 101 ~QuicClientSession() override; |
| 102 | 102 |
| 103 // Initialize session's connection to |server_id|. | 103 // Initialize session's connection to |server_id|. |
| 104 void InitializeSession( | 104 void InitializeSession( |
| 105 const QuicServerId& server_id, | 105 const QuicServerId& server_id, |
| 106 QuicCryptoClientConfig* config, | 106 QuicCryptoClientConfig* config, |
| 107 QuicCryptoClientStreamFactory* crypto_client_stream_factory); | 107 QuicCryptoClientStreamFactory* crypto_client_stream_factory); |
| 108 | 108 |
| 109 void AddObserver(Observer* observer); | 109 void AddObserver(Observer* observer); |
| 110 void RemoveObserver(Observer* observer); | 110 void RemoveObserver(Observer* observer); |
| 111 | 111 |
| 112 // Attempts to create a new stream. If the stream can be | 112 // Attempts to create a new stream. If the stream can be |
| 113 // created immediately, returns OK. If the open stream limit | 113 // created immediately, returns OK. If the open stream limit |
| 114 // has been reached, returns ERR_IO_PENDING, and |request| | 114 // has been reached, returns ERR_IO_PENDING, and |request| |
| 115 // will be added to the stream requets queue and will | 115 // will be added to the stream requets queue and will |
| 116 // be completed asynchronously. | 116 // be completed asynchronously. |
| 117 // TODO(rch): remove |stream| from this and use setter on |request| | 117 // TODO(rch): remove |stream| from this and use setter on |request| |
| 118 // and fix in spdy too. | 118 // and fix in spdy too. |
| 119 int TryCreateStream(StreamRequest* request, | 119 int TryCreateStream(StreamRequest* request, |
| 120 QuicReliableClientStream** stream); | 120 QuicReliableClientStream** stream); |
| 121 | 121 |
| 122 // Cancels the pending stream creation request. | 122 // Cancels the pending stream creation request. |
| 123 void CancelRequest(StreamRequest* request); | 123 void CancelRequest(StreamRequest* request); |
| 124 | 124 |
| 125 // QuicSession methods: | 125 // QuicSession methods: |
| 126 virtual void OnStreamFrames( | 126 void OnStreamFrames(const std::vector<QuicStreamFrame>& frames) override; |
| 127 const std::vector<QuicStreamFrame>& frames) override; | 127 QuicReliableClientStream* CreateOutgoingDataStream() override; |
| 128 virtual QuicReliableClientStream* CreateOutgoingDataStream() override; | 128 QuicCryptoClientStream* GetCryptoStream() override; |
| 129 virtual QuicCryptoClientStream* GetCryptoStream() override; | 129 void CloseStream(QuicStreamId stream_id) override; |
| 130 virtual void CloseStream(QuicStreamId stream_id) override; | 130 void SendRstStream(QuicStreamId id, |
| 131 virtual void SendRstStream(QuicStreamId id, | 131 QuicRstStreamErrorCode error, |
| 132 QuicRstStreamErrorCode error, | 132 QuicStreamOffset bytes_written) override; |
| 133 QuicStreamOffset bytes_written) override; | 133 void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override; |
| 134 virtual void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override; | 134 void OnCryptoHandshakeMessageSent( |
| 135 virtual void OnCryptoHandshakeMessageSent( | |
| 136 const CryptoHandshakeMessage& message) override; | 135 const CryptoHandshakeMessage& message) override; |
| 137 virtual void OnCryptoHandshakeMessageReceived( | 136 void OnCryptoHandshakeMessageReceived( |
| 138 const CryptoHandshakeMessage& message) override; | 137 const CryptoHandshakeMessage& message) override; |
| 139 virtual bool GetSSLInfo(SSLInfo* ssl_info) const override; | 138 bool GetSSLInfo(SSLInfo* ssl_info) const override; |
| 140 | 139 |
| 141 // QuicClientSessionBase methods: | 140 // QuicClientSessionBase methods: |
| 142 virtual void OnProofValid( | 141 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; |
| 143 const QuicCryptoClientConfig::CachedState& cached) override; | 142 void OnProofVerifyDetailsAvailable( |
| 144 virtual void OnProofVerifyDetailsAvailable( | |
| 145 const ProofVerifyDetails& verify_details) override; | 143 const ProofVerifyDetails& verify_details) override; |
| 146 | 144 |
| 147 // QuicConnectionVisitorInterface methods: | 145 // QuicConnectionVisitorInterface methods: |
| 148 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) override; | 146 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override; |
| 149 virtual void OnSuccessfulVersionNegotiation( | 147 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; |
| 150 const QuicVersion& version) override; | |
| 151 | 148 |
| 152 // Performs a crypto handshake with the server. | 149 // Performs a crypto handshake with the server. |
| 153 int CryptoConnect(bool require_confirmation, | 150 int CryptoConnect(bool require_confirmation, |
| 154 const CompletionCallback& callback); | 151 const CompletionCallback& callback); |
| 155 | 152 |
| 156 // Resumes a crypto handshake with the server after a timeout. | 153 // Resumes a crypto handshake with the server after a timeout. |
| 157 int ResumeCryptoConnect(const CompletionCallback& callback); | 154 int ResumeCryptoConnect(const CompletionCallback& callback); |
| 158 | 155 |
| 159 // Causes the QuicConnectionHelper to start reading from the socket | 156 // Causes the QuicConnectionHelper to start reading from the socket |
| 160 // and passing the data along to the QuicConnection. | 157 // and passing the data along to the QuicConnection. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 175 // than the number of round-trips needed for the handshake. | 172 // than the number of round-trips needed for the handshake. |
| 176 int GetNumSentClientHellos() const; | 173 int GetNumSentClientHellos() const; |
| 177 | 174 |
| 178 // Returns true if |hostname| may be pooled onto this session. If this | 175 // Returns true if |hostname| may be pooled onto this session. If this |
| 179 // is a secure QUIC session, then |hostname| must match the certificate | 176 // is a secure QUIC session, then |hostname| must match the certificate |
| 180 // presented during the handshake. | 177 // presented during the handshake. |
| 181 bool CanPool(const std::string& hostname) const; | 178 bool CanPool(const std::string& hostname) const; |
| 182 | 179 |
| 183 protected: | 180 protected: |
| 184 // QuicSession methods: | 181 // QuicSession methods: |
| 185 virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) override; | 182 QuicDataStream* CreateIncomingDataStream(QuicStreamId id) override; |
| 186 | 183 |
| 187 private: | 184 private: |
| 188 friend class test::QuicClientSessionPeer; | 185 friend class test::QuicClientSessionPeer; |
| 189 | 186 |
| 190 typedef std::set<Observer*> ObserverSet; | 187 typedef std::set<Observer*> ObserverSet; |
| 191 typedef std::list<StreamRequest*> StreamRequestQueue; | 188 typedef std::list<StreamRequest*> StreamRequestQueue; |
| 192 | 189 |
| 193 QuicReliableClientStream* CreateOutgoingReliableStreamImpl(); | 190 QuicReliableClientStream* CreateOutgoingReliableStreamImpl(); |
| 194 // A completion callback invoked when a read completes. | 191 // A completion callback invoked when a read completes. |
| 195 void OnReadComplete(int result); | 192 void OnReadComplete(int result); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // on this session. Existing stream will continue to be processed. | 244 // on this session. Existing stream will continue to be processed. |
| 248 bool going_away_; | 245 bool going_away_; |
| 249 base::WeakPtrFactory<QuicClientSession> weak_factory_; | 246 base::WeakPtrFactory<QuicClientSession> weak_factory_; |
| 250 | 247 |
| 251 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); | 248 DISALLOW_COPY_AND_ASSIGN(QuicClientSession); |
| 252 }; | 249 }; |
| 253 | 250 |
| 254 } // namespace net | 251 } // namespace net |
| 255 | 252 |
| 256 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ | 253 #endif // NET_QUIC_QUIC_CLIENT_SESSION_H_ |
| OLD | NEW |