ConnectionTimingInfo.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. JS_DECLARE_ALLOCATOR(ConnectionTimingInfo);
  16. public:
  17. [[nodiscard]] static JS::NonnullGCPtr<ConnectionTimingInfo> create(JS::VM&);
  18. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp domain_lookup_start_time() const { return m_domain_lookup_start_time; }
  19. void set_domain_lookup_start_time(HighResolutionTime::DOMHighResTimeStamp domain_lookup_start_time) { m_domain_lookup_start_time = domain_lookup_start_time; }
  20. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp domain_lookup_end_time() const { return m_domain_lookup_end_time; }
  21. void set_domain_lookup_end_time(HighResolutionTime::DOMHighResTimeStamp domain_lookup_end_time) { m_domain_lookup_end_time = domain_lookup_end_time; }
  22. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp connection_start_time() const { return m_connection_start_time; }
  23. void set_connection_start_time(HighResolutionTime::DOMHighResTimeStamp connection_start_time) { m_connection_start_time = connection_start_time; }
  24. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp connection_end_time() const { return m_connection_end_time; }
  25. void set_connection_end_time(HighResolutionTime::DOMHighResTimeStamp connection_end_time) { m_connection_end_time = connection_end_time; }
  26. [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp secure_connection_start_time() const { return m_secure_connection_start_time; }
  27. void set_secure_connection_start_time(HighResolutionTime::DOMHighResTimeStamp secure_connection_start_time) { m_secure_connection_start_time = secure_connection_start_time; }
  28. [[nodiscard]] ReadonlyBytes lpn_negotiated_protocol() const { return m_lpn_negotiated_protocol; }
  29. void set_lpn_negotiated_protocol(ByteBuffer lpn_negotiated_protocol) { m_lpn_negotiated_protocol = move(lpn_negotiated_protocol); }
  30. private:
  31. ConnectionTimingInfo();
  32. // https://fetch.spec.whatwg.org/#connection-timing-info-domain-lookup-start-time
  33. // domain lookup start time (default 0)
  34. // A DOMHighResTimeStamp.
  35. HighResolutionTime::DOMHighResTimeStamp m_domain_lookup_start_time { 0 };
  36. // https://fetch.spec.whatwg.org/#connection-timing-info-domain-lookup-end-time
  37. // domain lookup end time (default 0)
  38. // A DOMHighResTimeStamp.
  39. HighResolutionTime::DOMHighResTimeStamp m_domain_lookup_end_time { 0 };
  40. // https://fetch.spec.whatwg.org/#connection-timing-info-connection-start-time
  41. // connection start time (default 0)
  42. // A DOMHighResTimeStamp.
  43. HighResolutionTime::DOMHighResTimeStamp m_connection_start_time { 0 };
  44. // https://fetch.spec.whatwg.org/#connection-timing-info-connection-end-time
  45. // connection end time (default 0)
  46. // A DOMHighResTimeStamp.
  47. HighResolutionTime::DOMHighResTimeStamp m_connection_end_time { 0 };
  48. // https://fetch.spec.whatwg.org/#connection-timing-info-secure-connection-start-time
  49. // secure connection start time (default 0)
  50. // A DOMHighResTimeStamp.
  51. HighResolutionTime::DOMHighResTimeStamp m_secure_connection_start_time { 0 };
  52. // https://fetch.spec.whatwg.org/#connection-timing-info-alpn-negotiated-protocol
  53. // ALPN negotiated protocol (default the empty byte sequence)
  54. // A byte sequence.
  55. ByteBuffer m_lpn_negotiated_protocol;
  56. };
  57. }