mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
LibWeb: Remove GC allocations in FetchAlgorithms constructor
We should not GC allocate in the constructors of GC-allocated objects because a new allocation might trigger garbage collection, which in turn might access not fully initialized objects.
This commit is contained in:
parent
f9f9c38de3
commit
5951a93f51
2 changed files with 46 additions and 15 deletions
|
@ -30,6 +30,13 @@ public:
|
|||
using ProcessResponseEndOfBodyFunction = Function<void(JS::NonnullGCPtr<Infrastructure::Response>)>;
|
||||
using ProcessResponseConsumeBodyFunction = Function<void(JS::NonnullGCPtr<Infrastructure::Response>, BodyBytes)>;
|
||||
|
||||
using ProcessRequestBodyChunkLengthHeapFunction = JS::NonnullGCPtr<JS::HeapFunction<ProcessRequestBodyChunkLengthFunction::FunctionType>>;
|
||||
using ProcessRequestEndOfBodyHeapFunction = JS::NonnullGCPtr<JS::HeapFunction<ProcessRequestEndOfBodyFunction::FunctionType>>;
|
||||
using ProcessEarlyHintsResponseHeapFunction = JS::NonnullGCPtr<JS::HeapFunction<ProcessEarlyHintsResponseFunction::FunctionType>>;
|
||||
using ProcessResponseHeapFunction = JS::NonnullGCPtr<JS::HeapFunction<ProcessResponseFunction::FunctionType>>;
|
||||
using ProcessResponseEndOfBodyHeapFunction = JS::NonnullGCPtr<JS::HeapFunction<ProcessResponseEndOfBodyFunction::FunctionType>>;
|
||||
using ProcessResponseConsumeBodyHeapFunction = JS::NonnullGCPtr<JS::HeapFunction<ProcessResponseConsumeBodyFunction::FunctionType>>;
|
||||
|
||||
struct Input {
|
||||
ProcessRequestBodyChunkLengthFunction process_request_body_chunk_length;
|
||||
ProcessRequestEndOfBodyFunction process_request_end_of_body;
|
||||
|
@ -51,14 +58,20 @@ public:
|
|||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
explicit FetchAlgorithms(JS::VM&, Input);
|
||||
explicit FetchAlgorithms(
|
||||
ProcessRequestBodyChunkLengthHeapFunction process_request_body_chunk_length,
|
||||
ProcessRequestEndOfBodyHeapFunction process_request_end_of_body,
|
||||
ProcessEarlyHintsResponseHeapFunction process_early_hints_response,
|
||||
ProcessResponseHeapFunction process_response,
|
||||
ProcessResponseEndOfBodyHeapFunction process_response_end_of_body,
|
||||
ProcessResponseConsumeBodyHeapFunction process_response_consume_body);
|
||||
|
||||
JS::NonnullGCPtr<JS::HeapFunction<void(u64)>> m_process_request_body_chunk_length;
|
||||
JS::NonnullGCPtr<JS::HeapFunction<void()>> m_process_request_end_of_body;
|
||||
JS::NonnullGCPtr<JS::HeapFunction<void(JS::NonnullGCPtr<Infrastructure::Response>)>> m_process_early_hints_response;
|
||||
JS::NonnullGCPtr<JS::HeapFunction<void(JS::NonnullGCPtr<Infrastructure::Response>)>> m_process_response;
|
||||
JS::NonnullGCPtr<JS::HeapFunction<void(JS::NonnullGCPtr<Infrastructure::Response>)>> m_process_response_end_of_body;
|
||||
JS::NonnullGCPtr<JS::HeapFunction<void(JS::NonnullGCPtr<Infrastructure::Response>, BodyBytes)>> m_process_response_consume_body;
|
||||
ProcessRequestBodyChunkLengthHeapFunction m_process_request_body_chunk_length;
|
||||
ProcessRequestEndOfBodyHeapFunction m_process_request_end_of_body;
|
||||
ProcessEarlyHintsResponseHeapFunction m_process_early_hints_response;
|
||||
ProcessResponseHeapFunction m_process_response;
|
||||
ProcessResponseEndOfBodyHeapFunction m_process_response_end_of_body;
|
||||
ProcessResponseConsumeBodyHeapFunction m_process_response_consume_body;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue