mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate TurboModulePerfLogger to Kotlin + internalize it. (#49034)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49034 This class was still in Java. I'm converting it to Kotlin + I'm making it internal. As this class was inside the `com.facebook.react.internal.turbomodule.core` package, we don't consider this a breaking change. Changelog: [Internal] [Changed] - Reviewed By: cipolleschi Differential Revision: D68826892 fbshipit-source-id: b1f7aea984ab333faea66a9e8ccbb1492767333e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e767dc3458
commit
71d39c5cfd
-93
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.internal.turbomodule.core;
|
||||
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.reactperflogger.NativeModulePerfLogger;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
@DoNotStrip
|
||||
class TurboModulePerfLogger {
|
||||
|
||||
@Nullable private static NativeModulePerfLogger sNativeModulePerfLogger = null;
|
||||
|
||||
static {
|
||||
NativeModuleSoLoader.maybeLoadSoLibrary();
|
||||
}
|
||||
|
||||
public static void moduleDataCreateStart(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleDataCreateStart(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleDataCreateEnd(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleDataCreateEnd(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateStart(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateStart(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateCacheHit(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateCacheHit(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateConstructStart(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateConstructStart(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateConstructEnd(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateConstructEnd(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateSetUpStart(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateSetUpStart(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateSetUpEnd(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateSetUpEnd(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateEnd(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateEnd(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void moduleCreateFail(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
sNativeModulePerfLogger.moduleCreateFail(moduleName, id);
|
||||
}
|
||||
}
|
||||
|
||||
private static native void jniEnableCppLogging(NativeModulePerfLogger perfLogger);
|
||||
|
||||
public static void enableLogging(NativeModulePerfLogger perfLogger) {
|
||||
if (perfLogger != null) {
|
||||
sNativeModulePerfLogger = perfLogger;
|
||||
jniEnableCppLogging(perfLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.internal.turbomodule.core
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.internal.turbomodule.core.NativeModuleSoLoader.Companion.maybeLoadSoLibrary
|
||||
import com.facebook.react.reactperflogger.NativeModulePerfLogger
|
||||
|
||||
@DoNotStrip
|
||||
internal object TurboModulePerfLogger {
|
||||
private var nativeModulePerfLogger: NativeModulePerfLogger? = null
|
||||
|
||||
init {
|
||||
maybeLoadSoLibrary()
|
||||
}
|
||||
|
||||
fun moduleDataCreateStart(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleDataCreateStart(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
fun moduleDataCreateEnd(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleDataCreateEnd(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateStart(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateStart(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateCacheHit(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateCacheHit(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateConstructStart(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateConstructStart(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateConstructEnd(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateConstructEnd(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateSetUpStart(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateSetUpStart(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateSetUpEnd(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateSetUpEnd(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateEnd(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateEnd(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun moduleCreateFail(moduleName: String?, id: Int) {
|
||||
nativeModulePerfLogger?.moduleCreateFail(checkNotNull(moduleName), id)
|
||||
}
|
||||
|
||||
@DoNotStrip private external fun jniEnableCppLogging(perfLogger: NativeModulePerfLogger)
|
||||
|
||||
fun enableLogging(perfLogger: NativeModulePerfLogger?) {
|
||||
if (perfLogger != null) {
|
||||
nativeModulePerfLogger = perfLogger
|
||||
jniEnableCppLogging(perfLogger)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user