mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-17 01:10:28 +03:00
Ladybird+LibWebView: Move SQLServer launcher to Ladybird
It previously resided in LibWebView to hide the details of launching a singleton process. That functionality now lives in LibCore. By moving this to Ladybird, we will be able to register the process with the task manager.
This commit is contained in:
parent
76af4503c1
commit
f16f89eb32
Notes:
sideshowbarker
2024-07-17 04:21:32 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/f16f89eb32 Pull-request: https://github.com/SerenityOS/serenity/pull/24074 Reviewed-by: https://github.com/ADKaster ✅
@ -9,6 +9,7 @@
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <LibSQL/SQLClient.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
|
||||
#import <System/Cocoa.h>
|
||||
@ -22,6 +23,7 @@ class WebViewBridge;
|
||||
- (instancetype)init;
|
||||
|
||||
- (ErrorOr<void>)launchRequestServer:(Vector<ByteString> const&)certificates;
|
||||
- (ErrorOr<NonnullRefPtr<SQL::SQLClient>>)launchSQLServer;
|
||||
- (ErrorOr<NonnullRefPtr<WebView::WebContentClient>>)launchWebContent:(Ladybird::WebViewBridge&)web_view_bridge;
|
||||
- (ErrorOr<IPC::File>)launchWebWorker;
|
||||
|
||||
|
@ -40,6 +40,11 @@
|
||||
return m_application_bridge->launch_request_server(certificates);
|
||||
}
|
||||
|
||||
- (ErrorOr<NonnullRefPtr<SQL::SQLClient>>)launchSQLServer
|
||||
{
|
||||
return m_application_bridge->launch_sql_server();
|
||||
}
|
||||
|
||||
- (ErrorOr<NonnullRefPtr<WebView::WebContentClient>>)launchWebContent:(Ladybird::WebViewBridge&)web_view_bridge
|
||||
{
|
||||
return m_application_bridge->launch_web_content(web_view_bridge);
|
||||
|
@ -37,6 +37,14 @@ ErrorOr<void> ApplicationBridge::launch_request_server(Vector<ByteString> const&
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SQL::SQLClient>> ApplicationBridge::launch_sql_server()
|
||||
{
|
||||
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
|
||||
auto sql_client = TRY(launch_sql_server_process(sql_server_paths));
|
||||
|
||||
return sql_client;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> ApplicationBridge::launch_web_content(WebViewBridge& web_view_bridge)
|
||||
{
|
||||
// FIXME: Fail to open the tab, rather than crashing the whole application if this fails
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <LibSQL/SQLClient.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
|
||||
namespace Ladybird {
|
||||
@ -22,6 +23,7 @@ public:
|
||||
~ApplicationBridge();
|
||||
|
||||
ErrorOr<void> launch_request_server(Vector<ByteString> const& certificates);
|
||||
ErrorOr<NonnullRefPtr<SQL::SQLClient>> launch_sql_server();
|
||||
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content(WebViewBridge&);
|
||||
ErrorOr<IPC::File> launch_web_worker();
|
||||
|
||||
|
@ -67,8 +67,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
WebView::ProcessManager::the().add_process(pid, move(port));
|
||||
};
|
||||
|
||||
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
|
||||
auto database = TRY(WebView::Database::create(move(sql_server_paths)));
|
||||
auto sql_client = TRY([application launchSQLServer]);
|
||||
auto database = TRY(WebView::Database::create(move(sql_client)));
|
||||
auto cookie_jar = TRY(WebView::CookieJar::create(*database));
|
||||
|
||||
// FIXME: Create an abstraction to re-spawn the RequestServer and re-hook up its client hooks to each tab on crash
|
||||
|
@ -186,7 +186,7 @@ target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
|
||||
BASE_DIRS ${SERENITY_SOURCE_DIR}
|
||||
FILES ${LADYBIRD_HEADERS}
|
||||
)
|
||||
target_link_libraries(ladybird PRIVATE AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibProtocol LibURL)
|
||||
target_link_libraries(ladybird PRIVATE AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibSQL LibWeb LibWebView LibProtocol LibURL)
|
||||
|
||||
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
@ -215,7 +215,7 @@ add_executable(headless-browser
|
||||
|
||||
target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(headless-browser PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibTLS LibIPC LibDiff LibProtocol LibURL)
|
||||
target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibSQL LibTLS LibIPC LibDiff LibProtocol LibURL)
|
||||
|
||||
if (ANDROID)
|
||||
include(cmake/AndroidExtras.cmake)
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "HelperProcess.h"
|
||||
#include "Utilities.h"
|
||||
#include <LibCore/Environment.h>
|
||||
#include <LibCore/SingletonProcess.h>
|
||||
#include <LibWebView/ProcessManager.h>
|
||||
|
||||
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
|
||||
@ -184,6 +185,12 @@ ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(Re
|
||||
return launch_generic_server_process<Protocol::RequestClient>(candidate_request_server_paths, "RequestServer"sv, move(arguments));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SQL::SQLClient>> launch_sql_server_process(ReadonlySpan<ByteString> candidate_sql_server_paths)
|
||||
{
|
||||
auto [client, _] = TRY(Core::launch_singleton_process<SQL::SQLClient>("SQLServer"sv, candidate_sql_server_paths));
|
||||
return client;
|
||||
}
|
||||
|
||||
ErrorOr<IPC::File> connect_new_request_server_client(Protocol::RequestClient& client)
|
||||
{
|
||||
auto new_socket = client.send_sync_but_allow_failure<Messages::RequestServer::ConnectNewClient>();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <AK/StringView.h>
|
||||
#include <LibImageDecoderClient/Client.h>
|
||||
#include <LibProtocol/RequestClient.h>
|
||||
#include <LibSQL/SQLClient.h>
|
||||
#include <LibWeb/Worker/WebWorkerClient.h>
|
||||
#include <LibWebView/ViewImplementation.h>
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
@ -26,5 +27,6 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
|
||||
ErrorOr<NonnullRefPtr<ImageDecoderClient::Client>> launch_image_decoder_process(ReadonlySpan<ByteString> candidate_image_decoder_paths);
|
||||
ErrorOr<NonnullRefPtr<Web::HTML::WebWorkerClient>> launch_web_worker_process(ReadonlySpan<ByteString> candidate_web_worker_paths, NonnullRefPtr<Protocol::RequestClient>);
|
||||
ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<ByteString> candidate_request_server_paths, StringView serenity_resource_root, Vector<ByteString> const& certificates);
|
||||
ErrorOr<NonnullRefPtr<SQL::SQLClient>> launch_sql_server_process(ReadonlySpan<ByteString> candidate_sql_server_paths);
|
||||
|
||||
ErrorOr<IPC::File> connect_new_request_server_client(Protocol::RequestClient&);
|
||||
|
@ -117,7 +117,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
if (!disable_sql_database) {
|
||||
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
|
||||
database = TRY(WebView::Database::create(move(sql_server_paths)));
|
||||
auto sql_client = TRY(launch_sql_server_process(sql_server_paths));
|
||||
|
||||
database = TRY(WebView::Database::create(sql_client));
|
||||
}
|
||||
|
||||
auto cookie_jar = database ? TRY(WebView::CookieJar::create(*database)) : WebView::CookieJar::create();
|
||||
|
@ -81,7 +81,7 @@ endif()
|
||||
target_include_directories(WebContent PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
||||
target_include_directories(WebContent PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
target_include_directories(WebContent PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..)
|
||||
target_link_libraries(WebContent PRIVATE LibAudio LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebSocket LibProtocol LibWebView LibURL)
|
||||
target_link_libraries(WebContent PRIVATE LibAudio LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibSQL LibWeb LibWebSocket LibProtocol LibWebView LibURL)
|
||||
|
||||
if (HAVE_PULSEAUDIO)
|
||||
target_compile_definitions(WebContent PRIVATE HAVE_PULSEAUDIO=1)
|
||||
|
@ -19,7 +19,7 @@ add_library(webworker STATIC ${WEBWORKER_SOURCES})
|
||||
target_include_directories(webworker PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
||||
target_include_directories(webworker PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
target_include_directories(webworker PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..)
|
||||
target_link_libraries(webworker PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibProtocol LibWeb LibWebView LibLocale LibImageDecoderClient LibMain LibURL)
|
||||
target_link_libraries(webworker PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibProtocol LibWeb LibWebView LibLocale LibImageDecoderClient LibMain LibSQL LibURL)
|
||||
|
||||
add_executable(WebWorker main.cpp)
|
||||
target_include_directories(WebWorker PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
|
@ -187,6 +187,7 @@ executable("headless-browser") {
|
||||
"//Userland/Libraries/LibJS",
|
||||
"//Userland/Libraries/LibMain",
|
||||
"//Userland/Libraries/LibProtocol",
|
||||
"//Userland/Libraries/LibSQL",
|
||||
"//Userland/Libraries/LibTLS",
|
||||
"//Userland/Libraries/LibURL",
|
||||
"//Userland/Libraries/LibWeb",
|
||||
|
@ -37,6 +37,7 @@ executable("WebContent") {
|
||||
"//Userland/Libraries/LibJS",
|
||||
"//Userland/Libraries/LibMain",
|
||||
"//Userland/Libraries/LibProtocol",
|
||||
"//Userland/Libraries/LibSQL",
|
||||
"//Userland/Libraries/LibURL",
|
||||
"//Userland/Libraries/LibWeb",
|
||||
"//Userland/Libraries/LibWebSocket",
|
||||
|
@ -15,6 +15,7 @@ executable("WebWorker") {
|
||||
"//Userland/Libraries/LibLocale",
|
||||
"//Userland/Libraries/LibMain",
|
||||
"//Userland/Libraries/LibProtocol",
|
||||
"//Userland/Libraries/LibSQL",
|
||||
"//Userland/Libraries/LibURL",
|
||||
"//Userland/Libraries/LibWeb",
|
||||
"//Userland/Libraries/LibWeb:WebWorkerClientEndpoint",
|
||||
|
@ -7,10 +7,6 @@
|
||||
#include <AK/StringView.h>
|
||||
#include <LibWebView/Database.h>
|
||||
|
||||
#if !defined(AK_OS_SERENITY)
|
||||
# include <LibCore/SingletonProcess.h>
|
||||
#endif
|
||||
|
||||
namespace WebView {
|
||||
|
||||
static constexpr auto database_name = "Browser"sv;
|
||||
@ -21,16 +17,6 @@ ErrorOr<NonnullRefPtr<Database>> Database::create()
|
||||
return create(move(sql_client));
|
||||
}
|
||||
|
||||
#if !defined(AK_OS_SERENITY)
|
||||
|
||||
ErrorOr<NonnullRefPtr<Database>> Database::create(ReadonlySpan<ByteString> candidate_sql_server_paths)
|
||||
{
|
||||
auto [sql_client, _] = TRY(Core::launch_singleton_process<SQL::SQLClient>("SQLServer"sv, 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,9 +29,7 @@ class Database : public RefCounted<Database> {
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Database>> create();
|
||||
#if !defined(AK_OS_SERENITY)
|
||||
static ErrorOr<NonnullRefPtr<Database>> create(ReadonlySpan<ByteString> candidate_sql_server_paths);
|
||||
#endif
|
||||
static ErrorOr<NonnullRefPtr<Database>> create(NonnullRefPtr<SQL::SQLClient>);
|
||||
|
||||
ErrorOr<SQL::StatementID> prepare_statement(StringView statement);
|
||||
|
||||
@ -59,8 +57,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static ErrorOr<NonnullRefPtr<Database>> create(NonnullRefPtr<SQL::SQLClient>);
|
||||
|
||||
struct ExecutionKey {
|
||||
constexpr bool operator==(ExecutionKey const&) const = default;
|
||||
|
||||
|
@ -75,7 +75,8 @@ public:
|
||||
(void)certificates;
|
||||
#else
|
||||
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
|
||||
auto database = TRY(WebView::Database::create(move(sql_server_paths)));
|
||||
auto sql_client = TRY(launch_sql_server_process(sql_server_paths));
|
||||
auto database = TRY(WebView::Database::create(move(sql_client)));
|
||||
|
||||
auto request_server_paths = TRY(get_paths_for_helper_process("RequestServer"sv));
|
||||
request_client = TRY(launch_request_server_process(request_server_paths, resources_folder, certificates));
|
||||
|
Loading…
Reference in New Issue
Block a user