diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp index 2d291b6296..ff47328d77 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp @@ -24,27 +24,39 @@ void FetchController::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_full_timing_info); + visitor.visit(m_report_timing_steps); + visitor.visit(m_next_manual_redirect_steps); visitor.visit(m_fetch_params); } +void FetchController::set_report_timing_steps(Function report_timing_steps) +{ + m_report_timing_steps = JS::create_heap_function(vm().heap(), move(report_timing_steps)); +} + +void FetchController::set_next_manual_redirect_steps(Function next_manual_redirect_steps) +{ + m_next_manual_redirect_steps = JS::create_heap_function(vm().heap(), move(next_manual_redirect_steps)); +} + // https://fetch.spec.whatwg.org/#finalize-and-report-timing void FetchController::report_timing(JS::Object const& global) const { // 1. Assert: this’s report timing steps is not null. - VERIFY(m_report_timing_steps.has_value()); + VERIFY(m_report_timing_steps); // 2. Call this’s report timing steps with global. - (*m_report_timing_steps)(global); + m_report_timing_steps->function()(global); } // https://fetch.spec.whatwg.org/#fetch-controller-process-the-next-manual-redirect void FetchController::process_next_manual_redirect() const { // 1. Assert: controller’s next manual redirect steps are not null. - VERIFY(m_next_manual_redirect_steps.has_value()); + VERIFY(m_next_manual_redirect_steps); // 2. Call controller’s next manual redirect steps. - (*m_next_manual_redirect_steps)(); + m_next_manual_redirect_steps->function()(); } // https://fetch.spec.whatwg.org/#extract-full-timing-info diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.h index c518533636..e519a97056 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -30,8 +32,8 @@ public: [[nodiscard]] static JS::NonnullGCPtr create(JS::VM&); void set_full_timing_info(JS::NonnullGCPtr full_timing_info) { m_full_timing_info = full_timing_info; } - void set_report_timing_steps(JS::SafeFunction report_timing_steps) { m_report_timing_steps = move(report_timing_steps); } - void set_next_manual_redirect_steps(JS::SafeFunction next_manual_redirect_steps) { m_next_manual_redirect_steps = move(next_manual_redirect_steps); } + void set_report_timing_steps(Function report_timing_steps); + void set_next_manual_redirect_steps(Function next_manual_redirect_steps); [[nodiscard]] State state() const { return m_state; } @@ -63,7 +65,7 @@ private: // https://fetch.spec.whatwg.org/#fetch-controller-report-timing-steps // report timing steps (default null) // Null or an algorithm accepting a global object. - Optional> m_report_timing_steps; + JS::GCPtr> m_report_timing_steps; // https://fetch.spec.whatwg.org/#fetch-controller-report-timing-steps // FIXME: serialized abort reason (default null) @@ -72,7 +74,7 @@ private: // https://fetch.spec.whatwg.org/#fetch-controller-next-manual-redirect-steps // next manual redirect steps (default null) // Null or an algorithm accepting nothing. - Optional> m_next_manual_redirect_steps; + JS::GCPtr> m_next_manual_redirect_steps; JS::GCPtr m_fetch_params; };