1 /*
2  * Copyright (c) 2021 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 ACCOUNT_CHANGE_OBSERVER_H
17 #define ACCOUNT_CHANGE_OBSERVER_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <vector>
22 
23 #include "common_event_subscribe_info.h"
24 #include "common_event_subscriber.h"
25 #include "mountpoint/mount_point.h"
26 
27 namespace OHOS {
28 namespace Storage {
29 namespace DistributedFile {
30 static constexpr int MOUNT_POINT_NUM = 2;
31 class OsAccountObserver final : public EventFwk::CommonEventSubscriber {
32 public:
33     OsAccountObserver() = default;
34     ~OsAccountObserver();
35     explicit OsAccountObserver(const EventFwk::CommonEventSubscribeInfo &subscribeInfo);
36 
37     virtual void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override;
38 private:
39     void RemoveMPInfo(const int id);
40     void AddMPInfo(const int id, const std::string &relativePath);
41 
42     std::mutex serializer_;
43     std::unordered_map<int, std::vector<std::shared_ptr<MountPoint>>> mountPoints_;
44     int curUsrId { -1 };
45 };
46 } // namespace DistributedFile
47 } // namespace Storage
48 } // namespace OHOS
49 #endif // ACCOUNT_CHANGE_OBSERVER_H