Skip to content

Truly independent web browser

UI/Qt: Keep only the pinned tabs of a session that is not restored

Jelle Raaijmakers7cb66e1c280f
diff --git a/Tests/UI/Qt/TestSessionStore.cpp b/Tests/UI/Qt/TestSessionStore.cpp
index cc6e5d721bf..b45dea36586 100644
--- a/Tests/UI/Qt/TestSessionStore.cpp
+++ b/Tests/UI/Qt/TestSessionStore.cpp
@@ -4,11 +4,14 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibCore/File.h>
#include <LibDatabase/Database.h>
#include <LibTest/TestCase.h>
#include <LibURL/Parser.h>
#include <UI/Qt/SessionStore.h>
+#include <QTemporaryDir>
+
using namespace Ladybird;
using namespace WebView;
@@ -91,12 +94,12 @@ static void rewind_sessions_schema_to_version_4(Database::Database& database)
}
// What the frontend does at Quit: Every window closes in quitting mode, and the run then ends normally.
-static void quit_cleanly(SessionStore& store, Vector<SessionWindowId> const& windows)
+static void quit_cleanly(SessionStore& store, Vector<SessionWindowId> const& windows, SessionStore::AfterExit after_exit = SessionStore::AfterExit::KeepEverything)
{
store.application_quitting();
for (auto window : windows)
MUST(store.window_closing({ .window_id = window, .active_tab_index = 0, .closed_at = UnixDateTime::now() }));
- store.mark_clean_exit();
+ store.mark_clean_exit(after_exit);
}
TEST_CASE(fresh_database_migrates_to_the_latest_schema)
@@ -1602,7 +1605,7 @@ TEST_CASE(a_restart_restores_every_window_once)
auto second_window = TRY_OR_FAIL(store->window_opened());
(void)open_tab(*store, first_window, "https://a.example/"sv);
(void)open_tab(*store, second_window, "https://b.example/"sv);
- store->mark_clean_exit(SessionStore::RestartAfterExit::Yes);
+ store->mark_clean_exit(SessionStore::AfterExit::Restart);
}
{
auto store = TRY_OR_FAIL(SessionStore::create(*database, SessionLaunchPolicy::PinnedOnly));
@@ -1623,7 +1626,7 @@ TEST_CASE(only_the_run_right_after_a_restart_follows_it)
auto store = TRY_OR_FAIL(SessionStore::create(*database));
auto window = TRY_OR_FAIL(store->window_opened());
(void)open_tab(*store, window, "https://a.example/"sv);
- store->mark_clean_exit(SessionStore::RestartAfterExit::Yes);
+ store->mark_clean_exit(SessionStore::AfterExit::Restart);
}
{
auto store = TRY_OR_FAIL(SessionStore::create(*database, SessionLaunchPolicy::PinnedOnly));
@@ -1634,6 +1637,204 @@ TEST_CASE(only_the_run_right_after_a_restart_follows_it)
EXPECT(!store->follows_restart());
}
+TEST_CASE(an_exit_that_keeps_pinned_tabs_forgets_everything_else)
+{
+ auto database = create_session_database();
+ {
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto pinned = open_tab(*store, window, "https://a.example/"sv);
+ (void)open_tab(*store, window, "https://b.example/"sv);
+ auto closed = open_tab(*store, window, "https://c.example/"sv);
+ TRY_OR_FAIL(store->tab_pinned_changed(pinned, true));
+ TRY_OR_FAIL(store->tab_closed({ .tab_id = closed, .closed_at = UnixDateTime::now() }));
+ quit_cleanly(*store, { window }, SessionStore::AfterExit::KeepPinnedTabs);
+ }
+
+ EXPECT_EQ(select_i64(*database, "SELECT COUNT(*) FROM SessionTabs;"_string), 1);
+ EXPECT_EQ(select_i64(*database, "SELECT COUNT(*) FROM SessionTabs WHERE active_url LIKE '%b.example%' OR active_url LIKE '%c.example%';"_string), 0);
+
+ auto store = TRY_OR_FAIL(SessionStore::create(*database, SessionLaunchPolicy::PinnedOnly));
+ auto plan = store->take_launch_plan();
+ EXPECT_EQ(plan.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs[0].url.serialize(), "https://a.example/"sv);
+ EXPECT(!store->has_closed_units());
+}
+
+TEST_CASE(a_pin_that_failed_to_write_keeps_its_tab_after_an_exit_that_keeps_pinned_tabs)
+{
+ auto database = create_session_database();
+ {
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto pinned = open_tab(*store, window, "https://pinned.example/"sv);
+ (void)open_tab(*store, window, "https://other.example/"sv);
+ store->flush_dirty_state();
+
+ TRY_OR_FAIL(database->execute_raw("CREATE TRIGGER InjectedFailure BEFORE UPDATE OF pinned ON SessionTabs BEGIN SELECT RAISE(ABORT, 'injected'); END;"sv));
+ EXPECT(store->tab_pinned_changed(pinned, true).is_error());
+ store->application_quitting();
+ (void)store->window_closing({ .window_id = window, .active_tab_index = 0, .closed_at = UnixDateTime::now() });
+ store->flush_dirty_state();
+ store->mark_clean_exit(SessionStore::AfterExit::KeepPinnedTabs);
+ TRY_OR_FAIL(database->execute_raw("DROP TRIGGER InjectedFailure;"sv));
+ }
+
+ EXPECT_EQ(select_i64(*database, "SELECT COUNT(*) FROM SessionTabs WHERE active_url LIKE '%pinned.example%';"_string), 1);
+}
+
+TEST_CASE(a_pinned_tab_whose_close_failed_to_write_stays_closed_after_an_exit_that_keeps_pinned_tabs)
+{
+ auto database = create_session_database();
+ {
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto kept = open_tab(*store, window, "https://kept.example/"sv);
+ auto closed = open_tab(*store, window, "https://closed.example/"sv);
+ TRY_OR_FAIL(store->tab_pinned_changed(kept, true));
+ TRY_OR_FAIL(store->tab_pinned_changed(closed, true));
+ store->flush_dirty_state();
+
+ TRY_OR_FAIL(database->execute_raw("CREATE TRIGGER InjectedFailure BEFORE INSERT ON Sessions BEGIN SELECT RAISE(ABORT, 'injected'); END;"sv));
+ EXPECT(store->tab_closed({ .tab_id = closed, .closed_at = UnixDateTime::now() }).is_error());
+ store->application_quitting();
+ (void)store->window_closing({ .window_id = window, .active_tab_index = 0, .closed_at = UnixDateTime::now() });
+ store->flush_dirty_state();
+ store->mark_clean_exit(SessionStore::AfterExit::KeepPinnedTabs);
+ TRY_OR_FAIL(database->execute_raw("DROP TRIGGER InjectedFailure;"sv));
+ }
+
+ auto store = TRY_OR_FAIL(SessionStore::create(*database, SessionLaunchPolicy::PinnedOnly));
+ auto plan = store->take_launch_plan();
+ EXPECT_EQ(plan.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs[0].url.serialize(), "https://kept.example/"sv);
+}
+
+TEST_CASE(a_close_that_failed_to_write_stays_forgotten_after_an_exit_that_keeps_pinned_tabs)
+{
+ auto database = create_session_database();
+ {
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto pinned = open_tab(*store, window, "https://kept.example/"sv);
+ auto closed = open_tab(*store, window, "https://forgotten.example/"sv);
+ store->update_tab_state({ .tab_id = closed, .history = make_snapshot({ "https://forgotten.example/"sv }), .url = parse_url("https://forgotten.example/"sv) });
+ TRY_OR_FAIL(store->tab_pinned_changed(pinned, true));
+ store->flush_dirty_state();
+
+ TRY_OR_FAIL(database->execute_raw("CREATE TRIGGER InjectedFailure BEFORE INSERT ON Sessions BEGIN SELECT RAISE(ABORT, 'injected'); END;"sv));
+ EXPECT(store->tab_closed({ .tab_id = closed, .closed_at = UnixDateTime::now() }).is_error());
+ store->application_quitting();
+ (void)store->window_closing({ .window_id = window, .active_tab_index = 0, .closed_at = UnixDateTime::now() });
+ store->flush_dirty_state();
+ store->mark_clean_exit(SessionStore::AfterExit::KeepPinnedTabs);
+ TRY_OR_FAIL(database->execute_raw("DROP TRIGGER InjectedFailure;"sv));
+ }
+
+ EXPECT_EQ(select_i64(*database, "SELECT COUNT(*) FROM SessionTabs WHERE active_url LIKE '%forgotten.example%';"_string), 0);
+ EXPECT_EQ(select_i64(*database, "SELECT COUNT(*) FROM SessionEntries WHERE url LIKE '%forgotten.example%';"_string), 0);
+ EXPECT_EQ(select_i64(*database, "SELECT COUNT(*) FROM SessionTabs WHERE active_url LIKE '%kept.example%';"_string), 1);
+}
+
+TEST_CASE(the_last_window_whose_close_failed_to_write_comes_back_as_it_was_after_an_exit_that_keeps_pinned_tabs)
+{
+ auto database = create_session_database();
+ {
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto pinned = open_tab(*store, window, "https://before.example/"sv);
+ TRY_OR_FAIL(store->tab_pinned_changed(pinned, true));
+ store->flush_dirty_state();
+ store->update_tab_state({ .tab_id = pinned, .history = make_snapshot({ "https://before.example/"sv, "https://after.example/"sv }), .url = parse_url("https://after.example/"sv) });
+
+ TRY_OR_FAIL(database->execute_raw("CREATE TRIGGER InjectedSessionFailure BEFORE UPDATE ON Sessions BEGIN SELECT RAISE(ABORT, 'injected'); END;"sv));
+ TRY_OR_FAIL(database->execute_raw("CREATE TRIGGER InjectedTabFailure BEFORE UPDATE ON SessionTabs BEGIN SELECT RAISE(ABORT, 'injected'); END;"sv));
+ EXPECT(store->window_closing({ .window_id = window, .active_tab_index = 0, .closed_at = UnixDateTime::now() }).is_error());
+ store->flush_dirty_state();
+ TRY_OR_FAIL(database->execute_raw("DROP TRIGGER InjectedSessionFailure;"sv));
+ TRY_OR_FAIL(database->execute_raw("DROP TRIGGER InjectedTabFailure;"sv));
+ store->mark_clean_exit(SessionStore::AfterExit::KeepPinnedTabs);
+ }
+
+ auto store = TRY_OR_FAIL(SessionStore::create(*database, SessionLaunchPolicy::PinnedOnly));
+ auto plan = store->take_launch_plan();
+ EXPECT_EQ(plan.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs[0].url.serialize(), "https://after.example/"sv);
+}
+
+TEST_CASE(a_deletion_that_failed_to_write_removes_the_last_window_at_an_exit_that_keeps_pinned_tabs)
+{
+ auto database = create_session_database();
+ {
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto pinned = open_tab(*store, window, "https://deleted.example/"sv);
+ TRY_OR_FAIL(store->tab_pinned_changed(pinned, true));
+ store->flush_dirty_state();
+
+ TRY_OR_FAIL(database->execute_raw("CREATE TRIGGER InjectedUpdateFailure BEFORE UPDATE ON Sessions BEGIN SELECT RAISE(ABORT, 'injected'); END;"sv));
+ TRY_OR_FAIL(database->execute_raw("CREATE TRIGGER InjectedDeleteFailure BEFORE DELETE ON Sessions BEGIN SELECT RAISE(ABORT, 'injected'); END;"sv));
+ EXPECT(store->window_closing({ .window_id = window, .active_tab_index = 0, .closed_at = UnixDateTime::now() }).is_error());
+ EXPECT(store->remove_entries_accessed_since(UnixDateTime::epoch()).is_error());
+ store->flush_dirty_state();
+ TRY_OR_FAIL(database->execute_raw("DROP TRIGGER InjectedUpdateFailure;"sv));
+ TRY_OR_FAIL(database->execute_raw("DROP TRIGGER InjectedDeleteFailure;"sv));
+ store->mark_clean_exit(SessionStore::AfterExit::KeepPinnedTabs);
+ }
+
+ EXPECT_EQ(select_i64(*database, "SELECT COUNT(*) FROM SessionTabs WHERE active_url LIKE '%deleted.example%';"_string), 0);
+}
+
+TEST_CASE(an_exit_that_keeps_pinned_tabs_leaves_nothing_else_in_the_files)
+{
+ QTemporaryDir directory;
+ VERIFY(directory.isValid());
+ auto path = ByteString { directory.path().toUtf8().constData() };
+ {
+ auto database = TRY_OR_FAIL(Database::Database::create(path, "Sessions"sv, { .foreign_keys = Database::Database::ForeignKeys::Yes }));
+ TRY_OR_FAIL(SessionStore::migrate_schema(*database));
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto pinned = open_tab(*store, window, "https://kept.example/"sv);
+ (void)open_tab(*store, window, "https://forgotten.example/"sv);
+ TRY_OR_FAIL(store->tab_pinned_changed(pinned, true));
+ quit_cleanly(*store, { window }, SessionStore::AfterExit::KeepPinnedTabs);
+ }
+
+ for (auto suffix : { ""sv, "-wal"sv }) {
+ auto file = Core::File::open(ByteString::formatted("{}/Sessions.db{}", path, suffix), Core::File::OpenMode::Read);
+ if (suffix == "-wal"sv && file.is_error() && file.error().code() == ENOENT)
+ continue;
+ auto contents = TRY_OR_FAIL(TRY_OR_FAIL(move(file))->read_until_eof());
+ EXPECT(StringView { contents.bytes() }.contains("kept.example"sv) == suffix.is_empty());
+ EXPECT(!StringView { contents.bytes() }.contains("forgotten.example"sv));
+ }
+}
+
+TEST_CASE(an_exit_that_keeps_pinned_tabs_keeps_those_of_the_last_window_closed)
+{
+ auto database = create_session_database();
+ {
+ auto store = TRY_OR_FAIL(SessionStore::create(*database));
+ auto window = TRY_OR_FAIL(store->window_opened());
+ auto pinned = open_tab(*store, window, "https://a.example/"sv);
+ (void)open_tab(*store, window, "https://b.example/"sv);
+ TRY_OR_FAIL(store->tab_pinned_changed(pinned, true));
+ TRY_OR_FAIL(store->window_closing({ .window_id = window, .active_tab_index = 1, .closed_at = UnixDateTime::now() }));
+ store->mark_clean_exit(SessionStore::AfterExit::KeepPinnedTabs);
+ }
+
+ auto store = TRY_OR_FAIL(SessionStore::create(*database, SessionLaunchPolicy::PinnedOnly));
+ auto plan = store->take_launch_plan();
+ EXPECT_EQ(plan.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs.size(), 1uz);
+ EXPECT_EQ(plan[0].tabs[0].url.serialize(), "https://a.example/"sv);
+ EXPECT(!store->has_closed_units());
+}
+
TEST_CASE(pinned_only_restores_the_last_windows_pins)
{
auto database = create_session_database();
diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cpp
index 9f930811ac3..b382791fac0 100644
--- a/UI/Qt/Application.cpp
+++ b/UI/Qt/Application.cpp
@@ -1046,7 +1046,12 @@ Application::~Application()
// process at once, so it never records a clean exit.
if (m_session_store) {
m_session_store->flush_dirty_state();
- m_session_store->mark_clean_exit(m_restart != Restart::None ? SessionStore::RestartAfterExit::Yes : SessionStore::RestartAfterExit::No);
+ auto after_exit = SessionStore::AfterExit::KeepPinnedTabs;
+ if (m_restart != Restart::None)
+ after_exit = SessionStore::AfterExit::Restart;
+ else if (Application::settings().restore_previous_session())
+ after_exit = SessionStore::AfterExit::KeepEverything;
+ m_session_store->mark_clean_exit(after_exit);
}
// NB: The views go along with the windows that showed them, and their timers need the QApplication.
diff --git a/UI/Qt/SessionStore.cpp b/UI/Qt/SessionStore.cpp
index 0d1f45c4145..fee58073216 100644
--- a/UI/Qt/SessionStore.cpp
+++ b/UI/Qt/SessionStore.cpp
@@ -342,6 +342,9 @@ ErrorOr<SessionStore::PersistedStorage> SessionStore::PersistedStorage::create(D
statements.reopen_closed_session = TRY(database.prepare_statement("UPDATE Sessions SET kind = :open_window_kind, closed_time = 0, close_sequence = 0, source_window_id = NULL, source_tab_index = NULL, origin = :origin WHERE id = :id;"sv));
statements.recover_open_session = TRY(database.prepare_statement("UPDATE Sessions SET kind = :closed_window_kind, closed_time = :closed_time, close_sequence = :close_sequence, source_window_id = NULL, source_tab_index = NULL, origin = :origin WHERE id = :id;"sv));
statements.delete_empty_open_sessions = TRY(database.prepare_statement("DELETE FROM Sessions WHERE kind = :open_window_kind AND NOT EXISTS (SELECT 1 FROM SessionTabs WHERE session_id = Sessions.id);"sv));
+ statements.delete_closed_units_left_closed = TRY(database.prepare_statement("DELETE FROM Sessions WHERE kind != :open_window_kind AND restore_at_launch = 0;"sv));
+ statements.delete_unpinned_tabs = TRY(database.prepare_statement("DELETE FROM SessionTabs WHERE pinned = 0;"sv));
+ statements.delete_empty_sessions = TRY(database.prepare_statement("DELETE FROM Sessions WHERE NOT EXISTS (SELECT 1 FROM SessionTabs WHERE session_id = Sessions.id);"sv));
statements.select_lifecycle = TRY(database.prepare_statement("SELECT clean_exit, consecutive_unclean_exits, restart FROM SessionLifecycle WHERE id = 1;"sv));
statements.write_lifecycle = TRY(database.prepare_statement("INSERT INTO SessionLifecycle (id, clean_exit, consecutive_unclean_exits, restart) VALUES (1, :clean_exit, :consecutive_unclean_exits, :restart) ON CONFLICT (id) DO UPDATE SET clean_exit = excluded.clean_exit, consecutive_unclean_exits = excluded.consecutive_unclean_exits, restart = excluded.restart;"sv));
statements.snapshot_statements = TRY(prepare_session_history_snapshot_statements(database));
@@ -1114,6 +1117,26 @@ ErrorOr<void> SessionStore::PersistedStorage::write_lifecycle(bool clean_exit, u
});
}
+// Only the windows that the next launch brings back stay: those left open, and the last window closed, which counts as
+// left open. Their unpinned tabs, and every tab and window closed before, go with all of their history.
+ErrorOr<void> SessionStore::PersistedStorage::forget_all_but_pinned_tabs()
+{
+ TRY(database->transaction([&]() -> ErrorOr<void> {
+ TRY(database->try_execute_bound_statement(statements.delete_closed_units_left_closed, [&](auto& bind) -> ErrorOr<void> {
+ return bind("open_window_kind"sv, to_underlying(UnitKind::OpenWindow));
+ }));
+ TRY(database->try_execute_bound_statement(statements.delete_unpinned_tabs, [](auto&) -> ErrorOr<void> { return {}; }));
+ TRY(database->try_execute_bound_statement(statements.delete_empty_sessions, [](auto&) -> ErrorOr<void> { return {}; }));
+ return {};
+ }));
+
+ // A deleted row stays in the files, in the space that it took up and in the write-ahead log, until something writes
+ // over it. Rewriting the database leaves only what remains, which is little, and emptying the log removes the rest.
+ TRY(database->execute_raw("VACUUM;"));
+ TRY(database->execute_raw("PRAGMA wal_checkpoint(TRUNCATE);"));
+ return {};
+}
+
// Runs inside the recovery transaction, so it opens none of its own.
ErrorOr<SessionStore::PersistedStorage::RunStart> SessionStore::PersistedStorage::record_run_start()
{
@@ -2234,15 +2257,45 @@ void SessionStore::application_quit_aborted()
m_quitting = false;
}
-void SessionStore::mark_clean_exit(RestartAfterExit restart_after_exit)
+// A run that the next launch doesn't bring back whole leaves nothing of itself on disk but the pinned tabs.
+void SessionStore::mark_clean_exit(AfterExit after_exit)
{
m_consecutive_unclean_exits = 0;
if (!m_persisted_storage.has_value())
return;
- if (auto result = m_persisted_storage->write_lifecycle(true, 0, restart_after_exit == RestartAfterExit::Yes); result.is_error())
+ if (after_exit == AfterExit::KeepPinnedTabs) {
+ // Which tabs are pinned has to be on disk first, or a tab that was pinned since the last write would go too.
+ if (auto result = drain_window_metadata(); result.is_error())
+ dbgln("Unable to save which tabs are pinned, so the session stays in the session store: {}", result.error());
+ else if (auto result = discard_pending_closes(); result.is_error())
+ dbgln("Unable to remove what was closed, so the session stays in the session store: {}", result.error());
+ else if (auto result = m_persisted_storage->forget_all_but_pinned_tabs(); result.is_error())
+ dbgln("Unable to remove the session from the session store: {}", result.error());
+ }
+ if (auto result = m_persisted_storage->write_lifecycle(true, 0, after_exit == AfterExit::Restart); result.is_error())
dbgln("Unable to record a clean exit in the session store: {}", result.error());
}
+// A close that failed to write leaves what it closed among the open windows and tabs, where a pinned tab would be kept,
+// and would write it back once it is tried again. Nothing closed is kept, so such a close removes its rows instead. Only
+// the window that the next launch brings back is written as it was closed, since its pending close alone holds the latest
+// state of its tabs, unless deleting browsing data took it.
+ErrorOr<void> SessionStore::discard_pending_closes()
+{
+ for (auto const& pending : m_pending_tab_closes)
+ TRY(m_persisted_storage->discard_tab({ .id = pending.tab_id, .remaining_window = remaining_window_write(pending.tab.window_id, pending.tab_id) }));
+ m_pending_tab_closes.clear();
+
+ for (auto const& pending : m_pending_window_closes) {
+ if (pending.discard || !pending.restore_at_launch)
+ TRY(m_persisted_storage->delete_session_rows(pending.window_id));
+ else
+ TRY(finish_window_close(pending));
+ }
+ m_pending_window_closes.clear();
+ return {};
+}
+
bool SessionStore::has_closed_units() const
{
return m_transient_storage.has_closed_units();
diff --git a/UI/Qt/SessionStore.h b/UI/Qt/SessionStore.h
index 1e4823e2360..b057fa83704 100644
--- a/UI/Qt/SessionStore.h
+++ b/UI/Qt/SessionStore.h
@@ -179,12 +179,13 @@ public:
u32 consecutive_unclean_exits() const { return m_consecutive_unclean_exits; }
bool follows_restart() const { return m_follows_restart; }
- enum class RestartAfterExit : u8 {
- No,
- Yes,
+ enum class AfterExit : u8 {
+ KeepEverything,
+ KeepPinnedTabs,
+ Restart,
};
// Records that this run is ending normally. Only a normal teardown calls it, so a crash never records one.
- void mark_clean_exit(RestartAfterExit = RestartAfterExit::No);
+ void mark_clean_exit(AfterExit = AfterExit::KeepEverything);
bool is_persistent() const { return m_persisted_storage.has_value(); }
@@ -258,6 +259,9 @@ private:
Database::StatementID reopen_closed_session;
Database::StatementID recover_open_session;
Database::StatementID delete_empty_open_sessions;
+ Database::StatementID delete_closed_units_left_closed;
+ Database::StatementID delete_unpinned_tabs;
+ Database::StatementID delete_empty_sessions;
Database::StatementID select_lifecycle;
Database::StatementID write_lifecycle;
SessionHistorySnapshotStatements snapshot_statements;
@@ -435,6 +439,7 @@ private:
ErrorOr<void> delete_session_rows(SessionWindowId);
ErrorOr<void> prune_closed_units(UnitKind, u32 max_units);
ErrorOr<void> write_lifecycle(bool clean_exit, u32 consecutive_unclean_exits, bool restart = false);
+ ErrorOr<void> forget_all_but_pinned_tabs();
ErrorOr<IdAllocators> create_id_allocators();
ErrorOr<WebView::SessionHistorySnapshot> load_tab_snapshot(SessionTabId, size_t current_used_step_index);
@@ -549,6 +554,7 @@ private:
Optional<WindowMetadataWrite> remaining_window_write(SessionWindowId, SessionTabId closing_tab) const;
TabWrite tab_write_for(SessionTabId, OpenTab const&, i64 tab_ordinal) const;
bool window_has_pending_tab_closes(SessionWindowId) const;
+ ErrorOr<void> discard_pending_closes();
ErrorOr<void> finish_tab_close(PendingTabClose const&);
ErrorOr<void> finish_window_close(PendingWindowClose const&);
ErrorOr<void> retry_pending_clear_closed_units();