| 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_ |
| 11 #define NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 11 #define NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
| 12 | 12 |
| 13 #include <stddef.h> | 13 #include <stddef.h> |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/containers/hash_tables.h" | 17 #include "base/containers/hash_tables.h" |
| 18 #include "base/containers/mru_cache.h" | 18 #include "base/containers/mru_cache.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "net/base/completion_callback.h" | 22 #include "net/base/completion_callback.h" |
| 23 #include "net/base/net_error_details.h" |
| 23 #include "net/base/socket_performance_watcher.h" | 24 #include "net/base/socket_performance_watcher.h" |
| 24 #include "net/cert/ct_verify_result.h" | 25 #include "net/cert/ct_verify_result.h" |
| 25 #include "net/proxy/proxy_server.h" | 26 #include "net/proxy/proxy_server.h" |
| 26 #include "net/quic/quic_chromium_client_stream.h" | 27 #include "net/quic/quic_chromium_client_stream.h" |
| 27 #include "net/quic/quic_chromium_packet_reader.h" | 28 #include "net/quic/quic_chromium_packet_reader.h" |
| 28 #include "net/quic/quic_client_session_base.h" | 29 #include "net/quic/quic_client_session_base.h" |
| 29 #include "net/quic/quic_connection_logger.h" | 30 #include "net/quic/quic_connection_logger.h" |
| 30 #include "net/quic/quic_crypto_client_stream.h" | 31 #include "net/quic/quic_crypto_client_stream.h" |
| 31 #include "net/quic/quic_protocol.h" | 32 #include "net/quic/quic_protocol.h" |
| 32 #include "net/quic/quic_time.h" | 33 #include "net/quic/quic_time.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS = 2, | 65 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS = 2, |
| 65 QUIC_DISABLED_BAD_PACKET_LOSS_RATE = 3, | 66 QUIC_DISABLED_BAD_PACKET_LOSS_RATE = 3, |
| 66 QUIC_DISABLED_MAX = 4, | 67 QUIC_DISABLED_MAX = 4, |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 // An interface for observing events on a session. | 70 // An interface for observing events on a session. |
| 70 class NET_EXPORT_PRIVATE Observer { | 71 class NET_EXPORT_PRIVATE Observer { |
| 71 public: | 72 public: |
| 72 virtual ~Observer() {} | 73 virtual ~Observer() {} |
| 73 virtual void OnCryptoHandshakeConfirmed() = 0; | 74 virtual void OnCryptoHandshakeConfirmed() = 0; |
| 74 virtual void OnSessionClosed(int error) = 0; | 75 virtual void OnSessionClosed(int error, bool port_migration_detected) = 0; |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 // A helper class used to manage a request to create a stream. | 78 // A helper class used to manage a request to create a stream. |
| 78 class NET_EXPORT_PRIVATE StreamRequest { | 79 class NET_EXPORT_PRIVATE StreamRequest { |
| 79 public: | 80 public: |
| 80 StreamRequest(); | 81 StreamRequest(); |
| 81 ~StreamRequest(); | 82 ~StreamRequest(); |
| 82 | 83 |
| 83 // Starts a request to create a stream. If OK is returned, then | 84 // Starts a request to create a stream. If OK is returned, then |
| 84 // |stream| will be updated with the newly created stream. If | 85 // |stream| will be updated with the newly created stream. If |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Migrates session onto new socket, i.e., starts reading from |socket| | 242 // Migrates session onto new socket, i.e., starts reading from |socket| |
| 242 // in addition to any previous sockets, and sets |writer| to be the new | 243 // in addition to any previous sockets, and sets |writer| to be the new |
| 243 // default writer. Returns true if socket was successfully added to the | 244 // default writer. Returns true if socket was successfully added to the |
| 244 // session and the session was successfully migrated to using the new socket. | 245 // session and the session was successfully migrated to using the new socket. |
| 245 // Returns false if number of migrations exceeds kMaxReadersPerQuicSession. | 246 // Returns false if number of migrations exceeds kMaxReadersPerQuicSession. |
| 246 // Takes ownership of |socket|, |reader|, and |writer|. | 247 // Takes ownership of |socket|, |reader|, and |writer|. |
| 247 bool MigrateToSocket(scoped_ptr<DatagramClientSocket> socket, | 248 bool MigrateToSocket(scoped_ptr<DatagramClientSocket> socket, |
| 248 scoped_ptr<QuicChromiumPacketReader> reader, | 249 scoped_ptr<QuicChromiumPacketReader> reader, |
| 249 scoped_ptr<QuicPacketWriter> writer); | 250 scoped_ptr<QuicPacketWriter> writer); |
| 250 | 251 |
| 252 // Populates network error details for this session. |
| 253 void PopulateNetErrorDetails(NetErrorDetails* details); |
| 254 |
| 251 // Returns current default socket. This is the socket over which all | 255 // Returns current default socket. This is the socket over which all |
| 252 // QUIC packets are sent. This default socket can change, so do not store the | 256 // QUIC packets are sent. This default socket can change, so do not store the |
| 253 // returned socket. | 257 // returned socket. |
| 254 const DatagramClientSocket* GetDefaultSocket() const; | 258 const DatagramClientSocket* GetDefaultSocket() const; |
| 255 | 259 |
| 256 bool IsAuthorized(const std::string& hostname) override; | 260 bool IsAuthorized(const std::string& hostname) override; |
| 257 | 261 |
| 258 // Returns true if session has one ore more streams marked as non-migratable. | 262 // Returns true if session has one ore more streams marked as non-migratable. |
| 259 bool HasNonMigratableStreams() const; | 263 bool HasNonMigratableStreams() const; |
| 260 | 264 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 size_t num_total_streams_; | 325 size_t num_total_streams_; |
| 322 base::TaskRunner* task_runner_; | 326 base::TaskRunner* task_runner_; |
| 323 BoundNetLog net_log_; | 327 BoundNetLog net_log_; |
| 324 std::vector<scoped_ptr<QuicChromiumPacketReader>> packet_readers_; | 328 std::vector<scoped_ptr<QuicChromiumPacketReader>> packet_readers_; |
| 325 base::TimeTicks dns_resolution_end_time_; | 329 base::TimeTicks dns_resolution_end_time_; |
| 326 base::TimeTicks handshake_start_; // Time the handshake was started. | 330 base::TimeTicks handshake_start_; // Time the handshake was started. |
| 327 scoped_ptr<QuicConnectionLogger> logger_; | 331 scoped_ptr<QuicConnectionLogger> logger_; |
| 328 // True when the session is going away, and streams may no longer be created | 332 // True when the session is going away, and streams may no longer be created |
| 329 // on this session. Existing stream will continue to be processed. | 333 // on this session. Existing stream will continue to be processed. |
| 330 bool going_away_; | 334 bool going_away_; |
| 335 // True when the session receives a go away from server due to port migration. |
| 336 bool port_migration_detected_; |
| 331 QuicDisabledReason disabled_reason_; | 337 QuicDisabledReason disabled_reason_; |
| 332 TokenBindingSignatureMap token_binding_signatures_; | 338 TokenBindingSignatureMap token_binding_signatures_; |
| 333 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; | 339 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; |
| 334 | 340 |
| 335 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); | 341 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); |
| 336 }; | 342 }; |
| 337 | 343 |
| 338 } // namespace net | 344 } // namespace net |
| 339 | 345 |
| 340 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 346 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
| OLD | NEW |