mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 15:34:59 +00:00
Ladybird/Android: Move JNI functions into their own files
This should be easier to work on, and keeps the layers of the native code nice and clean cut.
This commit is contained in:
parent
274fd88242
commit
315ad2d391
8 changed files with 256 additions and 210 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "WebContentService.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <Ladybird/FontPlugin.h>
|
||||
#include <Ladybird/HelperProcess.h>
|
||||
|
@ -26,8 +27,6 @@
|
|||
#include <LibWebView/WebSocketClientAdapter.h>
|
||||
#include <WebContent/ConnectionFromClient.h>
|
||||
#include <WebContent/PageHost.h>
|
||||
#include <jni.h>
|
||||
#include <unistd.h>
|
||||
|
||||
class NullResourceConnector : public Web::ResourceLoaderConnector {
|
||||
virtual void prefetch_dns(AK::URL const&) override { }
|
||||
|
@ -72,33 +71,3 @@ ErrorOr<int> web_content_main(int ipc_socket, int fd_passing_socket)
|
|||
|
||||
return event_loop.exec();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_org_serenityos_ladybird_WebContentService_nativeThreadLoop(JNIEnv*, jobject /* thiz */, jint ipc_socket, jint fd_passing_socket)
|
||||
{
|
||||
dbgln("New binding received, sockets {} and {}", ipc_socket, fd_passing_socket);
|
||||
auto ret = web_content_main(ipc_socket, fd_passing_socket);
|
||||
if (ret.is_error()) {
|
||||
warnln("Runtime Error: {}", ret.release_error());
|
||||
} else {
|
||||
outln("Thread exited with code {}", ret.release_value());
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_org_serenityos_ladybird_WebContentService_initNativeCode(JNIEnv* env, jobject /* thiz */, jstring resource_dir, jstring tag_name)
|
||||
{
|
||||
static Atomic<bool> s_initialized_flag { false };
|
||||
if (s_initialized_flag.exchange(true) == true) {
|
||||
// Skip initializing if someone else already started the process at some point in the past
|
||||
return;
|
||||
}
|
||||
|
||||
char const* raw_resource_dir = env->GetStringUTFChars(resource_dir, nullptr);
|
||||
s_serenity_resource_root = raw_resource_dir;
|
||||
env->ReleaseStringUTFChars(resource_dir, raw_resource_dir);
|
||||
|
||||
char const* raw_tag_name = env->GetStringUTFChars(tag_name, nullptr);
|
||||
AK::set_log_tag_name(raw_tag_name);
|
||||
env->ReleaseStringUTFChars(tag_name, raw_tag_name);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue