add a way to call QPL.markerTag()
Reviewed By: mhorowitz Differential Revision: D4564193 fbshipit-source-id: a63262eeb62c2945249e7021a59da0ff5df44918
This commit is contained in:
parent
93a263d874
commit
dc0df40770
|
@ -37,6 +37,12 @@ class JObjectWrapper<jqpl> : public JObjectWrapper<jobject> {
|
|||
markerEndMethod(this_, markerId, instanceKey, actionId, timestamp);
|
||||
}
|
||||
|
||||
void markerTag(int markerId, int instanceKey, alias_ref<jstring> tag) {
|
||||
static auto markerTagMethod =
|
||||
qplClass()->getMethod<void(jint, jint, alias_ref<jstring>)>("markerTag");
|
||||
markerTagMethod(this_, markerId, instanceKey, tag);
|
||||
}
|
||||
|
||||
void markerNote(int markerId, int instanceKey, short actionId, long timestamp) {
|
||||
static auto markerNoteMethod =
|
||||
qplClass()->getMethod<void(jint, jint, jshort, jlong)>("markerNote");
|
||||
|
@ -146,6 +152,15 @@ static bool grabDoubles(
|
|||
return true;
|
||||
}
|
||||
|
||||
static local_ref<jstring> getJStringFromJSValueRef(JSContextRef ctx, JSValueRef ref) {
|
||||
JSStringRef jsStringRef = JSValueToStringCopy(ctx, ref, nullptr);
|
||||
const JSChar* chars = JSStringGetCharactersPtr(jsStringRef);
|
||||
const size_t length = JSStringGetLength(jsStringRef);
|
||||
local_ref<jstring> returnStr = adopt_local(Environment::current()->NewString(chars, length));
|
||||
JSStringRelease(jsStringRef);
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
static JSValueRef nativeQPLMarkerStart(
|
||||
JSContextRef ctx,
|
||||
JSObjectRef function,
|
||||
|
@ -181,6 +196,23 @@ static JSValueRef nativeQPLMarkerEnd(
|
|||
return JSValueMakeUndefined(ctx);
|
||||
}
|
||||
|
||||
static JSValueRef nativeQPLMarkerTag(
|
||||
JSContextRef ctx,
|
||||
JSObjectRef function,
|
||||
JSObjectRef thisObject,
|
||||
size_t argumentCount,
|
||||
const JSValueRef arguments[],
|
||||
JSValueRef* exception) {
|
||||
double targets[2];
|
||||
if (isReady() && grabDoubles(2, targets, ctx, argumentCount, arguments, exception)) {
|
||||
int32_t markerId = (int32_t) targets[0];
|
||||
int32_t instanceKey = (int32_t) targets[1];
|
||||
local_ref<jstring> tag = getJStringFromJSValueRef(ctx, arguments[2]);
|
||||
JQuickPerformanceLoggerProvider::get()->markerTag(markerId, instanceKey, tag);
|
||||
}
|
||||
return JSValueMakeUndefined(ctx);
|
||||
}
|
||||
|
||||
static JSValueRef nativeQPLMarkerNote(
|
||||
JSContextRef ctx,
|
||||
JSObjectRef function,
|
||||
|
@ -236,6 +268,7 @@ namespace react {
|
|||
void addNativePerfLoggingHooks(JSGlobalContextRef ctx) {
|
||||
installGlobalFunction(ctx, "nativeQPLMarkerStart", nativeQPLMarkerStart);
|
||||
installGlobalFunction(ctx, "nativeQPLMarkerEnd", nativeQPLMarkerEnd);
|
||||
installGlobalFunction(ctx, "nativeQPLMarkerTag", nativeQPLMarkerTag);
|
||||
installGlobalFunction(ctx, "nativeQPLMarkerNote", nativeQPLMarkerNote);
|
||||
installGlobalFunction(ctx, "nativeQPLMarkerCancel", nativeQPLMarkerCancel);
|
||||
installGlobalFunction(ctx, "nativeQPLTimestamp", nativeQPLTimestamp);
|
||||
|
|
Loading…
Reference in New Issue