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 FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_SESSION_POOL_H 16 #define FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_SESSION_POOL_H 17 18 #include <map> 19 #include <mutex> 20 #include <string> 21 #include <vector> 22 23 namespace OHOS { 24 namespace Storage { 25 namespace DistributedFile { 26 class SoftBusSessionPool { 27 public: 28 struct SessionInfo { 29 int sessionId{}; 30 std::string srcUri; 31 std::string dstPath; 32 int uid{}; 33 }; 34 35 static SoftBusSessionPool &GetInstance(); 36 std::string GenerateSessionName(const SessionInfo &sessionInfo); 37 void AddSessionInfo(const std::string &sessionName, const SessionInfo &sessionInfo); 38 void DeleteSessionInfo(const std::string &sessionName); 39 bool GetSessionInfo(const std::string &sessionName, SessionInfo &sessionInfo); 40 41 private: 42 const std::string SESSION_NAME_PREFIX = "DistributedFileService"; 43 std::map<std::string, SessionInfo> sessionMap_; 44 std::mutex sessionMutex_; 45 }; 46 } // namespace DistributedFile 47 } // namespace Storage 48 } // namespace OHOS 49 #endif // FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_SESSION_POOL_H