Move thread jump for js loading into NativeToJSBridge, out of platform code

Reviewed By: javache

Differential Revision: D3906009

fbshipit-source-id: b9782a6c209e3c1626899dac7fd50233cdef87f3
This commit is contained in:
Marc Horowitz
2016-09-26 16:14:10 -07:00
committed by Facebook Github Bot 7
parent 72e203bf95
commit 971cda8794
6 changed files with 28 additions and 62 deletions
+6 -9
View File
@@ -118,12 +118,6 @@ NativeToJsBridge::~NativeToJsBridge() {
"NativeToJsBridge::destroy() must be called before deallocating the NativeToJsBridge!";
}
void NativeToJsBridge::loadApplicationScript(std::unique_ptr<const JSBigString> script,
std::string sourceURL) {
// TODO(t11144533): Add assert that we are on the correct thread
m_mainExecutor->loadApplicationScript(std::move(script), std::move(sourceURL));
}
void NativeToJsBridge::loadOptimizedApplicationScript(
std::string bundlePath,
std::string sourceURL,
@@ -138,18 +132,21 @@ void NativeToJsBridge::loadOptimizedApplicationScript(
});
}
void NativeToJsBridge::loadApplicationUnbundle(
void NativeToJsBridge::loadApplication(
std::unique_ptr<JSModulesUnbundle> unbundle,
std::unique_ptr<const JSBigString> startupScript,
std::string startupScriptSourceURL) {
runOnExecutorQueue(
m_mainExecutorToken,
[unbundle=folly::makeMoveWrapper(std::move(unbundle)),
[unbundleWrap=folly::makeMoveWrapper(std::move(unbundle)),
startupScript=folly::makeMoveWrapper(std::move(startupScript)),
startupScriptSourceURL=std::move(startupScriptSourceURL)]
(JSExecutor* executor) mutable {
executor->setJSModulesUnbundle(unbundle.move());
auto unbundle = unbundleWrap.move();
if (unbundle) {
executor->setJSModulesUnbundle(std::move(unbundle));
}
executor->loadApplicationScript(std::move(*startupScript),
std::move(startupScriptSourceURL));
});