mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
Ladybird+LibWebView: Move creation of the SQL client to LibWebView
This lets us remove the direct dependency from Ladybird to LibSQL.
This commit is contained in:
parent
5c5a00dd3a
commit
e26ead0995
Notes:
sideshowbarker
2024-07-16 23:55:09 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/e26ead0995 Pull-request: https://github.com/SerenityOS/serenity/pull/20863
5 changed files with 18 additions and 8 deletions
|
@ -46,9 +46,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
|
||||
auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client(move(sql_server_paths)));
|
||||
|
||||
auto database = TRY(WebView::Database::create(move(sql_client)));
|
||||
auto database = TRY(WebView::Database::create(move(sql_server_paths)));
|
||||
auto cookie_jar = TRY(WebView::CookieJar::create(*database));
|
||||
|
||||
Optional<URL> initial_url;
|
||||
|
|
|
@ -150,7 +150,7 @@ target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
|
|||
BASE_DIRS ${SERENITY_SOURCE_DIR}
|
||||
FILES ${LADYBIRD_HEADERS}
|
||||
)
|
||||
target_link_libraries(ladybird PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibPublicSuffix LibWeb LibWebView LibSQL LibProtocol)
|
||||
target_link_libraries(ladybird PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibPublicSuffix LibWeb LibWebView LibProtocol)
|
||||
|
||||
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibSQL/SQLClient.h>
|
||||
#include <LibWebView/CookieJar.h>
|
||||
#include <LibWebView/Database.h>
|
||||
#include <QApplication>
|
||||
|
@ -99,8 +98,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (enable_sql_database) {
|
||||
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
|
||||
auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client(move(sql_server_paths)));
|
||||
database = TRY(WebView::Database::create(move(sql_client)));
|
||||
database = TRY(WebView::Database::create(move(sql_server_paths)));
|
||||
}
|
||||
|
||||
auto cookie_jar = database ? TRY(WebView::CookieJar::create(*database)) : WebView::CookieJar::create();
|
||||
|
|
|
@ -17,6 +17,16 @@ ErrorOr<NonnullRefPtr<Database>> Database::create()
|
|||
return create(move(sql_client));
|
||||
}
|
||||
|
||||
#if !defined(AK_OS_SERENITY)
|
||||
|
||||
ErrorOr<NonnullRefPtr<Database>> Database::create(Vector<String> candidate_sql_server_paths)
|
||||
{
|
||||
auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client(move(candidate_sql_server_paths)));
|
||||
return create(move(sql_client));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ErrorOr<NonnullRefPtr<Database>> Database::create(NonnullRefPtr<SQL::SQLClient> sql_client)
|
||||
{
|
||||
auto connection_id = sql_client->connect(database_name);
|
||||
|
|
|
@ -29,7 +29,9 @@ class Database : public RefCounted<Database> {
|
|||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Database>> create();
|
||||
static ErrorOr<NonnullRefPtr<Database>> create(NonnullRefPtr<SQL::SQLClient>);
|
||||
#if !defined(AK_OS_SERENITY)
|
||||
static ErrorOr<NonnullRefPtr<Database>> create(Vector<String> candidate_sql_server_paths);
|
||||
#endif
|
||||
|
||||
ErrorOr<SQL::StatementID> prepare_statement(StringView statement);
|
||||
|
||||
|
@ -57,6 +59,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static ErrorOr<NonnullRefPtr<Database>> create(NonnullRefPtr<SQL::SQLClient>);
|
||||
|
||||
struct ExecutionKey {
|
||||
constexpr bool operator==(ExecutionKey const&) const = default;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue