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 #ifndef TRANS_MANANGER_H
16 #define TRANS_MANANGER_H
17 
18 #include <cstdint>
19 #include <map>
20 #include <memory>
21 #include <mutex>
22 
23 #include "i_file_trans_listener.h"
24 #include "refbase.h"
25 namespace OHOS {
26 namespace Storage {
27 namespace DistributedFile {
28 class TransManager {
29 public:
30     static TransManager &GetInstance();
31 
32     void AddTransTask(const std::string &sessionName, const sptr<IFileTransListener> &listener);
33     void NotifyFileProgress(const std::string &sessionName, uint64_t total, uint64_t processed);
34     void NotifyFileFailed(const std::string &sessionName, int32_t errorCode);
35     void NotifyFileFinished(const std::string &sessionName);
36     void DeleteTransTask(const std::string &sessionName);
37 
38 private:
39     std::mutex sessionTransMapMutex_;
40     std::map<std::string, sptr<IFileTransListener>> sessionTransMap_;
41 };
42 } // namespace DistributedFile
43 } // namespace Storage
44 } // namespace OHOS
45 #endif // TRANS_MANANGER_H
46