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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 namespace test { | 52 namespace test { |
53 class QuicChromiumClientSessionPeer; | 53 class QuicChromiumClientSessionPeer; |
54 } // namespace test | 54 } // namespace test |
55 | 55 |
56 class NET_EXPORT_PRIVATE QuicChromiumClientSession | 56 class NET_EXPORT_PRIVATE QuicChromiumClientSession |
57 : public QuicClientSessionBase, | 57 : public QuicClientSessionBase, |
58 public QuicChromiumPacketReader::Visitor, | 58 public QuicChromiumPacketReader::Visitor, |
59 public QuicChromiumPacketWriter::WriteErrorObserver { | 59 public QuicChromiumPacketWriter::WriteErrorObserver { |
60 public: | 60 public: |
| 61 // Reasons to disable QUIC, that is under certain pathological |
| 62 // connection errors. Note: these values must be kept in sync with |
| 63 // the corresponding values of QuicDisabledReason in: |
| 64 // tools/metrics/histograms/histograms.xml |
| 65 enum QuicDisabledReason { |
| 66 QUIC_DISABLED_NOT = 0, // default, not disabled |
| 67 QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE = 1, |
| 68 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS = 2, |
| 69 QUIC_DISABLED_BAD_PACKET_LOSS_RATE = 3, |
| 70 QUIC_DISABLED_MAX = 4, |
| 71 }; |
| 72 |
61 // An interface for observing events on a session. | 73 // An interface for observing events on a session. |
62 class NET_EXPORT_PRIVATE Observer { | 74 class NET_EXPORT_PRIVATE Observer { |
63 public: | 75 public: |
64 virtual ~Observer() {} | 76 virtual ~Observer() {} |
65 virtual void OnCryptoHandshakeConfirmed() = 0; | 77 virtual void OnCryptoHandshakeConfirmed() = 0; |
66 virtual void OnSessionClosed(int error, bool port_migration_detected) = 0; | 78 virtual void OnSessionClosed(int error, bool port_migration_detected) = 0; |
67 }; | 79 }; |
68 | 80 |
69 // A helper class used to manage a request to create a stream. | 81 // A helper class used to manage a request to create a stream. |
70 class NET_EXPORT_PRIVATE StreamRequest { | 82 class NET_EXPORT_PRIVATE StreamRequest { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // than the number of round-trips needed for the handshake. | 242 // than the number of round-trips needed for the handshake. |
231 int GetNumSentClientHellos() const; | 243 int GetNumSentClientHellos() const; |
232 | 244 |
233 // Returns true if |hostname| may be pooled onto this session. If this | 245 // Returns true if |hostname| may be pooled onto this session. If this |
234 // is a secure QUIC session, then |hostname| must match the certificate | 246 // is a secure QUIC session, then |hostname| must match the certificate |
235 // presented during the handshake. | 247 // presented during the handshake. |
236 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; | 248 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; |
237 | 249 |
238 const QuicServerId& server_id() const { return server_id_; } | 250 const QuicServerId& server_id() const { return server_id_; } |
239 | 251 |
| 252 QuicDisabledReason disabled_reason() const { return disabled_reason_; } |
| 253 |
240 // Migrates session onto new socket, i.e., starts reading from | 254 // Migrates session onto new socket, i.e., starts reading from |
241 // |socket| in addition to any previous sockets, and sets |writer| | 255 // |socket| in addition to any previous sockets, and sets |writer| |
242 // to be the new default writer. Returns true if socket was | 256 // to be the new default writer. Returns true if socket was |
243 // successfully added to the session and the session was | 257 // successfully added to the session and the session was |
244 // successfully migrated to using the new socket. If not null, | 258 // successfully migrated to using the new socket. If not null, |
245 // |packet| is sent on the new network, else a PING frame is | 259 // |packet| is sent on the new network, else a PING frame is |
246 // sent. Returns true on successful migration, or false if number of | 260 // sent. Returns true on successful migration, or false if number of |
247 // migrations exceeds kMaxReadersPerQuicSession. Takes ownership of | 261 // migrations exceeds kMaxReadersPerQuicSession. Takes ownership of |
248 // |socket|, |reader|, and |writer|. | 262 // |socket|, |reader|, and |writer|. |
249 bool MigrateToSocket(std::unique_ptr<DatagramClientSocket> socket, | 263 bool MigrateToSocket(std::unique_ptr<DatagramClientSocket> socket, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 BoundNetLog net_log_; | 351 BoundNetLog net_log_; |
338 std::vector<std::unique_ptr<QuicChromiumPacketReader>> packet_readers_; | 352 std::vector<std::unique_ptr<QuicChromiumPacketReader>> packet_readers_; |
339 base::TimeTicks dns_resolution_end_time_; | 353 base::TimeTicks dns_resolution_end_time_; |
340 base::TimeTicks handshake_start_; // Time the handshake was started. | 354 base::TimeTicks handshake_start_; // Time the handshake was started. |
341 std::unique_ptr<QuicConnectionLogger> logger_; | 355 std::unique_ptr<QuicConnectionLogger> logger_; |
342 // True when the session is going away, and streams may no longer be created | 356 // True when the session is going away, and streams may no longer be created |
343 // on this session. Existing stream will continue to be processed. | 357 // on this session. Existing stream will continue to be processed. |
344 bool going_away_; | 358 bool going_away_; |
345 // True when the session receives a go away from server due to port migration. | 359 // True when the session receives a go away from server due to port migration. |
346 bool port_migration_detected_; | 360 bool port_migration_detected_; |
| 361 QuicDisabledReason disabled_reason_; |
347 TokenBindingSignatureMap token_binding_signatures_; | 362 TokenBindingSignatureMap token_binding_signatures_; |
348 // UMA histogram counters for streams pushed to this session. | 363 // UMA histogram counters for streams pushed to this session. |
349 int streams_pushed_count_; | 364 int streams_pushed_count_; |
350 int streams_pushed_and_claimed_count_; | 365 int streams_pushed_and_claimed_count_; |
351 // Return value from packet rewrite packet on new socket. Used | 366 // Return value from packet rewrite packet on new socket. Used |
352 // during connection migration on socket write error. | 367 // during connection migration on socket write error. |
353 int error_code_from_rewrite_; | 368 int error_code_from_rewrite_; |
354 bool use_error_code_from_rewrite_; | 369 bool use_error_code_from_rewrite_; |
355 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; | 370 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; |
356 | 371 |
357 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); | 372 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); |
358 }; | 373 }; |
359 | 374 |
360 } // namespace net | 375 } // namespace net |
361 | 376 |
362 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 377 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
OLD | NEW |