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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 // Returns true if |hostname| may be pooled onto this session. If this | 247 // Returns true if |hostname| may be pooled onto this session. If this |
248 // is a secure QUIC session, then |hostname| must match the certificate | 248 // is a secure QUIC session, then |hostname| must match the certificate |
249 // presented during the handshake. | 249 // presented during the handshake. |
250 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; | 250 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; |
251 | 251 |
252 const QuicServerId& server_id() const { return server_id_; } | 252 const QuicServerId& server_id() const { return server_id_; } |
253 | 253 |
254 QuicDisabledReason disabled_reason() const { return disabled_reason_; } | 254 QuicDisabledReason disabled_reason() const { return disabled_reason_; } |
255 | 255 |
| 256 // Attempts to migrate session when a write error is encountered. |
| 257 void MigrateSessionOnWriteError(); |
| 258 |
| 259 // Helper method that writes a packet on the new socket after |
| 260 // migration completes. If not null, the packet_ member is written, |
| 261 // otherwise a PING packet is written. |
| 262 void WriteToNewSocket(); |
| 263 |
256 // Migrates session onto new socket, i.e., starts reading from | 264 // Migrates session onto new socket, i.e., starts reading from |
257 // |socket| in addition to any previous sockets, and sets |writer| | 265 // |socket| in addition to any previous sockets, and sets |writer| |
258 // to be the new default writer. Returns true if socket was | 266 // to be the new default writer. Returns true if socket was |
259 // successfully added to the session and the session was | 267 // successfully added to the session and the session was |
260 // successfully migrated to using the new socket. If not null, | 268 // successfully migrated to using the new socket. Returns true on |
261 // |packet| is sent on the new network, else a PING frame is | 269 // successful migration, or false if number of migrations exceeds |
262 // sent. Returns true on successful migration, or false if number of | 270 // kMaxReadersPerQuicSession. Takes ownership of |socket|, |reader|, |
263 // migrations exceeds kMaxReadersPerQuicSession. Takes ownership of | 271 // and |writer|. |
264 // |socket|, |reader|, and |writer|. | |
265 bool MigrateToSocket(std::unique_ptr<DatagramClientSocket> socket, | 272 bool MigrateToSocket(std::unique_ptr<DatagramClientSocket> socket, |
266 std::unique_ptr<QuicChromiumPacketReader> reader, | 273 std::unique_ptr<QuicChromiumPacketReader> reader, |
267 std::unique_ptr<QuicChromiumPacketWriter> writer, | 274 std::unique_ptr<QuicChromiumPacketWriter> writer); |
268 scoped_refptr<StringIOBuffer> packet); | |
269 | 275 |
270 // Populates network error details for this session. | 276 // Populates network error details for this session. |
271 void PopulateNetErrorDetails(NetErrorDetails* details); | 277 void PopulateNetErrorDetails(NetErrorDetails* details); |
272 | 278 |
273 // Returns current default socket. This is the socket over which all | 279 // Returns current default socket. This is the socket over which all |
274 // QUIC packets are sent. This default socket can change, so do not store the | 280 // QUIC packets are sent. This default socket can change, so do not store the |
275 // returned socket. | 281 // returned socket. |
276 const DatagramClientSocket* GetDefaultSocket() const; | 282 const DatagramClientSocket* GetDefaultSocket() const; |
277 | 283 |
278 bool IsAuthorized(const std::string& hostname) override; | 284 bool IsAuthorized(const std::string& hostname) override; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 // True when the session is going away, and streams may no longer be created | 364 // True when the session is going away, and streams may no longer be created |
359 // on this session. Existing stream will continue to be processed. | 365 // on this session. Existing stream will continue to be processed. |
360 bool going_away_; | 366 bool going_away_; |
361 // True when the session receives a go away from server due to port migration. | 367 // True when the session receives a go away from server due to port migration. |
362 bool port_migration_detected_; | 368 bool port_migration_detected_; |
363 QuicDisabledReason disabled_reason_; | 369 QuicDisabledReason disabled_reason_; |
364 TokenBindingSignatureMap token_binding_signatures_; | 370 TokenBindingSignatureMap token_binding_signatures_; |
365 // UMA histogram counters for streams pushed to this session. | 371 // UMA histogram counters for streams pushed to this session. |
366 int streams_pushed_count_; | 372 int streams_pushed_count_; |
367 int streams_pushed_and_claimed_count_; | 373 int streams_pushed_and_claimed_count_; |
368 // Return value from packet rewrite packet on new socket. Used | 374 // Stores packet that witnesses socket write error. This packet is |
369 // during connection migration on socket write error. | 375 // written to a new socket after migration completes. |
370 int error_code_from_rewrite_; | 376 scoped_refptr<StringIOBuffer> packet_; |
371 bool use_error_code_from_rewrite_; | 377 // TODO(jri): Replace use of migration_pending_ sockets_.size(). |
| 378 // When a task is posted for MigrateSessionOnError, pass in |
| 379 // sockets_.size(). Then in MigrateSessionOnError, check to see if |
| 380 // the current sockets_.size() == the passed in value. |
| 381 bool migration_pending_; // True while migration is underway. |
372 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; | 382 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; |
373 | 383 |
374 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); | 384 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); |
375 }; | 385 }; |
376 | 386 |
377 } // namespace net | 387 } // namespace net |
378 | 388 |
379 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 389 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
OLD | NEW |