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 #ifndef DISTRIBUTEDDATAMGR_OBJECT_ASSET_LOADER_H 16 #define DISTRIBUTEDDATAMGR_OBJECT_ASSET_LOADER_H 17 18 #include <string> 19 #include "executor_pool.h" 20 #include "object_types.h" 21 #include "store/general_value.h" 22 23 namespace OHOS { 24 namespace DistributedObject { 25 class ObjectAssetLoader { 26 public: 27 static ObjectAssetLoader *GetInstance(); 28 void SetThreadPool(std::shared_ptr<ExecutorPool> executors); 29 bool Transfer(const int32_t userId, const std::string &bundleName, 30 const std::string &deviceId, const DistributedData::Asset &assetValue); 31 void TransferAssetsAsync(const int32_t userId, const std::string& bundleName, const std::string& deviceId, 32 const std::vector<DistributedData::Asset>& assets, const std::function<void(bool success)>& callback); 33 private: 34 ObjectAssetLoader() = default; 35 ~ObjectAssetLoader() = default; 36 ObjectAssetLoader(const ObjectAssetLoader &) = delete; 37 ObjectAssetLoader &operator=(const ObjectAssetLoader &) = delete; 38 39 static constexpr int WAIT_TIME = 60; 40 std::shared_ptr<ExecutorPool> executors_; 41 }; 42 } // namespace DistributedObject 43 } // namespace OHOS 44 #endif // DISTRIBUTEDDATAMGR_OBJECT_ASSET_LOADER_H