1 // 2 // Copyright (C) 2020 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef UPDATE_ENGINE_COMMON_EXCLUDER_INTERFACE_H_ 18 #define UPDATE_ENGINE_COMMON_EXCLUDER_INTERFACE_H_ 19 20 #include <memory> 21 #include <string> 22 23 #include <base/macros.h> 24 25 namespace chromeos_update_engine { 26 27 class PrefsInterface; 28 29 class ExcluderInterface { 30 public: 31 virtual ~ExcluderInterface() = default; 32 33 // Returns true on successfuly excluding |name|, otherwise false. On a 34 // successful |Exclude()| the passed in |name| will be considered excluded 35 // and calls to |IsExcluded()| will return true. The exclusions are persisted. 36 virtual bool Exclude(const std::string& name) = 0; 37 38 // Returns true if |name| reached the exclusion limit, otherwise false. 39 virtual bool IsExcluded(const std::string& name) = 0; 40 41 // Returns true on sucessfully reseting the entire exclusion state, otherwise 42 // false. On a successful |Reset()| there will be no excluded |name| in the 43 // exclusion state. 44 virtual bool Reset() = 0; 45 46 // Not copyable or movable 47 ExcluderInterface(const ExcluderInterface&) = delete; 48 ExcluderInterface& operator=(const ExcluderInterface&) = delete; 49 ExcluderInterface(ExcluderInterface&&) = delete; 50 ExcluderInterface& operator=(ExcluderInterface&&) = delete; 51 52 protected: 53 ExcluderInterface() = default; 54 }; 55 56 std::unique_ptr<ExcluderInterface> CreateExcluder(PrefsInterface* prefs); 57 58 } // namespace chromeos_update_engine 59 60 #endif // UPDATE_ENGINE_COMMON_EXCLUDER_INTERFACE_H_ 61