mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
WebContent process keeps session history entries for pages we have navigated away from. Before this change, those entries could prevent GC objects (e.g. PolicyContainer and its CSP PolicyList) from being collected, since the GC-allocated SHE/DocumentState held live GC::Ref pointers into the heap. By making both classes RefCounted and storing SerializedPolicyContainer instead of a live PolicyContainer, history entries no longer keep alive any GC objects. This eliminates the leak and is also a step toward moving the session history entry tree to the UI process.
33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Runtime/VM.h>
|
|
#include <LibWeb/Crypto/Crypto.h>
|
|
#include <LibWeb/HTML/DocumentState.h>
|
|
#include <LibWeb/HTML/SessionHistoryEntry.h>
|
|
#include <LibWeb/HTML/StructuredSerialize.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
NonnullRefPtr<SessionHistoryEntry> SessionHistoryEntry::create()
|
|
{
|
|
return adopt_ref(*new SessionHistoryEntry());
|
|
}
|
|
|
|
SessionHistoryEntry::~SessionHistoryEntry() = default;
|
|
|
|
RefPtr<DocumentState> SessionHistoryEntry::document_state() const { return m_document_state; }
|
|
void SessionHistoryEntry::set_document_state(RefPtr<DocumentState> document_state) { m_document_state = move(document_state); }
|
|
|
|
SessionHistoryEntry::SessionHistoryEntry()
|
|
: m_classic_history_api_state(MUST(structured_serialize_for_storage(JS::VM::the(), JS::js_null())))
|
|
, m_navigation_api_state(MUST(structured_serialize_for_storage(JS::VM::the(), JS::js_undefined())))
|
|
, m_navigation_api_key(Crypto::generate_random_uuid())
|
|
, m_navigation_api_id(Crypto::generate_random_uuid())
|
|
{
|
|
}
|
|
|
|
}
|