LibWeb: Implement fetch record from the fetch spec
Implement fetch record concept from the '2.4. Fetch groups' in the fetch specs.
This commit is contained in:
parent
69da6a0ce4
commit
8d38a1326e
Notes:
github-actions[bot]
2024-07-20 20:10:56 +00:00
Author: https://github.com/mobounya Commit: https://github.com/LadybirdBrowser/ladybird/commit/8d38a1326e5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/673 Reviewed-by: https://github.com/kalenikaliaksandr Reviewed-by: https://github.com/kennethmyhra ✅
4 changed files with 87 additions and 0 deletions
|
@ -214,6 +214,7 @@ set(SOURCES
|
|||
Fetch/Infrastructure/ConnectionTimingInfo.cpp
|
||||
Fetch/Infrastructure/FetchAlgorithms.cpp
|
||||
Fetch/Infrastructure/FetchController.cpp
|
||||
Fetch/Infrastructure/FetchRecord.cpp
|
||||
Fetch/Infrastructure/FetchParams.cpp
|
||||
Fetch/Infrastructure/FetchTimingInfo.cpp
|
||||
Fetch/Infrastructure/HTTP.cpp
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Mohamed amine Bounya <mobounya@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Fetch/Infrastructure/FetchRecord.h>
|
||||
|
||||
namespace Web::Fetch::Infrastructure {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(FetchRecord);
|
||||
|
||||
JS::NonnullGCPtr<FetchRecord> FetchRecord::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request)
|
||||
{
|
||||
return vm.heap().allocate_without_realm<FetchRecord>(request);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<FetchRecord> FetchRecord::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Fetch::Infrastructure::FetchController> fetch_controller)
|
||||
{
|
||||
return vm.heap().allocate_without_realm<FetchRecord>(request, fetch_controller);
|
||||
}
|
||||
|
||||
FetchRecord::FetchRecord(JS::NonnullGCPtr<Infrastructure::Request> request)
|
||||
: m_request(request)
|
||||
{
|
||||
}
|
||||
|
||||
FetchRecord::FetchRecord(JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Fetch::Infrastructure::FetchController> fetch_controller)
|
||||
: m_request(request)
|
||||
, m_fetch_controller(fetch_controller)
|
||||
{
|
||||
}
|
||||
|
||||
void FetchRecord::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_request);
|
||||
visitor.visit(m_fetch_controller);
|
||||
}
|
||||
|
||||
}
|
44
Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchRecord.h
Normal file
44
Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchRecord.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Mohamed amine Bounya <mobounya@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
|
||||
|
||||
namespace Web::Fetch::Infrastructure {
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-fetch-record
|
||||
class FetchRecord : public JS::Cell {
|
||||
JS_CELL(FetchRecord, JS::Cell);
|
||||
JS_DECLARE_ALLOCATOR(FetchRecord);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<FetchRecord> create(JS::VM&, JS::NonnullGCPtr<Infrastructure::Request>);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<FetchRecord> create(JS::VM&, JS::NonnullGCPtr<Infrastructure::Request>, JS::GCPtr<FetchController>);
|
||||
|
||||
[[nodiscard]] JS::NonnullGCPtr<Infrastructure::Request> request() const { return m_request; }
|
||||
void set_request(JS::NonnullGCPtr<Infrastructure::Request> request) { m_request = request; }
|
||||
|
||||
[[nodiscard]] JS::GCPtr<FetchController> fetch_controller() const { return m_fetch_controller; }
|
||||
void set_fetch_controller(JS::GCPtr<FetchController> fetch_controller) { m_fetch_controller = fetch_controller; }
|
||||
|
||||
private:
|
||||
explicit FetchRecord(JS::NonnullGCPtr<Infrastructure::Request>);
|
||||
FetchRecord(JS::NonnullGCPtr<Infrastructure::Request>, JS::GCPtr<FetchController>);
|
||||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request
|
||||
// A fetch record has an associated request (a request)
|
||||
JS::NonnullGCPtr<Infrastructure::Request> m_request;
|
||||
|
||||
// https://fetch.spec.whatwg.org/#fetch-controller
|
||||
// A fetch record has an associated controller (a fetch controller or null)
|
||||
JS::GCPtr<FetchController> m_fetch_controller { nullptr };
|
||||
};
|
||||
|
||||
}
|
|
@ -311,6 +311,7 @@ class FetchAlgorithms;
|
|||
class FetchController;
|
||||
class FetchParams;
|
||||
class FetchTimingInfo;
|
||||
class FetchRecord;
|
||||
class HeaderList;
|
||||
class IncrementalReadLoopReadRequest;
|
||||
class Request;
|
||||
|
|
Loading…
Add table
Reference in a new issue