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_FILEMGMT_CLOUD_DOWNLOAD_URI_MANAGER_H
17 #define OHOS_FILEMGMT_CLOUD_DOWNLOAD_URI_MANAGER_H
18 
19 #include "nocopyable.h"
20 
21 #include <map>
22 #include <mutex>
23 
24 namespace OHOS::FileManagement::CloudSync {
25 class CloudDownloadUriManager : public NoCopyable {
26 public:
27     static CloudDownloadUriManager &GetInstance();
28 
29     int32_t AddPathToUri(const std::string& path, const std::string& uri);
30     int32_t AddDownloadIdToPath(int64_t &downloadId, std::vector<std::string> &pathVec);
31     std::string GetUri(const std::string& path);
32     void RemoveUri(const std::string& path);
33     void CheckDownloadIdPathMap(int64_t &downloadId);
34     void RemoveUri(const int64_t &downloadId);
35     void Reset();
36 
37 private:
38     CloudDownloadUriManager() = default;
39     std::mutex pathUriMutex_;
40     std::mutex downloadIdPathMutex_;
41     std::map<std::string, std::string> pathUriMap_;
42     std::map<uint64_t, std::vector<std::string>> downloadIdPathMap_;
43 };
44 } // namespace OHOS::FileManagement::CloudSync
45 
46 #endif // OHOS_FILEMGMT_CLOUD_DOWNLOAD_URI_MANAGER_H
47