1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 01:07:44 +00:00

LibWeb: Make Web::PageClient GC-allocated

This is a first step towards simplifying the ownership model of
Web::Page. Soon Web::Page will store its WebClient as a
NonnullGCPtr to help solve lifetime issues of the client being
destroyed before the page.
This commit is contained in:
Shannon Booth 2023-12-04 21:40:33 +13:00 committed by Andreas Kling
parent 5c0cd0f484
commit 6e6f3a9a8f
11 changed files with 45 additions and 17 deletions

View file

@ -36,7 +36,7 @@ void ConnectionFromClient::request_file(Web::FileRequest request)
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
: IPC::ConnectionFromClient<WebWorkerClientEndpoint, WebWorkerServerEndpoint>(*this, move(socket), 1)
, m_page_host(PageHost::create(*this))
, m_page_host(PageHost::create(Web::Bindings::main_thread_vm(), *this))
{
}

View file

@ -9,10 +9,12 @@
#include <AK/HashMap.h>
#include <LibIPC/ConnectionFromClient.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Handle.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Loader/FileRequest.h>
#include <LibWeb/Worker/WebWorkerClientEndpoint.h>
#include <LibWeb/Worker/WebWorkerServerEndpoint.h>
#include <Services/WebWorker/PageHost.h>
#include <WebWorker/Forward.h>
namespace WebWorker {
@ -40,7 +42,7 @@ private:
virtual void start_dedicated_worker(AK::URL const& url, String const&, String const&, String const&, IPC::File const&) override;
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
NonnullOwnPtr<PageHost> m_page_host;
JS::Handle<PageHost> m_page_host;
// FIXME: Route console messages to the Browser UI using a ConsoleClient

View file

@ -4,11 +4,17 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/VM.h>
#include <WebWorker/ConnectionFromClient.h>
#include <WebWorker/PageHost.h>
namespace WebWorker {
JS::NonnullGCPtr<PageHost> PageHost::create(JS::VM& vm, ConnectionFromClient& client)
{
return vm.heap().allocate_without_realm<PageHost>(client);
}
PageHost::~PageHost() = default;
Web::Page& PageHost::page()

View file

@ -14,11 +14,11 @@
namespace WebWorker {
class PageHost final : public Web::PageClient {
AK_MAKE_NONCOPYABLE(PageHost);
AK_MAKE_NONMOVABLE(PageHost);
JS_CELL(PageHost, Web::PageClient);
public:
static NonnullOwnPtr<PageHost> create(ConnectionFromClient& client) { return adopt_own(*new PageHost(client)); }
static JS::NonnullGCPtr<PageHost> create(JS::VM& vm, ConnectionFromClient& client);
virtual ~PageHost();
virtual Web::Page& page() override;