mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Moving some RAM logic to Instance.
Reviewed By: michalgr Differential Revision: D6208977 fbshipit-source-id: 28339d07c58f1acc816be02f2707ef75529fa069
This commit is contained in:
committed by
Facebook Github Bot
parent
59a5dbc0b0
commit
19de7fcb22
@@ -3,6 +3,7 @@
|
||||
#include "Instance.h"
|
||||
|
||||
#include "JSBigString.h"
|
||||
#include "JSBundleType.h"
|
||||
#include "JSExecutor.h"
|
||||
#include "MessageQueueThread.h"
|
||||
#include "MethodCall.h"
|
||||
@@ -11,6 +12,7 @@
|
||||
#include "RecoverableError.h"
|
||||
#include "SystraceSection.h"
|
||||
|
||||
#include <cxxreact/JSIndexedRAMBundle.h>
|
||||
#include <folly/Memory.h>
|
||||
#include <folly/MoveWrapper.h>
|
||||
#include <folly/json.h>
|
||||
@@ -18,6 +20,7 @@
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <condition_variable>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
@@ -91,6 +94,31 @@ void Instance::loadScriptFromString(std::unique_ptr<const JSBigString> string,
|
||||
}
|
||||
}
|
||||
|
||||
bool Instance::isIndexedRAMBundle(const char *sourcePath) {
|
||||
std::ifstream bundle_stream(sourcePath, std::ios_base::in);
|
||||
BundleHeader header;
|
||||
|
||||
if (!bundle_stream ||
|
||||
!bundle_stream.read(reinterpret_cast<char *>(&header), sizeof(header))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parseTypeFromHeader(header) == ScriptTag::RAMBundle;
|
||||
}
|
||||
|
||||
void Instance::loadRAMBundleFromFile(const std::string& sourcePath,
|
||||
const std::string& sourceURL,
|
||||
bool loadSynchronously) {
|
||||
auto bundle = folly::make_unique<JSIndexedRAMBundle>(sourcePath.c_str());
|
||||
auto startupScript = bundle->getStartupCode();
|
||||
auto registry = folly::make_unique<RAMBundleRegistry>(std::move(bundle));
|
||||
loadRAMBundle(
|
||||
std::move(registry),
|
||||
std::move(startupScript),
|
||||
sourceURL,
|
||||
loadSynchronously);
|
||||
}
|
||||
|
||||
void Instance::loadRAMBundle(std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL,
|
||||
|
||||
Reference in New Issue
Block a user