MCPcopy Create free account
hub / github.com/Kudo/react-native-v8 / V8ExecutorHolder

Class V8ExecutorHolder

android/src/main/cpp/OnLoad.cpp:57–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57class V8ExecutorHolder
58 : public jni::
59 HybridClass<V8ExecutorHolder, react::JavaScriptExecutorHolder> {
60 public:
61 static constexpr auto kJavaDescriptor =
62 "Lio/csie/kudo/reactnative/v8/executor/V8Executor;";
63
64 static jni::local_ref<jhybriddata> initHybrid(
65 jni::alias_ref<jclass>,
66 jni::alias_ref<react::JAssetManager::javaobject> assetManager,
67 const std::string &timezoneId,
68 bool enableInspector,
69 const std::string &appName,
70 const std::string &deviceName,
71 const std::string &snapshotBlobPath,
72 int codecacheMode,
73 const std::string &codecacheDir) {
74 react::JReactMarker::setLogPerfMarkerIfNeeded();
75
76 auto config = std::make_unique<V8RuntimeConfig>();
77 config->timezoneId = timezoneId;
78 config->enableInspector = enableInspector;
79 config->appName = appName;
80 config->deviceName = deviceName;
81 if (!snapshotBlobPath.empty()) {
82 config->snapshotBlob =
83 std::move(loadBlob(assetManager, snapshotBlobPath));
84 }
85 config->codecacheMode =
86 static_cast<V8RuntimeConfig::CodecacheMode>(codecacheMode);
87 config->codecacheDir = codecacheDir;
88
89 return makeCxxInstance(folly::make_unique<V8ExecutorFactory>(
90 installBindings,
91 react::JSIExecutor::defaultTimeoutInvoker,
92 std::move(config)));
93 }
94
95 static void onMainLoopIdle(
96 jni::alias_ref<jclass>,
97 jni::alias_ref<facebook::react::JRuntimeExecutor::javaobject>
98 runtimeExecutor) {
99 runtimeExecutor->cthis()->get()([](jsi::Runtime &runtime) {
100 auto v8Runtime = dynamic_cast<V8Runtime *>(&runtime);
101 if (v8Runtime) {
102 v8Runtime->OnMainLoopIdle();
103 }
104 });
105 }
106
107 static void registerNatives() {
108 registerHybrid({
109 makeNativeMethod("initHybrid", V8ExecutorHolder::initHybrid),
110 makeNativeMethod("onMainLoopIdle", V8ExecutorHolder::onMainLoopIdle),
111 });
112 }
113
114 private:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected