make the CREATE_MODULE marker actually end

Reviewed By: fkgozali

Differential Revision: D5024378

fbshipit-source-id: 6f25ecd15e25a6d9aabaa52013c2abe24a3f8fb9
This commit is contained in:
Aaron Chiu 2017-05-11 19:50:00 -07:00 committed by Facebook Github Bot
parent 2fbe3b799e
commit c7317c5e61
2 changed files with 31 additions and 6 deletions

View File

@ -5,6 +5,8 @@ package com.facebook.react.bridge;
import javax.annotation.Nullable;
import javax.inject.Provider;
import java.util.concurrent.atomic.AtomicInteger;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactMarker;
@ -30,6 +32,8 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
@DoNotStrip
public class ModuleHolder {
private static final AtomicInteger sInstanceKeyCounter = new AtomicInteger(1);
private final String mName;
private final boolean mCanOverrideExistingModule;
private final boolean mHasConstants;
@ -96,7 +100,8 @@ public class ModuleHolder {
private NativeModule create() {
SoftAssertions.assertCondition(mModule == null, "Creating an already created module.");
ReactMarker.logMarker(CREATE_MODULE_START, mName);
int instanceKey = sInstanceKeyCounter.getAndIncrement();
ReactMarker.logMarker(CREATE_MODULE_START, mName, instanceKey);
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule")
.arg("name", mName)
.flush();
@ -110,7 +115,7 @@ public class ModuleHolder {
}
} finally {
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(CREATE_MODULE_END);
ReactMarker.logMarker(CREATE_MODULE_END, instanceKey);
}
return module;
}

View File

@ -14,7 +14,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
public class ReactMarker {
public interface MarkerListener {
void logMarker(ReactMarkerConstants name, @Nullable String tag);
void logMarker(ReactMarkerConstants name, @Nullable String tag, int instanceKey);
};
private static @Nullable MarkerListener sMarkerListener = null;
@ -35,22 +35,42 @@ public class ReactMarker {
logMarker(name, null);
}
@DoNotStrip
public static void logMarker(String name, int instanceKey) {
logMarker(name, null, instanceKey);
}
@DoNotStrip
public static void logMarker(String name, @Nullable String tag) {
logMarker(name, tag, 0);
}
@DoNotStrip
public static void logMarker(String name, @Nullable String tag, int instanceKey) {
if (sMarkerListener != null) {
sMarkerListener.logMarker(ReactMarkerConstants.valueOf(name), tag);
sMarkerListener.logMarker(ReactMarkerConstants.valueOf(name), tag, instanceKey);
}
}
@DoNotStrip
public static void logMarker(ReactMarkerConstants name) {
logMarker(name, null);
logMarker(name, null, 0);
}
@DoNotStrip
public static void logMarker(ReactMarkerConstants name, int instanceKey) {
logMarker(name, null, instanceKey);
}
@DoNotStrip
public static void logMarker(ReactMarkerConstants name, @Nullable String tag) {
logMarker(name, null, 0);
}
@DoNotStrip
public static void logMarker(ReactMarkerConstants name, @Nullable String tag, int instanceKey) {
if (sMarkerListener != null) {
sMarkerListener.logMarker(name, tag);
sMarkerListener.logMarker(name, tag, instanceKey);
}
}
}