Decouple JSBundleLoader from CatalystInstanceImpl

Summary: Right now JSBundleLoader is tightly coupled to CatalystInstanceImpl; this diffs adds an interface, JSBundleLoaderDelegate, that CatalystInstanceImpl implements so that we can use the bundle loader with other classes.

Reviewed By: mdvacca

Differential Revision: D13216752

fbshipit-source-id: fc406ef30f12ed9d3ed13a062dedd7b33f3b7985
This commit is contained in:
Emily Janzer
2018-11-30 16:51:26 -08:00
committed by Facebook Github Bot
parent 668341a294
commit a2ead1c7b5
5 changed files with 82 additions and 31 deletions
@@ -201,17 +201,8 @@ public class CatalystInstanceImpl implements CatalystInstance {
Collection<JavaModuleWrapper> javaModules,
Collection<ModuleHolder> cxxModules);
/**
* This API is used in situations where the JS bundle is being executed not on
* the device, but on a host machine. In that case, we must provide two source
* URLs for the JS bundle: One to be used on the device, and one to be used on
* the remote debugging machine.
*
* @param deviceURL A source URL that is accessible from this device.
* @param remoteURL A source URL that is accessible from the remote machine
* executing the JS.
*/
/* package */ void setSourceURLs(String deviceURL, String remoteURL) {
@Override
public void setSourceURLs(String deviceURL, String remoteURL) {
mSourceURL = deviceURL;
jniSetSourceURL(remoteURL);
}
@@ -221,17 +212,20 @@ public class CatalystInstanceImpl implements CatalystInstance {
jniRegisterSegment(segmentId, path);
}
/* package */ void loadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously) {
@Override
public void loadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously) {
mSourceURL = assetURL;
jniLoadScriptFromAssets(assetManager, assetURL, loadSynchronously);
}
/* package */ void loadScriptFromFile(String fileName, String sourceURL, boolean loadSynchronously) {
@Override
public void loadScriptFromFile(String fileName, String sourceURL, boolean loadSynchronously) {
mSourceURL = sourceURL;
jniLoadScriptFromFile(fileName, sourceURL, loadSynchronously);
}
/* package */ void loadScriptFromDeltaBundle(
@Override
public void loadScriptFromDeltaBundle(
String sourceURL,
NativeDeltaClient deltaClient,
boolean loadSynchronously) {