• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_ABILITY_RUNTIME_JS_MODULE_READER_H
17 #define OHOS_ABILITY_RUNTIME_JS_MODULE_READER_H
18 
19 #include <sstream>
20 #include <string>
21 
22 #include "js_module_searcher.h"
23 #include "runtime_extractor.h"
24 
25 namespace OHOS {
26 namespace AbilityRuntime {
27 class JsModuleReader final : private JsModuleSearcher {
28 public:
JsModuleReader(const std::string & bundleName,const std::string & hapPath,const std::shared_ptr<RuntimeExtractor> & runtimeExtractor)29     JsModuleReader(const std::string& bundleName, const std::string& hapPath,
30         const std::shared_ptr<RuntimeExtractor>& runtimeExtractor)
31         : JsModuleSearcher(bundleName), hapPath_(hapPath), runtimeExtractor_(runtimeExtractor)
32     {}
33     ~JsModuleReader() = default;
34 
35     JsModuleReader(const JsModuleReader&) = default;
36     JsModuleReader(JsModuleReader&&) = default;
37     JsModuleReader& operator=(const JsModuleReader&) = default;
38     JsModuleReader& operator=(JsModuleReader&&) = default;
39 
40     std::vector<uint8_t> operator()(const std::string& curJsModulePath, const std::string& newJsModuleUri) const;
41 
42 private:
43     std::string hapPath_;
44     std::shared_ptr<RuntimeExtractor> runtimeExtractor_;
45 };
46 } // namespace AbilityRuntime
47 } // namespace OHOS
48 
49 #endif // OHOS_ABILITY_RUNTIME_JS_MODULE_READER_H