1 /* 2 * Copyright (c) 2022 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 TOKEN_MODIFY_NOTIFIER_H 17 #define TOKEN_MODIFY_NOTIFIER_H 18 19 #include <set> 20 #include <vector> 21 22 #include "access_token.h" 23 #include "nocopyable.h" 24 #include "rwlock.h" 25 #include "thread_pool.h" 26 27 namespace OHOS { 28 namespace Security { 29 namespace AccessToken { 30 class TokenModifyNotifier final { 31 public: 32 static TokenModifyNotifier& GetInstance(); 33 ~TokenModifyNotifier(); 34 void AddHapTokenObservation(AccessTokenID tokenID); 35 void NotifyTokenDelete(AccessTokenID tokenID); 36 void NotifyTokenModify(AccessTokenID tokenID); 37 void NotifyTokenChangedIfNeed(); 38 void NotifyTokenSyncTask(); 39 40 private: 41 TokenModifyNotifier(); 42 DISALLOW_COPY_AND_MOVE(TokenModifyNotifier); 43 44 bool hasInited_; 45 OHOS::Utils::RWLock initLock_; 46 OHOS::Utils::RWLock Notifylock_; 47 OHOS::ThreadPool notifyTokenWorker_; 48 std::set<AccessTokenID> observationSet_; 49 std::vector<AccessTokenID> deleteTokenList_; 50 std::vector<AccessTokenID> modifiedTokenList_; 51 }; 52 } // namespace AccessToken 53 } // namespace Security 54 } // namespace OHOS 55 #endif // TOKEN_MODIFY_NOTIFIER_H 56