1 /*
2  * Copyright (c) 2023 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_DISTRIBUTED_DATA_SERVICES_EXTENSION_ASSET_LOADER_IMPL_H
17 #define OHOS_DISTRIBUTED_DATA_SERVICES_EXTENSION_ASSET_LOADER_IMPL_H
18 
19 #include "cloud/asset_loader.h"
20 #include "cloud/schema_meta.h"
21 #include "cloud_extension.h"
22 
23 namespace OHOS::CloudData {
24 using DBValue = DistributedData::Value;
25 using DBVBucket = DistributedData::VBucket;
26 using DBMeta = DistributedData::Database;
27 using DBAssets = DistributedData::Assets;
28 using DBAsset = DistributedData::Asset;
29 using DBErr = DistributedData::GeneralError;
30 class AssetLoaderImpl : public DistributedData::AssetLoader {
31 public:
32     explicit AssetLoaderImpl(OhCloudExtCloudAssetLoader *loader);
33     ~AssetLoaderImpl();
34     int32_t Download(const std::string &tableName, const std::string &gid, const DBValue &prefix,
35         DBVBucket &assets) override;
36     int32_t RemoveLocalAssets(const std::string &tableName, const std::string &gid,
37         const DBValue &prefix, DBVBucket &assets) override;
38 
39 private:
40     OhCloudExtCloudAssetLoader *loader_ = nullptr;
41     int32_t RemoveLocalAsset(const DBAsset &dbAsset);
42 };
43 } // namespace OHOS::CloudData
44 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_EXTENSION_ASSET_LOADER_IMPL_H
45