mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 22:38:59 +08:00
Make JavaScriptExecutor.Factory a configurable property of ReactInstanceManager
Reviewed By: mhorowitz Differential Revision: D5662431 fbshipit-source-id: 17dca2744de645740cef252efbf83902acde5046
This commit is contained in:
committed by
Facebook Github Bot
parent
606a876df7
commit
73f17908e6
@@ -43,9 +43,9 @@ import com.facebook.infer.annotation.ThreadSafe;
|
||||
import com.facebook.react.bridge.CatalystInstance;
|
||||
import com.facebook.react.bridge.CatalystInstanceImpl;
|
||||
import com.facebook.react.bridge.JSBundleLoader;
|
||||
import com.facebook.react.bridge.JSCJavaScriptExecutor;
|
||||
import com.facebook.react.bridge.JavaJSExecutor;
|
||||
import com.facebook.react.bridge.JavaScriptExecutor;
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
||||
import com.facebook.react.bridge.NativeArray;
|
||||
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
|
||||
import com.facebook.react.bridge.NativeModuleRegistry;
|
||||
@@ -127,7 +127,8 @@ public class ReactInstanceManager {
|
||||
private volatile @Nullable Thread mCreateReactContextThread;
|
||||
|
||||
/* accessed from any thread */
|
||||
private final @Nullable JSBundleLoader mBundleLoader; /* path to JS bundle on file system */
|
||||
private final JavaScriptExecutorFactory mJavaScriptExecutorFactory;
|
||||
private final @Nullable JSBundleLoader mBundleLoader;
|
||||
private final @Nullable String mJSMainModulePath; /* path to JS bundle root on packager server */
|
||||
private final List<ReactPackage> mPackages;
|
||||
private final List<CatalystInstanceImpl.PendingJSCall> mInitFunctions;
|
||||
@@ -178,17 +179,17 @@ public class ReactInstanceManager {
|
||||
};
|
||||
|
||||
private class ReactContextInitParams {
|
||||
private final JavaScriptExecutor.Factory mJsExecutorFactory;
|
||||
private final JavaScriptExecutorFactory mJsExecutorFactory;
|
||||
private final JSBundleLoader mJsBundleLoader;
|
||||
|
||||
public ReactContextInitParams(
|
||||
JavaScriptExecutor.Factory jsExecutorFactory,
|
||||
JavaScriptExecutorFactory jsExecutorFactory,
|
||||
JSBundleLoader jsBundleLoader) {
|
||||
mJsExecutorFactory = Assertions.assertNotNull(jsExecutorFactory);
|
||||
mJsBundleLoader = Assertions.assertNotNull(jsBundleLoader);
|
||||
}
|
||||
|
||||
public JavaScriptExecutor.Factory getJsExecutorFactory() {
|
||||
public JavaScriptExecutorFactory getJsExecutorFactory() {
|
||||
return mJsExecutorFactory;
|
||||
}
|
||||
|
||||
@@ -208,6 +209,7 @@ public class ReactInstanceManager {
|
||||
Context applicationContext,
|
||||
@Nullable Activity currentActivity,
|
||||
@Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
|
||||
JavaScriptExecutorFactory javaScriptExecutorFactory,
|
||||
@Nullable JSBundleLoader bundleLoader,
|
||||
@Nullable String jsMainModulePath,
|
||||
List<ReactPackage> packages,
|
||||
@@ -233,6 +235,7 @@ public class ReactInstanceManager {
|
||||
mApplicationContext = applicationContext;
|
||||
mCurrentActivity = currentActivity;
|
||||
mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
|
||||
mJavaScriptExecutorFactory = javaScriptExecutorFactory;
|
||||
mBundleLoader = bundleLoader;
|
||||
mJSMainModulePath = jsMainModulePath;
|
||||
mPackages = new ArrayList<>();
|
||||
@@ -444,7 +447,7 @@ public class ReactInstanceManager {
|
||||
Log.d(
|
||||
ReactConstants.TAG,
|
||||
"ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()");
|
||||
recreateReactContextInBackground(new JSCJavaScriptExecutor.Factory(), mBundleLoader);
|
||||
recreateReactContextInBackground(mJavaScriptExecutorFactory, mBundleLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -790,14 +793,14 @@ public class ReactInstanceManager {
|
||||
private void onJSBundleLoadedFromServer() {
|
||||
Log.d(ReactConstants.TAG, "ReactInstanceManager.onJSBundleLoadedFromServer()");
|
||||
recreateReactContextInBackground(
|
||||
new JSCJavaScriptExecutor.Factory(),
|
||||
mJavaScriptExecutorFactory,
|
||||
JSBundleLoader.createCachedBundleFromNetworkLoader(
|
||||
mDevSupportManager.getSourceUrl(), mDevSupportManager.getDownloadedJSBundleFile()));
|
||||
}
|
||||
|
||||
@ThreadConfined(UI)
|
||||
private void recreateReactContextInBackground(
|
||||
JavaScriptExecutor.Factory jsExecutorFactory,
|
||||
JavaScriptExecutorFactory jsExecutorFactory,
|
||||
JSBundleLoader jsBundleLoader) {
|
||||
Log.d(ReactConstants.TAG, "ReactInstanceManager.recreateReactContextInBackground()");
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
Reference in New Issue
Block a user