CatalystInstanceImpl.setSourceURL

Reviewed By: javache

Differential Revision: D4422416

fbshipit-source-id: bc49485ac64064909f32375b6b8360a0a505975b
This commit is contained in:
Ashok Menon
2017-01-18 08:55:46 -08:00
committed by Facebook Github Bot
parent bbd5750bb4
commit 76c4faee5e
6 changed files with 35 additions and 19 deletions

View File

@@ -50,6 +50,14 @@ void Instance::initializeBridge(
CHECK(nativeToJsBridge_);
}
void Instance::setSourceURL(std::string sourceURL) {
callback_->incrementPendingJSCalls();
SystraceSection s("reactbridge_xplat_setSourceURL",
"sourceURL", sourceURL);
nativeToJsBridge_->loadApplication(nullptr, nullptr, std::move(sourceURL));
}
void Instance::loadScriptFromString(std::unique_ptr<const JSBigString> string,
std::string sourceURL) {
callback_->incrementPendingJSCalls();
@@ -74,15 +82,10 @@ void Instance::loadScriptFromFile(const std::string& filename,
std::unique_ptr<const JSBigFileString> script;
// This function can be called in order to change the Bridge's Source URL.
// In that case, the filename will be empty, and we should not attempt to
// load it.
if (!filename.empty()) {
RecoverableError::runRethrowingAsRecoverable<std::system_error>(
[&filename, &script]() {
script = JSBigFileString::fromPath(filename);
});
}
RecoverableError::runRethrowingAsRecoverable<std::system_error>(
[&filename, &script]() {
script = JSBigFileString::fromPath(filename);
});
nativeToJsBridge_->loadApplication(nullptr, std::move(script), sourceURL);
}