Skip to content

Commit

Permalink
Use JSCExecutor to manage loading js script in JSContext
Browse files Browse the repository at this point in the history
Reviewed By: jaegs

Differential Revision: D4021624

fbshipit-source-id: 8e46052ad246e842a88715d55059a233196a4a6b
  • Loading branch information
bnham authored and Facebook Github Bot committed Oct 31, 2016
1 parent 34c7e76 commit c089761
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions ReactAndroid/src/main/jni/xreact/jni/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SUPPORTED_PLATFORMS = '^android-(armv7|x86)$'

EXPORTED_HEADERS = [
'CxxModuleWrapper.h',
'JSLoader.h',
'NativeArray.h',
'NativeCommon.h',
'NativeMap.h',
Expand Down
2 changes: 2 additions & 0 deletions ReactAndroid/src/main/jni/xreact/jni/JSLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ std::unique_ptr<const JSBigString> loadScriptFromAssets(const std::string& asset
return loadScriptFromAssets(AAssetManager_fromJava(env, assetManager), assetName);
}

__attribute__((visibility("default")))
AAssetManager *extractAssetManager(jobject jassetManager) {
auto env = jni::Environment::current();
return AAssetManager_fromJava(env, jassetManager);
}

__attribute__((visibility("default")))
std::unique_ptr<const JSBigString> loadScriptFromAssets(
AAssetManager *manager,
const std::string& assetName) {
Expand Down
9 changes: 6 additions & 3 deletions ReactCommon/cxxreact/JSCExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ JSCExecutor::JSCExecutor(std::shared_ptr<ExecutorDelegate> delegate,
m_delegate(delegate),
m_deviceCacheDir(cacheDir),
m_messageQueueThread(messageQueueThread),
m_nativeModules(delegate->getModuleRegistry()),
m_nativeModules(delegate ? delegate->getModuleRegistry() : nullptr),
m_jscConfig(jscConfig) {
initOnJSVMThread();

Expand Down Expand Up @@ -362,9 +362,12 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip

String jsSourceURL(sourceURL.c_str());
evaluateScript(m_context, jsScript, jsSourceURL);
bindBridge();

flush();
// TODO(luk): t13903306 Remove this check once we make native modules working for java2js
if (m_delegate) {
bindBridge();
flush();
}
ReactMarker::logMarker("CREATE_REACT_CONTEXT_END");
ReactMarker::logMarker("RUN_JS_BUNDLE_END");
}
Expand Down
6 changes: 4 additions & 2 deletions ReactCommon/cxxreact/JSCExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ namespace react {

class MessageQueueThread;

class JSCExecutorFactory : public JSExecutorFactory {
#define RN_JSC_EXECUTOR_EXPORT __attribute__((visibility("default")))

class RN_JSC_EXECUTOR_EXPORT JSCExecutorFactory : public JSExecutorFactory {
public:
JSCExecutorFactory(const std::string& cacheDir, const folly::dynamic& jscConfig) :
m_cacheDir(cacheDir),
Expand All @@ -46,7 +48,7 @@ class WorkerRegistration : public noncopyable {
Object jsObj;
};

class JSCExecutor : public JSExecutor {
class RN_JSC_EXECUTOR_EXPORT JSCExecutor : public JSExecutor {
public:
/**
* Must be invoked from thread this Executor will run on.
Expand Down

0 comments on commit c089761

Please sign in to comment.