set JS profiling global to true, fix to parsing of strings with ascii value >=128

Reviewed By: @mkonicek

Differential Revision: D2512320

fb-gh-sync-id: 098727cd664f0f0cdb0092875a9934a5d7b577f2
This commit is contained in:
Mike Armstrong 2015-10-06 09:09:19 -07:00 коммит произвёл facebook-github-bot-4
Родитель b5890e1283
Коммит 5d682d65f6
2 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -28,6 +28,7 @@ import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.infer.annotation.Assertions;
import com.facebook.systrace.Systrace;
import com.facebook.systrace.TraceListener;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
@ -60,6 +61,7 @@ public class CatalystInstance {
// Access from JS thread
private @Nullable ReactBridge mBridge;
private @Nullable JavaScriptModuleRegistry mJSModuleRegistry;
private @Nullable TraceListener mTraceListener;
private CatalystInstance(
final CatalystQueueConfigurationSpec catalystQueueConfigurationSpec,
@ -119,6 +121,45 @@ public class CatalystInstance {
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
mTraceListener = new 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");
}
});
}
@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");
}
});
}
};
Systrace.registerListener(mTraceListener);
}
/* package */ void callFunction(
@ -207,6 +248,10 @@ public class CatalystInstance {
}
}
if (mTraceListener != null) {
Systrace.unregisterListener(mTraceListener);
}
// We can access the Bridge from any thread now because we know either we are on the JS thread
// or the JS thread has finished via CatalystQueueConfiguration#destroy()
Assertions.assertNotNull(mBridge).dispose();

Просмотреть файл

@ -60,6 +60,10 @@ public class ReactBridge extends Countable {
JavaScriptExecutor jsExecutor,
ReactCallback callback,
MessageQueueThread nativeModulesQueueThread);
/**
* All native functions are not thread safe and appropriate queues should be used
*/
public native void loadScriptFromAssets(AssetManager assetManager, String assetName);
public native void loadScriptFromNetworkCached(String sourceURL, @Nullable String tempFileName);
public native void callFunction(int moduleId, int methodId, NativeArray arguments);