`JSBundleLoader`: allow to load with delta client

Summary: Adds glue between `CatalystInstance` and `JSBundleLoader`: Adds the possibility to create a `JSBundleLoader` instance that calls into `CatalystInstanceImpl#loadScriptFromDeltaBundle(...)`.

Reviewed By: fromcelticpark

Differential Revision: D7845134

fbshipit-source-id: 9585b44a6e7c63245c9f634543642be55c928896
This commit is contained in:
David Aurelio 2018-05-03 08:38:11 -07:00 коммит произвёл Facebook Github Bot
Родитель 3e730528ee
Коммит 8f85abdb14
1 изменённых файлов: 23 добавлений и 0 удалений

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

@ -8,6 +8,7 @@
package com.facebook.react.bridge;
import android.content.Context;
import com.facebook.react.bridge.NativeDeltaClient;
import com.facebook.react.common.DebugServerException;
/**
@ -78,6 +79,28 @@ public abstract class JSBundleLoader {
};
}
/**
* This loader is used to load delta bundles from the dev server. We pass each delta message to
* the loader and process it in C++. Passing it as a string leads to inefficiencies due to memory
* copies, which will have to be addressed in a follow-up.
* @param nativeDeltaClient
*/
public static JSBundleLoader createDeltaFromNetworkLoader(
final String sourceURL,
final NativeDeltaClient nativeDeltaClient) {
return new JSBundleLoader() {
@Override
public String loadScript(CatalystInstanceImpl instance) {
try {
instance.loadScriptFromDeltaBundle(sourceURL, nativeDeltaClient, false);
return sourceURL;
} catch (Exception e) {
throw DebugServerException.makeGeneric(e.getMessage(), e);
}
}
};
}
/**
* This loader is used when proxy debugging is enabled. In that case there is no point in fetching
* the bundle from device as remote executor will have to do it anyway.