Permalink
Browse files

replace string comparison with enum

Summary:
This change change the interface of reactmarker to use enum type and ReactMarker would still support logMarker(string, string) with addtional support for logMarker(ReactMarkerConstants, string).
Also moved some markers into the enum.

Reviewed By: fkgozali

Differential Revision: D4773600

fbshipit-source-id: 336ba79bb9514d3146bdda177861743ae51424ab
  • Loading branch information...
BruinBear authored and facebook-github-bot committed Mar 28, 2017
1 parent 4bf2d8c commit 63035a4c083807efce3ad0bb08e318811fa7558b
@@ -13,7 +13,7 @@
public class ReactMarker {
public interface MarkerListener {
void logMarker(String name, @Nullable String tag);
void logMarker(ReactMarkerConstants name, @Nullable String tag);
};
private static @Nullable MarkerListener sMarkerListener = null;
@@ -31,7 +31,19 @@ public static void logMarker(String name) {
}
@DoNotStrip
public static void logMarker(String name, String tag) {
public static void logMarker(String name, @Nullable String tag) {
if (sMarkerListener != null) {
sMarkerListener.logMarker(ReactMarkerConstants.valueOf(name), tag);
}
}
@DoNotStrip
public static void logMarker(ReactMarkerConstants name) {
logMarker(name, null);
}
@DoNotStrip
public static void logMarker(ReactMarkerConstants name, @Nullable String tag) {
if (sMarkerListener != null) {
sMarkerListener.logMarker(name, tag);
}
@@ -5,69 +5,62 @@
/**
* Constants used by ReactMarker.
*/
public class ReactMarkerConstants {
// TODO convert to ints so we don't have to do String compares
public static final String CREATE_REACT_CONTEXT_START = "CREATE_REACT_CONTEXT_START";
public static final String CREATE_REACT_CONTEXT_END = "CREATE_REACT_CONTEXT_END";
public static final String PROCESS_PACKAGES_START = "PROCESS_PACKAGES_START";
public static final String PROCESS_PACKAGES_END = "PROCESS_PACKAGES_END";
public static final String BUILD_NATIVE_MODULE_REGISTRY_START =
"BUILD_NATIVE_MODULE_REGISTRY_START";
public static final String BUILD_NATIVE_MODULE_REGISTRY_END =
"BUILD_NATIVE_MODULE_REGISTRY_END";
public static final String BUILD_JS_MODULE_CONFIG_START = "BUILD_JS_MODULE_CONFIG_START";
public static final String BUILD_JS_MODULE_CONFIG_END = "BUILD_JS_MODULE_CONFIG_END";
public static final String CREATE_CATALYST_INSTANCE_START = "CREATE_CATALYST_INSTANCE_START";
public static final String CREATE_CATALYST_INSTANCE_END = "CREATE_CATALYST_INSTANCE_END";
public static final String RUN_JS_BUNDLE_START = "RUN_JS_BUNDLE_START";
public static final String RUN_JS_BUNDLE_END = "RUN_JS_BUNDLE_END";
public static final String NATIVE_MODULE_INITIALIZE_START = "NativeModule_start";
public static final String NATIVE_MODULE_INITIALIZE_END = "NativeModule_end";
public static final String SETUP_REACT_CONTEXT_START = "SETUP_REACT_CONTEXT_START";
public static final String SETUP_REACT_CONTEXT_END = "SETUP_REACT_CONTEXT_END";
public static final String CREATE_UI_MANAGER_MODULE_START = "CREATE_UI_MANAGER_MODULE_START";
public static final String CREATE_UI_MANAGER_MODULE_END = "CREATE_UI_MANAGER_MODULE_END";
public static final String CREATE_VIEW_MANAGERS_START = "CREATE_VIEW_MANAGERS_START";
public static final String CREATE_VIEW_MANAGERS_END = "CREATE_VIEW_MANAGERS_END";
public static final String CREATE_UI_MANAGER_MODULE_CONSTANTS_START =
"CREATE_UI_MANAGER_MODULE_CONSTANTS_START";
public static final String CREATE_UI_MANAGER_MODULE_CONSTANTS_END =
"CREATE_UI_MANAGER_MODULE_CONSTANTS_END";
public static final String CREATE_MODULE_START = "CREATE_MODULE_START";
public static final String CREATE_MODULE_END = "CREATE_MODULE_END";
public static final String PROCESS_CORE_REACT_PACKAGE_START = "PROCESS_CORE_REACT_PACKAGE_START";
public static final String PROCESS_CORE_REACT_PACKAGE_END = "PROCESS_CORE_REACT_PACKAGE_END";
public static final String CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START =
"CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START";
public static final String CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END =
"CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END";
public static final String UI_MANAGER_MODULE_CONSTANTS_CONVERT_START =
"UI_MANAGER_MODULE_CONSTANTS_CONVERT_START";
public static final String UI_MANAGER_MODULE_CONSTANTS_CONVERT_END =
"UI_MANAGER_MODULE_CONSTANTS_CONVERT_END";
public static final String CREATE_I18N_MODULE_CONSTANTS_START =
"CREATE_I18N_MODULE_CONSTANTS_START";
public static final String CREATE_I18N_MODULE_CONSTANTS_END =
"CREATE_I18N_MODULE_CONSTANTS_END";
public static final String I18N_MODULE_CONSTANTS_CONVERT_START =
"I18N_MODULE_CONSTANTS_CONVERT_START";
public static final String I18N_MODULE_CONSTANTS_CONVERT_END =
"I18N_MODULE_CONSTANTS_CONVERT_END";
public static final String CREATE_I18N_ASSETS_MODULE_START =
"CREATE_I18N_ASSETS_MODULE_START";
public static final String CREATE_I18N_ASSETS_MODULE_END =
"CREATE_I18N_ASSETS_MODULE_END";
public static final String GET_CONSTANTS_START = "GET_CONSTANTS_START";
public static final String GET_CONSTANTS_END = "GET_CONSTANTS_END";
public static final String INITIALIZE_MODULE_START = "INITIALIZE_MODULE_START";
public static final String INITIALIZE_MODULE_END = "INITIALIZE_MODULE_END";
public static final String ON_HOST_RESUME_START = "ON_HOST_RESUME_START";
public static final String ON_HOST_RESUME_END = "ON_HOST_RESUME_END";
public static final String ON_HOST_PAUSE_START = "ON_HOST_PAUSE_START";
public static final String ON_HOST_PAUSE_END = "ON_HOST_PAUSE_END";
public static final String CONVERT_CONSTANTS_START = "CONVERT_CONSTANTS_START";
public static final String CONVERT_CONSTANTS_END = "CONVERT_CONSTANTS_END";
public static final String PRE_SETUP_REACT_CONTEXT_START = "PRE_SETUP_REACT_CONTEXT_START";
public static final String PRE_SETUP_REACT_CONTEXT_END = "PRE_SETUP_REACT_CONTEXT_END";
public enum ReactMarkerConstants {
CREATE_REACT_CONTEXT_START,
CREATE_REACT_CONTEXT_END,
PROCESS_PACKAGES_START,
PROCESS_PACKAGES_END,
BUILD_NATIVE_MODULE_REGISTRY_START,
BUILD_NATIVE_MODULE_REGISTRY_END,
BUILD_JS_MODULE_CONFIG_START,
BUILD_JS_MODULE_CONFIG_END,
CREATE_CATALYST_INSTANCE_START,
CREATE_CATALYST_INSTANCE_END,
RUN_JS_BUNDLE_START,
RUN_JS_BUNDLE_END,
NATIVE_MODULE_INITIALIZE_START,
NATIVE_MODULE_INITIALIZE_END,
SETUP_REACT_CONTEXT_START,
SETUP_REACT_CONTEXT_END,
CREATE_UI_MANAGER_MODULE_START,
CREATE_UI_MANAGER_MODULE_END,
CREATE_VIEW_MANAGERS_START,
CREATE_VIEW_MANAGERS_END,
CREATE_UI_MANAGER_MODULE_CONSTANTS_START,
CREATE_UI_MANAGER_MODULE_CONSTANTS_END,
CREATE_MODULE_START,
CREATE_MODULE_END,
PROCESS_CORE_REACT_PACKAGE_START,
PROCESS_CORE_REACT_PACKAGE_END,
CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START,
CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END,
UI_MANAGER_MODULE_CONSTANTS_CONVERT_START,
UI_MANAGER_MODULE_CONSTANTS_CONVERT_END,
CREATE_I18N_MODULE_CONSTANTS_START,
CREATE_I18N_MODULE_CONSTANTS_END,
I18N_MODULE_CONSTANTS_CONVERT_START,
I18N_MODULE_CONSTANTS_CONVERT_END,
CREATE_I18N_ASSETS_MODULE_START,
CREATE_I18N_ASSETS_MODULE_END,
GET_CONSTANTS_START,
GET_CONSTANTS_END,
INITIALIZE_MODULE_START,
INITIALIZE_MODULE_END,
ON_HOST_RESUME_START,
ON_HOST_RESUME_END,
ON_HOST_PAUSE_START,
ON_HOST_PAUSE_END,
CONVERT_CONSTANTS_START,
CONVERT_CONSTANTS_END,
PRE_REACT_CONTEXT_END,
UNPACKER_CHECK_START,
UNPACKER_CHECK_END,
UNPACKER_BUNDLE_EXTRACTED,
UNPACKING_JS_BUNDLE_LOADER_CHECK_START,
UNPACKING_JS_BUNDLE_LOADER_CHECK_END,
UNPACKING_JS_BUNDLE_LOADER_EXTRACTED,
loadApplicationScript_startStringConvert,
loadApplicationScript_endStringConvert,
PRE_SETUP_REACT_CONTEXT_START,
PRE_SETUP_REACT_CONTEXT_END,
}

0 comments on commit 63035a4

Please sign in to comment.