move page registration logic in to jsinspector

Reviewed By: pakoito

Differential Revision: D6531199

fbshipit-source-id: ed1ae9e2f0c19e7656cd022e438693798320e55a
This commit is contained in:
Ben Nham
2017-12-15 09:10:47 -08:00
committed by Facebook Github Bot
parent 48019a0c2a
commit bef7967f9a
10 changed files with 147 additions and 39 deletions

View File

@@ -215,11 +215,12 @@ namespace facebook {
const std::string ownerId = m_jscConfig.getDefault("OwnerIdentity", "unknown").getString();
const std::string appId = m_jscConfig.getDefault("AppIdentity", "unknown").getString();
const std::string deviceId = m_jscConfig.getDefault("DeviceIdentity", "unknown").getString();
const std::function<bool()> checkIsInspectedRemote = [&](){
auto checkIsInspectedRemote = [ownerId, appId, deviceId]() {
return isNetworkInspected(ownerId, appId, deviceId);
};
IInspector* pInspector = JSC_JSInspectorGetInstance(true);
pInspector->registerGlobalContext(ownerId, checkIsInspectedRemote, m_context);
auto& globalInspector = facebook::react::getInspectorInstance();
JSC_JSGlobalContextEnableDebugger(m_context, globalInspector, ownerId.c_str(), checkIsInspectedRemote);
}
installNativeHook<&JSCExecutor::nativeFlushQueueImmediate>("nativeFlushQueueImmediate");
@@ -340,8 +341,8 @@ namespace facebook {
m_nativeModules.reset();
if (canUseInspector(context)) {
IInspector* pInspector = JSC_JSInspectorGetInstance(true);
pInspector->unregisterGlobalContext(context);
auto &globalInspector = facebook::react::getInspectorInstance();
JSC_JSGlobalContextDisableDebugger(context, globalInspector);
}
JSC_JSGlobalContextRelease(context);