Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_QUIC_QUARTC_QUARTC_SESSION_H_ | |
| 6 #define NET_QUIC_QUARTC_QUARTC_SESSION_H_ | |
| 7 | |
| 8 #include "net/quic/core/quic_crypto_client_stream.h" | |
| 9 #include "net/quic/core/quic_crypto_server_stream.h" | |
| 10 #include "net/quic/core/quic_crypto_stream.h" | |
| 11 #include "net/quic/core/quic_session.h" | |
| 12 #include "net/quic/quartc/quartc_session_interface.h" | |
| 13 #include "net/quic/quartc/quartc_stream.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 // A helper class is used by the QuicCryptoServerStream. | |
| 18 class NET_EXPORT_PRIVATE QuartcCryptoServerStreamHelper | |
| 19 : public QuicCryptoServerStream::Helper { | |
| 20 public: | |
| 21 QuicConnectionId GenerateConnectionIdForReject( | |
| 22 QuicConnectionId connection_id) const override; | |
| 23 | |
| 24 bool CanAcceptClientHello(const CryptoHandshakeMessage& message, | |
| 25 const IPEndPoint& self_address, | |
| 26 std::string* error_details) const override; | |
| 27 }; | |
| 28 | |
| 29 class NET_EXPORT_PRIVATE QuartcSession | |
| 30 : public QuicSession, | |
| 31 public QuartcSessionInterface, | |
| 32 public QuicCryptoClientStream::ProofHandler { | |
| 33 public: | |
| 34 QuartcSession(std::unique_ptr<QuicConnection> connection, | |
| 35 const QuicConfig& config, | |
| 36 const std::string& remote_fingerprint_value, | |
|
pthatcher1
2016/10/14 18:59:00
Didn't you rename this to unique_remote_server_id?
zhihuang1
2016/10/16 00:45:28
Ah. sorry for missing this.
| |
| 37 Perspective perspective, | |
| 38 QuicConnectionHelperInterface* helper); | |
| 39 ~QuartcSession() override; | |
| 40 | |
| 41 // QuicSession overrides. | |
| 42 QuicCryptoStream* GetCryptoStream() override; | |
| 43 | |
| 44 QuartcStream* CreateOutgoingDynamicStream(SpdyPriority priority) override; | |
| 45 | |
| 46 void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override; | |
| 47 | |
| 48 void CloseStream(QuicStreamId stream_id) override; | |
| 49 | |
| 50 // QuicConnectionVisitorInterface overrides. | |
| 51 void OnConnectionClosed(QuicErrorCode error, | |
| 52 const std::string& error_details, | |
| 53 ConnectionCloseSource source) override; | |
| 54 | |
| 55 // QuartcSessionInterface overrides | |
| 56 void StartCryptoHandshake() override; | |
| 57 | |
| 58 bool ExportKeyingMaterial(const std::string& label, | |
| 59 const uint8_t* context, | |
| 60 size_t context_len, | |
| 61 bool used_context, | |
| 62 uint8_t* result, | |
| 63 size_t result_len) override; | |
| 64 | |
| 65 QuartcStreamInterface* CreateOutgoingStream( | |
| 66 const OutgoingStreamParameters& param) override; | |
| 67 | |
| 68 void SetDelegate(QuartcSessionInterface::Delegate* session_delegate) override; | |
| 69 | |
| 70 void OnTransportCanWrite() override; | |
| 71 | |
| 72 // Decrypts an incoming QUIC packet to a data stream. | |
| 73 bool OnTransportReceived(const char* data, size_t data_len) override; | |
| 74 | |
| 75 // ProofHandler overrides. | |
| 76 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; | |
| 77 | |
| 78 // Called by the client crypto handshake when proof verification details | |
| 79 // become available, either because proof verification is complete, or when | |
| 80 // cached details are used. | |
| 81 void OnProofVerifyDetailsAvailable( | |
| 82 const ProofVerifyDetails& verify_details) override; | |
| 83 | |
| 84 // Override the default crypto configuration. | |
| 85 // The session will take the ownership of the configurations. | |
| 86 void SetClientCryptoConfig(QuicCryptoClientConfig* client_config); | |
| 87 | |
| 88 void SetServerCryptoConfig(QuicCryptoServerConfig* server_config); | |
| 89 | |
| 90 protected: | |
| 91 // QuicSession override. | |
| 92 ReliableQuicStream* CreateIncomingDynamicStream(QuicStreamId id) override; | |
| 93 | |
| 94 QuartcStream* CreateDataStream(QuicStreamId id, SpdyPriority priority); | |
| 95 | |
| 96 private: | |
| 97 // For crypto handshake. | |
| 98 std::unique_ptr<QuicCryptoStream> crypto_stream_; | |
| 99 // For recording packet receipt time | |
| 100 QuicClock clock_; | |
| 101 const std::string remote_fingerprint_value_; | |
| 102 Perspective perspective_; | |
| 103 // Take the ownership of the QuicConnection. | |
| 104 std::unique_ptr<QuicConnection> connection_; | |
| 105 // Not owned by QuartcSession. From the QuartcFactory. | |
| 106 QuicConnectionHelperInterface* helper_; | |
| 107 // Not owned by QuartcSession. | |
| 108 QuartcSessionInterface::Delegate* session_delegate_ = nullptr; | |
| 109 // Used by QUIC crypto server stream to track most recently compressed certs. | |
| 110 std::unique_ptr<QuicCompressedCertsCache> quic_compressed_certs_cache_; | |
| 111 // This helper is needed when create QuicCryptoServerStream. | |
| 112 QuartcCryptoServerStreamHelper stream_helper_; | |
| 113 // Config for QUIC crypto client stream, used by the client. | |
| 114 std::unique_ptr<QuicCryptoClientConfig> quic_crypto_client_config_; | |
| 115 // Config for QUIC crypto server stream, used by the server. | |
| 116 std::unique_ptr<QuicCryptoServerConfig> quic_crypto_server_config_; | |
| 117 | |
| 118 DISALLOW_COPY_AND_ASSIGN(QuartcSession); | |
| 119 }; | |
| 120 | |
| 121 } // namespace net | |
| 122 | |
| 123 #endif // NET_QUIC_QUARTC_QUARTC_SESSION_H_ | |
| OLD | NEW |