react-native/ReactCommon/cxxreact/JSDeltaBundleClient.h
Héctor Ramos da7873563b Migrate Android sources to MIT license header
Reviewed By: fkgozali

Differential Revision: D8065619

fbshipit-source-id: 719c303b40c96950bab8e5dde9a75f449b2956c6
2018-05-31 15:37:30 -07:00

46 lines
1.1 KiB
C++

// Copyright (c) 2004-present, Facebook, Inc.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include <unordered_map>
#include <cxxreact/JSBigString.h>
#include <cxxreact/JSModulesUnbundle.h>
#include <folly/dynamic.h>
namespace facebook {
namespace react {
class JSDeltaBundleClient {
public:
void patch(const folly::dynamic& delta);
JSModulesUnbundle::Module getModule(uint32_t moduleId) const;
std::unique_ptr<const JSBigString> getStartupCode() const;
void clear();
private:
std::unordered_map<uint32_t, std::string> modules_;
std::string startupCode_;
};
class JSDeltaBundleClientRAMBundle : public JSModulesUnbundle {
public:
JSDeltaBundleClientRAMBundle(
std::shared_ptr<const JSDeltaBundleClient> client) : client_(client) {}
Module getModule(uint32_t moduleId) const override {
return client_->getModule(moduleId);
}
private:
const std::shared_ptr<const JSDeltaBundleClient> client_;
};
} // namespace react
} // namespace facebook