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_CHROMIUM_CLIENT_SESSION_H_ | 10 #ifndef NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // QuicClientSessionBase methods: | 167 // QuicClientSessionBase methods: |
168 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; | 168 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; |
169 void OnProofVerifyDetailsAvailable( | 169 void OnProofVerifyDetailsAvailable( |
170 const ProofVerifyDetails& verify_details) override; | 170 const ProofVerifyDetails& verify_details) override; |
171 | 171 |
172 // QuicConnectionVisitorInterface methods: | 172 // QuicConnectionVisitorInterface methods: |
173 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override; | 173 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override; |
174 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; | 174 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; |
175 | 175 |
176 // QuicPacketReader::Visitor methods: | 176 // QuicPacketReader::Visitor methods: |
177 void OnReadError(int result) override; | 177 void OnReadError(int result, const DatagramClientSocket* socket) override; |
178 bool OnPacket(const QuicEncryptedPacket& packet, | 178 bool OnPacket(const QuicEncryptedPacket& packet, |
179 IPEndPoint local_address, | 179 IPEndPoint local_address, |
180 IPEndPoint peer_address) override; | 180 IPEndPoint peer_address) override; |
181 | 181 |
182 // Gets the SSL connection information. | 182 // Gets the SSL connection information. |
183 bool GetSSLInfo(SSLInfo* ssl_info) const; | 183 bool GetSSLInfo(SSLInfo* ssl_info) const; |
184 | 184 |
185 // Performs a crypto handshake with the server. | 185 // Performs a crypto handshake with the server. |
186 int CryptoConnect(bool require_confirmation, | 186 int CryptoConnect(bool require_confirmation, |
187 const CompletionCallback& callback); | 187 const CompletionCallback& callback); |
188 | 188 |
189 // Resumes a crypto handshake with the server after a timeout. | 189 // Resumes a crypto handshake with the server after a timeout. |
190 int ResumeCryptoConnect(const CompletionCallback& callback); | 190 int ResumeCryptoConnect(const CompletionCallback& callback); |
191 | 191 |
192 // Causes the QuicConnectionHelper to start reading from the socket | 192 // Causes the QuicConnectionHelper to start reading from all sockets |
193 // and passing the data along to the QuicConnection. | 193 // and passing the data along to the QuicConnection. |
194 void StartReading(); | 194 void StartReading(); |
195 | 195 |
196 // Close the session because of |error| and notifies the factory | 196 // Close the session because of |error| and notifies the factory |
197 // that this session has been closed, which will delete the session. | 197 // that this session has been closed, which will delete the session. |
198 void CloseSessionOnError(int error, QuicErrorCode quic_error); | 198 void CloseSessionOnError(int error, QuicErrorCode quic_error); |
199 | 199 |
200 // Close the session because of |error| and notifies the factory later that | 200 // Close the session because of |error| and notifies the factory later that |
201 // this session has been closed, which will delete the session. | 201 // this session has been closed, which will delete the session. |
202 void CloseSessionOnErrorAndNotifyFactoryLater(int error, | 202 void CloseSessionOnErrorAndNotifyFactoryLater(int error, |
(...skipping 12 matching lines...) Expand all Loading... |
215 | 215 |
216 // Returns true if |hostname| may be pooled onto this session. If this | 216 // Returns true if |hostname| may be pooled onto this session. If this |
217 // is a secure QUIC session, then |hostname| must match the certificate | 217 // is a secure QUIC session, then |hostname| must match the certificate |
218 // presented during the handshake. | 218 // presented during the handshake. |
219 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; | 219 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; |
220 | 220 |
221 const QuicServerId& server_id() const { return server_id_; } | 221 const QuicServerId& server_id() const { return server_id_; } |
222 | 222 |
223 QuicDisabledReason disabled_reason() const { return disabled_reason_; } | 223 QuicDisabledReason disabled_reason() const { return disabled_reason_; } |
224 | 224 |
| 225 // Migrates session onto new socket, i.e., starts reading from |socket| |
| 226 // in addition to any previous sockets, and sets |writer| to be the new |
| 227 // default writer. Returns true if socket was successfully added to the |
| 228 // session and the session was successfully migrated to using the new socket. |
| 229 // Returns false if number of migrations exceeds kMaxReadersPerQuicSession. |
| 230 // Takes ownership of |socket|, |reader|, and |writer|. |
| 231 bool MigrateToSocket(scoped_ptr<DatagramClientSocket> socket, |
| 232 scoped_ptr<QuicPacketReader> reader, |
| 233 scoped_ptr<QuicPacketWriter> writer); |
| 234 |
| 235 // Returns current default socket. This is the socket over which all |
| 236 // QUIC packets are sent. This default socket can change, so do not store the |
| 237 // returned socket. |
| 238 const DatagramClientSocket* GetDefaultSocket() const; |
| 239 |
225 protected: | 240 protected: |
226 // QuicSession methods: | 241 // QuicSession methods: |
227 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override; | 242 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override; |
228 | 243 |
229 private: | 244 private: |
230 friend class test::QuicChromiumClientSessionPeer; | 245 friend class test::QuicChromiumClientSessionPeer; |
231 | 246 |
232 typedef std::set<Observer*> ObserverSet; | 247 typedef std::set<Observer*> ObserverSet; |
233 typedef std::list<StreamRequest*> StreamRequestQueue; | 248 typedef std::list<StreamRequest*> StreamRequestQueue; |
234 | 249 |
(...skipping 29 matching lines...) Expand all Loading... |
264 // Notifies the factory that this session has been closed which will | 279 // Notifies the factory that this session has been closed which will |
265 // delete |this|. | 280 // delete |this|. |
266 void NotifyFactoryOfSessionClosed(); | 281 void NotifyFactoryOfSessionClosed(); |
267 | 282 |
268 void OnConnectTimeout(); | 283 void OnConnectTimeout(); |
269 | 284 |
270 QuicServerId server_id_; | 285 QuicServerId server_id_; |
271 bool require_confirmation_; | 286 bool require_confirmation_; |
272 scoped_ptr<QuicCryptoClientStream> crypto_stream_; | 287 scoped_ptr<QuicCryptoClientStream> crypto_stream_; |
273 QuicStreamFactory* stream_factory_; | 288 QuicStreamFactory* stream_factory_; |
274 scoped_ptr<DatagramClientSocket> socket_; | 289 std::vector<scoped_ptr<DatagramClientSocket>> sockets_; |
275 TransportSecurityState* transport_security_state_; | 290 TransportSecurityState* transport_security_state_; |
276 scoped_ptr<QuicServerInfo> server_info_; | 291 scoped_ptr<QuicServerInfo> server_info_; |
277 scoped_ptr<CertVerifyResult> cert_verify_result_; | 292 scoped_ptr<CertVerifyResult> cert_verify_result_; |
278 scoped_ptr<ct::CTVerifyResult> ct_verify_result_; | 293 scoped_ptr<ct::CTVerifyResult> ct_verify_result_; |
279 std::string pinning_failure_log_; | 294 std::string pinning_failure_log_; |
280 ObserverSet observers_; | 295 ObserverSet observers_; |
281 StreamRequestQueue stream_requests_; | 296 StreamRequestQueue stream_requests_; |
282 CompletionCallback callback_; | 297 CompletionCallback callback_; |
283 size_t num_total_streams_; | 298 size_t num_total_streams_; |
284 base::TaskRunner* task_runner_; | 299 base::TaskRunner* task_runner_; |
285 BoundNetLog net_log_; | 300 BoundNetLog net_log_; |
286 QuicPacketReader packet_reader_; | 301 std::vector<scoped_ptr<QuicPacketReader>> packet_readers_; |
287 base::TimeTicks dns_resolution_end_time_; | 302 base::TimeTicks dns_resolution_end_time_; |
288 base::TimeTicks handshake_start_; // Time the handshake was started. | 303 base::TimeTicks handshake_start_; // Time the handshake was started. |
289 scoped_ptr<QuicConnectionLogger> logger_; | 304 scoped_ptr<QuicConnectionLogger> logger_; |
290 // True when the session is going away, and streams may no longer be created | 305 // True when the session is going away, and streams may no longer be created |
291 // on this session. Existing stream will continue to be processed. | 306 // on this session. Existing stream will continue to be processed. |
292 bool going_away_; | 307 bool going_away_; |
293 QuicDisabledReason disabled_reason_; | 308 QuicDisabledReason disabled_reason_; |
294 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; | 309 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; |
295 | 310 |
296 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); | 311 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); |
297 }; | 312 }; |
298 | 313 |
299 } // namespace net | 314 } // namespace net |
300 | 315 |
301 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 316 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
OLD | NEW |