dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / fetch / infrastructure / fetch_params.lucb
#==============================================================================================
#
# fetch_params - Fetch::Infrastructure::FetchParams: a fetch's request, algorithms, task
# destination, controller, timing info and preloaded response candidate
#
# DESCRIPTION:
# Port of Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp (lines 16-73) with the
# inline members of FetchParams.h (lines 34-51).
#
# Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
# mark: Creation ================================================================================
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp:16 Web::Fetch::Infrastructure::FetchParams::FetchParams (private).
func fetch_params_construct(this: FetchParams*, request: FetchRequest*, algorithms: FetchAlgorithms*, controller: FetchController*, timing_info: FetchTimingInfo*):
# The default member initializers: a null task destination and preloaded response candidate (the zeroed cell's)
# and no cross-origin isolated capability.
this.m_cross_origin_isolated_capability = HtmlCanUseCrossOriginIsolatedApIs.no
this.m_request = request
this.m_algorithms = algorithms
this.m_controller = controller
this.m_timing_info = timing_info
fetch_controller_set_fetch_params(this.m_controller, this)
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp:25 Web::Fetch::Infrastructure::FetchParams::FetchParams (private copy constructor).
func fetch_params_construct_fetch_params(this: FetchParams*, params: const FetchParams*):
this.m_request = params.m_request
this.m_algorithms = params.m_algorithms
this.m_task_destination = params.m_task_destination
this.m_cross_origin_isolated_capability = params.m_cross_origin_isolated_capability
this.m_controller = params.m_controller
this.m_timing_info = params.m_timing_info
this.m_preloaded_response_candidate = params.m_preloaded_response_candidate
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp:36 Web::Fetch::Infrastructure::FetchParams::create.
pub func fetch_params_create(vm: Vm*, request: FetchRequest*, timing_info: FetchTimingInfo*) -> FetchParams*:
let algorithms = fetch_algorithms_create(vm, FetchAlgorithmsInput())
let controller = fetch_controller_create(vm)
# vm.heap().allocate<FetchParams>(request, algorithms, controller, timing_info)
let heap = vm_heap(vm)
let params = (FetchParams*)web_heap_allocate_cell(heap, &fetch_params_class)
gc.heap_defer_gc(heap)
fetch_params_construct(params, request, algorithms, controller, timing_info)
gc.heap_undefer_gc(heap)
return params
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp:43 Web::Fetch::Infrastructure::FetchParams::copy.
pub func fetch_params_copy(params: FetchParams*) -> FetchParams*:
# params.vm().heap().allocate<FetchParams>(params)
let heap = vm_heap(js_cell_vm(params.js_cell()))
let copy = (FetchParams*)web_heap_allocate_cell(heap, &fetch_params_class)
gc.heap_defer_gc(heap)
fetch_params_construct_fetch_params(copy, params)
gc.heap_undefer_gc(heap)
return copy
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp:48 Web::Fetch::Infrastructure::FetchParams::visit_edges (override).
pub func fetch_params_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (FetchParams*)base
gc.cell_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_t(visitor, this.m_request)
gc.cell_visitor_visit_t(visitor, this.m_algorithms)
gc.cell_visitor_visit_t(visitor, this.m_controller)
gc.cell_visitor_visit_t(visitor, this.m_timing_info)
match this.m_task_destination:
.js_object(object): js_visit_object(visitor, object)
_: _ = 0
match this.m_preloaded_response_candidate:
.fetch_response(response): gc.cell_visitor_visit_t(visitor, response)
_: _ = 0
# mark: FetchParams.h's accessors ===============================================================
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:34 Web::Fetch::Infrastructure::FetchParams::request.
pub func fetch_params_request(this: FetchParams*) -> FetchRequest*:
return this.m_request
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:35 Web::Fetch::Infrastructure::FetchParams::set_request.
pub func fetch_params_set_request(this: FetchParams*, request: FetchRequest*):
this.m_request = request
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:36 Web::Fetch::Infrastructure::FetchParams::controller.
pub func fetch_params_controller(this: FetchParams*) -> FetchController*:
return this.m_controller
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:37 Web::Fetch::Infrastructure::FetchParams::timing_info.
pub func fetch_params_timing_info(this: FetchParams*) -> FetchTimingInfo*:
return this.m_timing_info
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:39 Web::Fetch::Infrastructure::FetchParams::algorithms.
pub func fetch_params_algorithms(this: FetchParams*) -> FetchAlgorithms*:
return this.m_algorithms
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:40 Web::Fetch::Infrastructure::FetchParams::set_algorithms.
pub func fetch_params_set_algorithms(this: FetchParams*, algorithms: FetchAlgorithms*):
this.m_algorithms = algorithms
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:42 Web::Fetch::Infrastructure::FetchParams::task_destination.
pub func fetch_params_task_destination(this: FetchParams*) -> FetchTaskDestination*:
return &this.m_task_destination
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:43 Web::Fetch::Infrastructure::FetchParams::task_destination (const).
pub func fetch_params_task_destination_const(this: FetchParams*) -> FetchTaskDestination:
return this.m_task_destination
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:44 Web::Fetch::Infrastructure::FetchParams::set_task_destination.
pub func fetch_params_set_task_destination(this: FetchParams*, task_destination: FetchTaskDestination):
this.m_task_destination = task_destination
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:46 Web::Fetch::Infrastructure::FetchParams::cross_origin_isolated_capability.
pub func fetch_params_cross_origin_isolated_capability(this: FetchParams*) -> HtmlCanUseCrossOriginIsolatedApIs:
return this.m_cross_origin_isolated_capability
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:47 Web::Fetch::Infrastructure::FetchParams::set_cross_origin_isolated_capability.
pub func fetch_params_set_cross_origin_isolated_capability(this: FetchParams*, cross_origin_isolated_capability: HtmlCanUseCrossOriginIsolatedApIs):
this.m_cross_origin_isolated_capability = cross_origin_isolated_capability
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:49 Web::Fetch::Infrastructure::FetchParams::preloaded_response_candidate.
pub func fetch_params_preloaded_response_candidate(this: FetchParams*) -> FetchParamsPreloadedResponseCandidate*:
return &this.m_preloaded_response_candidate
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:50 Web::Fetch::Infrastructure::FetchParams::preloaded_response_candidate (const).
pub func fetch_params_preloaded_response_candidate_const(this: FetchParams*) -> FetchParamsPreloadedResponseCandidate:
return this.m_preloaded_response_candidate
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h:51 Web::Fetch::Infrastructure::FetchParams::set_preloaded_response_candidate.
pub func fetch_params_set_preloaded_response_candidate(this: FetchParams*, preloaded_response_candidate: FetchParamsPreloadedResponseCandidate):
this.m_preloaded_response_candidate = preloaded_response_candidate
# mark: Aborted and canceled ====================================================================
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp:62 Web::Fetch::Infrastructure::FetchParams::is_aborted.
# https://fetch.spec.whatwg.org/#fetch-params-aborted
pub func fetch_params_is_aborted(this: FetchParams*) -> bool:
# A fetch params fetchParams is aborted if its controller’s state is "aborted".
return fetch_controller_state(this.m_controller) == FetchControllerState.aborted
## Ported from Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp:69 Web::Fetch::Infrastructure::FetchParams::is_canceled.
# https://fetch.spec.whatwg.org/#fetch-params-canceled
pub func fetch_params_is_canceled(this: FetchParams*) -> bool:
# A fetch params fetchParams is canceled if its controller’s state is "aborted" or "terminated".
return fetch_controller_state(this.m_controller) == FetchControllerState.aborted or fetch_controller_state(this.m_controller) == FetchControllerState.terminated