RN trigger heap capture from js1

Differential Revision: D4397603

fbshipit-source-id: 566cfad9ce47bcc8cddb9219ed9f6a427ce19f84
This commit is contained in:
Charles Dick 2017-01-10 07:03:30 -08:00 committed by Facebook Github Bot
parent 9724eaeb42
commit 64f394a99b
2 changed files with 24 additions and 5 deletions

View File

@ -83,6 +83,7 @@ public class DevServerHelper {
public interface PackagerCommandListener {
void onPackagerReloadCommand();
void onCaptureHeapCommand();
}
public interface PackagerStatusCallback {
@ -123,8 +124,12 @@ public class DevServerHelper {
new JSPackagerWebSocketClient.JSPackagerCallback() {
@Override
public void onMessage(String target, String action) {
if (commandListener != null && "bridge".equals(target) && "reload".equals(action)) {
commandListener.onPackagerReloadCommand();
if (commandListener != null && "bridge".equals(target)) {
if ("reload".equals(action)) {
commandListener.onPackagerReloadCommand();
} else if ("captureHeap".equals(action)) {
commandListener.onCaptureHeapCommand();
}
}
}
});

View File

@ -417,9 +417,7 @@ public class DevSupportManagerImpl implements DevSupportManager, PackagerCommand
new DevOptionHandler() {
@Override
public void onOptionSelected() {
JSCHeapCapture.captureHeap(
mApplicationContext.getCacheDir().getPath(),
JSCHeapUpload.captureCallback(mDevServerHelper.getHeapCaptureUploadUrl()));
handleCaptureHeap();
}
});
options.put(
@ -691,6 +689,22 @@ public class DevSupportManagerImpl implements DevSupportManager, PackagerCommand
});
}
@Override
public void onCaptureHeapCommand() {
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
handleCaptureHeap();
}
});
}
private void handleCaptureHeap() {
JSCHeapCapture.captureHeap(
mApplicationContext.getCacheDir().getPath(),
JSCHeapUpload.captureCallback(mDevServerHelper.getHeapCaptureUploadUrl()));
}
private void updateLastErrorInfo(
final String message,
final StackFrame[] stack,