mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
70
Libraries/LibWeb/Fetch/Fetching/PendingResponse.cpp
Normal file
70
Libraries/LibWeb/Fetch/Fetching/PendingResponse.cpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Fetch/Fetching/PendingResponse.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
|
||||
namespace Web::Fetch::Fetching {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(PendingResponse);
|
||||
|
||||
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request)
|
||||
{
|
||||
return vm.heap().allocate_without_realm<PendingResponse>(request);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request, JS::NonnullGCPtr<Infrastructure::Response> response)
|
||||
{
|
||||
return vm.heap().allocate_without_realm<PendingResponse>(request, response);
|
||||
}
|
||||
|
||||
PendingResponse::PendingResponse(JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Infrastructure::Response> response)
|
||||
: m_request(request)
|
||||
, m_response(response)
|
||||
{
|
||||
m_request->add_pending_response({}, *this);
|
||||
}
|
||||
|
||||
void PendingResponse::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_callback);
|
||||
visitor.visit(m_request);
|
||||
visitor.visit(m_response);
|
||||
}
|
||||
|
||||
void PendingResponse::when_loaded(Callback callback)
|
||||
{
|
||||
VERIFY(!m_callback);
|
||||
m_callback = JS::create_heap_function(heap(), move(callback));
|
||||
if (m_response)
|
||||
run_callback();
|
||||
}
|
||||
|
||||
void PendingResponse::resolve(JS::NonnullGCPtr<Infrastructure::Response> response)
|
||||
{
|
||||
VERIFY(!m_response);
|
||||
m_response = response;
|
||||
if (m_callback)
|
||||
run_callback();
|
||||
}
|
||||
|
||||
void PendingResponse::run_callback()
|
||||
{
|
||||
VERIFY(m_callback);
|
||||
VERIFY(m_response);
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [this] {
|
||||
VERIFY(m_callback);
|
||||
VERIFY(m_response);
|
||||
m_callback->function()(*m_response);
|
||||
m_request->remove_pending_response({}, *this);
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue