1 // Copyright 2016 The Chromium Authors 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_SPDY_MULTIPLEXED_SESSION_H_ 6 #define NET_SPDY_MULTIPLEXED_SESSION_H_ 7 8 #include "base/strings/string_piece.h" 9 #include "net/base/ip_endpoint.h" 10 #include "net/base/net_errors.h" 11 #include "net/http/http_stream.h" 12 #include "net/ssl/ssl_info.h" 13 14 namespace url { 15 class SchemeHostPort; 16 } 17 18 namespace net { 19 20 // Base class for SPDY and QUIC sessions. 21 class NET_EXPORT_PRIVATE MultiplexedSession { 22 public: 23 virtual ~MultiplexedSession() = default; 24 25 // Fills SSL info in |ssl_info| and returns true when SSL is in use. 26 virtual bool GetSSLInfo(SSLInfo* ssl_info) const = 0; 27 28 // Gets the remote endpoint of the socket that the HTTP stream is using, if 29 // any. Returns OK and fills in |endpoint| if it is available; returns an 30 // error and does not modify |endpoint| otherwise. 31 virtual int GetRemoteEndpoint(IPEndPoint* endpoint) = 0; 32 33 // The value corresponding to |scheme_host_port| in the ACCEPT_CH frame 34 // received during TLS handshake via the ALPS extension, or the empty string 35 // if the server did not send one. Unlike Accept-CH header fields received in 36 // HTTP responses, this value is available before any requests are made. 37 // 38 // Note that this uses url::SchemeHostPort instead of url::Origin because this 39 // is based around network authorities, as opposed to general RFC 6454 40 // origins. 41 virtual base::StringPiece GetAcceptChViaAlps( 42 const url::SchemeHostPort& scheme_host_port) const = 0; 43 }; 44 45 // A handle to a multiplexed session which will be valid even after the 46 // underlying session is deleted. 47 class NET_EXPORT_PRIVATE MultiplexedSessionHandle { 48 public: 49 explicit MultiplexedSessionHandle(base::WeakPtr<MultiplexedSession> session); 50 virtual ~MultiplexedSessionHandle(); 51 52 // Gets the remote endpoint of the socket that the HTTP stream is using, if 53 // any. Returns OK and fills in |endpoint| if it is available; returns an 54 // error and does not modify |endpoint| otherwise. 55 int GetRemoteEndpoint(IPEndPoint* endpoint); 56 57 // Fills SSL info in |ssl_info| and returns true when SSL is in use. 58 bool GetSSLInfo(SSLInfo* ssl_info) const; 59 60 // Caches SSL info from the underlying session. 61 void SaveSSLInfo(); 62 63 // The value corresponding to |scheme_host_port| in the ACCEPT_CH frame 64 // received during TLS handshake via the ALPS extension, or the empty string 65 // if the server did not send one or if the underlying session is not 66 // available. 67 // 68 // Note that this uses url::SchemeHostPort instead of url::Origin because this 69 // is based around network authorities, as opposed to general RFC 6454 70 // origins. 71 virtual base::StringPiece GetAcceptChViaAlps( 72 const url::SchemeHostPort& scheme_host_port) const; 73 74 private: 75 base::WeakPtr<MultiplexedSession> session_; 76 SSLInfo ssl_info_; 77 bool has_ssl_info_; 78 }; 79 80 } // namespace net 81 82 #endif // NET_SPDY_MULTIPLEXED_SESSION_H_ 83