/src/serenity/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchTimingInfo.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/String.h> |
10 | | #include <AK/Vector.h> |
11 | | #include <LibJS/Forward.h> |
12 | | #include <LibJS/Heap/Cell.h> |
13 | | #include <LibJS/Heap/GCPtr.h> |
14 | | #include <LibWeb/Fetch/Infrastructure/ConnectionTimingInfo.h> |
15 | | #include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h> |
16 | | |
17 | | namespace Web::Fetch::Infrastructure { |
18 | | |
19 | | // https://fetch.spec.whatwg.org/#fetch-timing-info |
20 | | class FetchTimingInfo : public JS::Cell { |
21 | | JS_CELL(FetchTimingInfo, JS::Cell); |
22 | | JS_DECLARE_ALLOCATOR(FetchTimingInfo); |
23 | | |
24 | | public: |
25 | | [[nodiscard]] static JS::NonnullGCPtr<FetchTimingInfo> create(JS::VM&); |
26 | | |
27 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp start_time() const { return m_start_time; } |
28 | 0 | void set_start_time(HighResolutionTime::DOMHighResTimeStamp start_time) { m_start_time = start_time; } |
29 | | |
30 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp redirect_start_time() const { return m_redirect_start_time; } |
31 | 0 | void set_redirect_start_time(HighResolutionTime::DOMHighResTimeStamp redirect_start_time) { m_redirect_start_time = redirect_start_time; } |
32 | | |
33 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp redirect_end_time() const { return m_redirect_end_time; } |
34 | 0 | void set_redirect_end_time(HighResolutionTime::DOMHighResTimeStamp redirect_end_time) { m_redirect_end_time = redirect_end_time; } |
35 | | |
36 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp post_redirect_start_time() const { return m_post_redirect_start_time; } |
37 | 0 | void set_post_redirect_start_time(HighResolutionTime::DOMHighResTimeStamp post_redirect_start_time) { m_post_redirect_start_time = post_redirect_start_time; } |
38 | | |
39 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp final_service_worker_start_time() const { return m_final_service_worker_start_time; } |
40 | 0 | void set_final_service_worker_start_time(HighResolutionTime::DOMHighResTimeStamp final_service_worker_start_time) { m_final_service_worker_start_time = final_service_worker_start_time; } |
41 | | |
42 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp final_network_request_start_time() const { return m_final_network_request_start_time; } |
43 | 0 | void set_final_network_request_start_time(HighResolutionTime::DOMHighResTimeStamp final_network_request_start_time) { m_final_network_request_start_time = final_network_request_start_time; } |
44 | | |
45 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp final_network_response_start_time() const { return m_final_network_response_start_time; } |
46 | 0 | void set_final_network_response_start_time(HighResolutionTime::DOMHighResTimeStamp final_network_response_start_time) { m_final_network_response_start_time = final_network_response_start_time; } |
47 | | |
48 | 0 | [[nodiscard]] HighResolutionTime::DOMHighResTimeStamp end_time() const { return m_end_time; } |
49 | 0 | void set_end_time(HighResolutionTime::DOMHighResTimeStamp end_time) { m_end_time = end_time; } |
50 | | |
51 | 0 | [[nodiscard]] JS::GCPtr<ConnectionTimingInfo> final_connection_timing_info() const { return m_final_connection_timing_info; } |
52 | 0 | void set_final_connection_timing_info(JS::GCPtr<ConnectionTimingInfo> final_connection_timing_info) { m_final_connection_timing_info = final_connection_timing_info; } |
53 | | |
54 | 0 | [[nodiscard]] Vector<String>& server_timing_headers() { return m_server_timing_headers; } |
55 | 0 | [[nodiscard]] Vector<String> const& server_timing_headers() const { return m_server_timing_headers; } |
56 | 0 | void set_server_timing_headers(Vector<String> server_timing_headers) { m_server_timing_headers = move(server_timing_headers); } |
57 | | |
58 | 0 | [[nodiscard]] bool render_blocking() const { return m_render_blocking; } |
59 | 0 | void set_render_blocking(bool render_blocking) { m_render_blocking = render_blocking; } |
60 | | |
61 | | private: |
62 | | FetchTimingInfo(); |
63 | | |
64 | | virtual void visit_edges(JS::Cell::Visitor&) override; |
65 | | |
66 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-start-time |
67 | | // start time (default 0) |
68 | | // A DOMHighResTimeStamp. |
69 | | HighResolutionTime::DOMHighResTimeStamp m_start_time { 0 }; |
70 | | |
71 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-redirect-start-time |
72 | | // redirect start time (default 0) |
73 | | // A DOMHighResTimeStamp. |
74 | | HighResolutionTime::DOMHighResTimeStamp m_redirect_start_time { 0 }; |
75 | | |
76 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-redirect-end-time |
77 | | // redirect end time (default 0) |
78 | | // A DOMHighResTimeStamp. |
79 | | HighResolutionTime::DOMHighResTimeStamp m_redirect_end_time { 0 }; |
80 | | |
81 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-post-redirect-start-time |
82 | | // post-redirect start time (default 0) |
83 | | // A DOMHighResTimeStamp. |
84 | | HighResolutionTime::DOMHighResTimeStamp m_post_redirect_start_time { 0 }; |
85 | | |
86 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-final-service-worker-start-time |
87 | | // final service worker start time (default 0) |
88 | | // A DOMHighResTimeStamp. |
89 | | HighResolutionTime::DOMHighResTimeStamp m_final_service_worker_start_time { 0 }; |
90 | | |
91 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-final-network-request-start-time |
92 | | // final network-request start time (default 0) |
93 | | // A DOMHighResTimeStamp. |
94 | | HighResolutionTime::DOMHighResTimeStamp m_final_network_request_start_time { 0 }; |
95 | | |
96 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-final-network-response-start-time |
97 | | // final network-response start time (default 0) |
98 | | // A DOMHighResTimeStamp. |
99 | | HighResolutionTime::DOMHighResTimeStamp m_final_network_response_start_time { 0 }; |
100 | | |
101 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-end-time |
102 | | // end time (default 0) |
103 | | // A DOMHighResTimeStamp. |
104 | | HighResolutionTime::DOMHighResTimeStamp m_end_time { 0 }; |
105 | | |
106 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-final-connection-timing-info |
107 | | // final connection timing info (default null) |
108 | | // Null or a connection timing info. |
109 | | JS::GCPtr<ConnectionTimingInfo> m_final_connection_timing_info; |
110 | | |
111 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-server-timing-headers |
112 | | // server-timing headers (default « ») |
113 | | // A list of strings. |
114 | | Vector<String> m_server_timing_headers; |
115 | | |
116 | | // https://fetch.spec.whatwg.org/#fetch-timing-info-render-blocking |
117 | | // render-blocking (default false) |
118 | | // A boolean. |
119 | | bool m_render_blocking { false }; |
120 | | }; |
121 | | |
122 | | JS::NonnullGCPtr<FetchTimingInfo> create_opaque_timing_info(JS::VM&, FetchTimingInfo const& timing_info); |
123 | | |
124 | | } |