mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
Ladybird+headless-browser: Make RequestServer single instance on Lagom
Co-Authored-By: Timothy Flynn <trflynn89@pm.me>
This commit is contained in:
@@ -6,22 +6,19 @@
|
||||
*/
|
||||
|
||||
#include "WebContentView.h"
|
||||
#include "Application.h"
|
||||
#include "StringUtils.h"
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/API/KeyCode.h>
|
||||
#include <Ladybird/HelperProcess.h>
|
||||
#include <Ladybird/Utilities.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Font/FontDatabase.h>
|
||||
@@ -30,10 +27,9 @@
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibWeb/Crypto/Crypto.h>
|
||||
#include <LibWeb/Loader/ContentFilter.h>
|
||||
#include <LibWeb/Worker/WebWorkerClient.h>
|
||||
#include <LibWebView/SocketPair.h>
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
@@ -126,8 +122,9 @@ WebContentView::WebContentView(QWidget* window, WebContentOptions const& web_con
|
||||
finish_handling_key_event(event);
|
||||
};
|
||||
|
||||
on_request_worker_agent = [this]() {
|
||||
auto worker_client = MUST(launch_web_worker_process(MUST(get_paths_for_helper_process("WebWorker"sv)), m_web_content_options.certificates));
|
||||
on_request_worker_agent = []() {
|
||||
auto& request_server_client = static_cast<Ladybird::Application*>(QApplication::instance())->request_server_client;
|
||||
auto worker_client = MUST(launch_web_worker_process(MUST(get_paths_for_helper_process("WebWorker"sv)), *request_server_client));
|
||||
return worker_client->dup_sockets();
|
||||
};
|
||||
}
|
||||
@@ -537,8 +534,17 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli
|
||||
if (create_new_client == CreateNewClient::Yes) {
|
||||
m_client_state = {};
|
||||
|
||||
Optional<WebView::SocketPair> request_server_sockets;
|
||||
if (m_web_content_options.use_lagom_networking == UseLagomNetworking::Yes) {
|
||||
auto& protocol = static_cast<Ladybird::Application*>(QApplication::instance())->request_server_client;
|
||||
|
||||
// FIXME: Fail to open the tab, rather than crashing the whole application if this fails
|
||||
auto sockets = connect_new_request_server_client(*protocol).release_value_but_fixme_should_propagate_errors();
|
||||
request_server_sockets = AK::move(sockets);
|
||||
}
|
||||
|
||||
auto candidate_web_content_paths = get_paths_for_helper_process("WebContent"sv).release_value_but_fixme_should_propagate_errors();
|
||||
auto new_client = launch_web_content_process(*this, candidate_web_content_paths, m_web_content_options).release_value_but_fixme_should_propagate_errors();
|
||||
auto new_client = launch_web_content_process(*this, candidate_web_content_paths, m_web_content_options, AK::move(request_server_sockets)).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_client_state.client = new_client;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user