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::Delegate { | 59 public QuicChromiumPacketWriter::Delegate { |
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 | |
73 // An interface for observing events on a session. | 61 // An interface for observing events on a session. |
74 class NET_EXPORT_PRIVATE Observer { | 62 class NET_EXPORT_PRIVATE Observer { |
75 public: | 63 public: |
76 virtual ~Observer() {} | 64 virtual ~Observer() {} |
77 virtual void OnCryptoHandshakeConfirmed() = 0; | 65 virtual void OnCryptoHandshakeConfirmed() = 0; |
78 virtual void OnSessionClosed(int error, bool port_migration_detected) = 0; | 66 virtual void OnSessionClosed(int error, bool port_migration_detected) = 0; |
79 }; | 67 }; |
80 | 68 |
81 // A helper class used to manage a request to create a stream. | 69 // A helper class used to manage a request to create a stream. |
82 class NET_EXPORT_PRIVATE StreamRequest { | 70 class NET_EXPORT_PRIVATE StreamRequest { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // than the number of round-trips needed for the handshake. | 232 // than the number of round-trips needed for the handshake. |
245 int GetNumSentClientHellos() const; | 233 int GetNumSentClientHellos() const; |
246 | 234 |
247 // Returns true if |hostname| may be pooled onto this session. If this | 235 // Returns true if |hostname| may be pooled onto this session. If this |
248 // is a secure QUIC session, then |hostname| must match the certificate | 236 // is a secure QUIC session, then |hostname| must match the certificate |
249 // presented during the handshake. | 237 // presented during the handshake. |
250 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; | 238 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; |
251 | 239 |
252 const QuicServerId& server_id() const { return server_id_; } | 240 const QuicServerId& server_id() const { return server_id_; } |
253 | 241 |
254 QuicDisabledReason disabled_reason() const { return disabled_reason_; } | |
255 | |
256 // Attempts to migrate session when a write error is encountered. | 242 // Attempts to migrate session when a write error is encountered. |
257 void MigrateSessionOnWriteError(); | 243 void MigrateSessionOnWriteError(); |
258 | 244 |
259 // Helper method that writes a packet on the new socket after | 245 // Helper method that writes a packet on the new socket after |
260 // migration completes. If not null, the packet_ member is written, | 246 // migration completes. If not null, the packet_ member is written, |
261 // otherwise a PING packet is written. | 247 // otherwise a PING packet is written. |
262 void WriteToNewSocket(); | 248 void WriteToNewSocket(); |
263 | 249 |
264 // Migrates session onto new socket, i.e., starts reading from | 250 // Migrates session onto new socket, i.e., starts reading from |
265 // |socket| in addition to any previous sockets, and sets |writer| | 251 // |socket| in addition to any previous sockets, and sets |writer| |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 BoundNetLog net_log_; | 358 BoundNetLog net_log_; |
373 std::vector<std::unique_ptr<QuicChromiumPacketReader>> packet_readers_; | 359 std::vector<std::unique_ptr<QuicChromiumPacketReader>> packet_readers_; |
374 base::TimeTicks dns_resolution_end_time_; | 360 base::TimeTicks dns_resolution_end_time_; |
375 base::TimeTicks handshake_start_; // Time the handshake was started. | 361 base::TimeTicks handshake_start_; // Time the handshake was started. |
376 std::unique_ptr<QuicConnectionLogger> logger_; | 362 std::unique_ptr<QuicConnectionLogger> logger_; |
377 // True when the session is going away, and streams may no longer be created | 363 // True when the session is going away, and streams may no longer be created |
378 // on this session. Existing stream will continue to be processed. | 364 // on this session. Existing stream will continue to be processed. |
379 bool going_away_; | 365 bool going_away_; |
380 // True when the session receives a go away from server due to port migration. | 366 // True when the session receives a go away from server due to port migration. |
381 bool port_migration_detected_; | 367 bool port_migration_detected_; |
382 QuicDisabledReason disabled_reason_; | |
383 TokenBindingSignatureMap token_binding_signatures_; | 368 TokenBindingSignatureMap token_binding_signatures_; |
384 // UMA histogram counters for streams pushed to this session. | 369 // UMA histogram counters for streams pushed to this session. |
385 int streams_pushed_count_; | 370 int streams_pushed_count_; |
386 int streams_pushed_and_claimed_count_; | 371 int streams_pushed_and_claimed_count_; |
387 // Stores packet that witnesses socket write error. This packet is | 372 // Stores packet that witnesses socket write error. This packet is |
388 // written to a new socket after migration completes. | 373 // written to a new socket after migration completes. |
389 scoped_refptr<StringIOBuffer> packet_; | 374 scoped_refptr<StringIOBuffer> packet_; |
390 // TODO(jri): Replace use of migration_pending_ sockets_.size(). | 375 // TODO(jri): Replace use of migration_pending_ sockets_.size(). |
391 // When a task is posted for MigrateSessionOnError, pass in | 376 // When a task is posted for MigrateSessionOnError, pass in |
392 // sockets_.size(). Then in MigrateSessionOnError, check to see if | 377 // sockets_.size(). Then in MigrateSessionOnError, check to see if |
393 // the current sockets_.size() == the passed in value. | 378 // the current sockets_.size() == the passed in value. |
394 bool migration_pending_; // True while migration is underway. | 379 bool migration_pending_; // True while migration is underway. |
395 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; | 380 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; |
396 | 381 |
397 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); | 382 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); |
398 }; | 383 }; |
399 | 384 |
400 } // namespace net | 385 } // namespace net |
401 | 386 |
402 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 387 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
OLD | NEW |