multiplexed_session.h 3.0 KB

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