Enable javascript systrace markers via js module

Differential Revision: D2658662

fb-gh-sync-id: 042377551f9dacc0a9d12728edfa54a57c617cf4
This commit is contained in:
Mike Armstrong 2015-11-16 09:41:05 -08:00 committed by facebook-github-bot-7
parent 2f9e7be04b
commit 619da521f3
3 changed files with 19 additions and 29 deletions

View File

@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.facebook.react.bridge.BridgeProfiling;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
@ -77,6 +78,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
RCTEventEmitter.class,
RCTNativeAppEventEmitter.class,
AppRegistry.class,
BridgeProfiling.class,
ReactNative.class,
DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
}

View File

@ -0,0 +1,14 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
/**
* Interface to the JavaScript BridgeProfiling Module
*/
@DoNotStrip
public interface BridgeProfiling extends JavaScriptModule{
@DoNotStrip
void setEnabled(boolean enabled);
}

View File

@ -66,7 +66,7 @@ public class CatalystInstance {
private @Nullable ReactBridge mBridge;
private boolean mJSBundleHasLoaded;
private CatalystInstance(
private CatalystInstance(
final CatalystQueueConfigurationSpec catalystQueueConfigurationSpec,
final JavaScriptExecutor jsExecutor,
final NativeModuleRegistry registry,
@ -412,38 +412,12 @@ public class CatalystInstance {
private class JSProfilerTraceListener implements TraceListener {
@Override
public void onTraceStarted() {
mCatalystQueueConfiguration.getJSQueueThread().runOnQueue(
new Runnable() {
@Override
public void run() {
mCatalystQueueConfiguration.getJSQueueThread().assertIsOnThread();
if (mDestroyed) {
return;
}
Assertions.assertNotNull(mBridge).setGlobalVariable(
"__BridgeProfilingIsProfiling",
"true");
}
});
getJSModule(BridgeProfiling.class).setEnabled(true);
}
@Override
public void onTraceStopped() {
mCatalystQueueConfiguration.getJSQueueThread().runOnQueue(
new Runnable() {
@Override
public void run() {
mCatalystQueueConfiguration.getJSQueueThread().assertIsOnThread();
if (mDestroyed) {
return;
}
Assertions.assertNotNull(mBridge).setGlobalVariable(
"__BridgeProfilingIsProfiling",
"false");
}
});
getJSModule(BridgeProfiling.class).setEnabled(false);
}
}