ConnectionTimingInfo.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. #include <LibJS/Heap/Cell.h>
  9. #include <LibJS/Heap/GCPtr.h>
  10. #include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
  11. namespace Web::Fetch::Infrastructure {
  12. // https://fetch.spec.whatwg.org/#connection-timing-info
  13. class ConnectionTimingInfo : public JS::Cell {
  14. JS_CELL(ConnectionTimingInfo, JS::Cell);
  15. public:
  16. [[nodiscard]] static JS::NonnullGCPtr<ConnectionTimingInfo> create(JS::VM&);
  17. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp domain_lookup_start_time() const { return m_domain_lookup_start_time; }
  18. void set_domain_lookup_start_time(HighResolutionTime::DOMHighResTimeStamp domain_lookup_start_time) { m_domain_lookup_start_time = domain_lookup_start_time; }
  19. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp domain_lookup_end_time() const { return m_domain_lookup_end_time; }
  20. void set_domain_lookup_end_time(HighResolutionTime::DOMHighResTimeStamp domain_lookup_end_time) { m_domain_lookup_end_time = domain_lookup_end_time; }
  21. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp connection_start_time() const { return m_connection_start_time; }
  22. void set_connection_start_time(HighResolutionTime::DOMHighResTimeStamp connection_start_time) { m_connection_start_time = connection_start_time; }
  23. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp connection_end_time() const { return m_connection_end_time; }
  24. void set_connection_end_time(HighResolutionTime::DOMHighResTimeStamp connection_end_time) { m_connection_end_time = connection_end_time; }
  25. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp secure_connection_start_time() const { return m_secure_connection_start_time; }
  26. void set_secure_connection_start_time(HighResolutionTime::DOMHighResTimeStamp secure_connection_start_time) { m_secure_connection_start_time = secure_connection_start_time; }
  27. [[nodiscard]] ReadonlyBytes lpn_negotiated_protocol() const { return m_lpn_negotiated_protocol; }
  28. void set_lpn_negotiated_protocol(ByteBuffer lpn_negotiated_protocol) { m_lpn_negotiated_protocol = move(lpn_negotiated_protocol); }
  29. private:
  30. ConnectionTimingInfo();
  31. // https://fetch.spec.whatwg.org/#connection-timing-info-domain-lookup-start-time
  32. // domain lookup start time (default 0)
  33. // A DOMHighResTimeStamp.
  34. HighResolutionTime::DOMHighResTimeStamp m_domain_lookup_start_time { 0 };
  35. // https://fetch.spec.whatwg.org/#connection-timing-info-domain-lookup-end-time
  36. // domain lookup end time (default 0)
  37. // A DOMHighResTimeStamp.
  38. HighResolutionTime::DOMHighResTimeStamp m_domain_lookup_end_time { 0 };
  39. // https://fetch.spec.whatwg.org/#connection-timing-info-connection-start-time
  40. // connection start time (default 0)
  41. // A DOMHighResTimeStamp.
  42. HighResolutionTime::DOMHighResTimeStamp m_connection_start_time { 0 };
  43. // https://fetch.spec.whatwg.org/#connection-timing-info-connection-end-time
  44. // connection end time (default 0)
  45. // A DOMHighResTimeStamp.
  46. HighResolutionTime::DOMHighResTimeStamp m_connection_end_time { 0 };
  47. // https://fetch.spec.whatwg.org/#connection-timing-info-secure-connection-start-time
  48. // secure connection start time (default 0)
  49. // A DOMHighResTimeStamp.
  50. HighResolutionTime::DOMHighResTimeStamp m_secure_connection_start_time { 0 };
  51. // https://fetch.spec.whatwg.org/#connection-timing-info-alpn-negotiated-protocol
  52. // ALPN negotiated protocol (default the empty byte sequence)
  53. // A byte sequence.
  54. ByteBuffer m_lpn_negotiated_protocol;
  55. };
  56. }