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 // TODO(b/171829801): Move this interface to 'cros' directory. 'aosp' in no way 30 // is using this. Not even the stub implementation. 31 class ExcluderInterface { 32 public: 33 virtual ~ExcluderInterface() = default; 34 35 // Returns true on successfuly excluding |name|, otherwise false. On a 36 // successful |Exclude()| the passed in |name| will be considered excluded 37 // and calls to |IsExcluded()| will return true. The exclusions are persisted. 38 virtual bool Exclude(const std::string& name) = 0; 39 40 // Returns true if |name| reached the exclusion limit, otherwise false. 41 virtual bool IsExcluded(const std::string& name) = 0; 42 43 // Returns true on sucessfully reseting the entire exclusion state, otherwise 44 // false. On a successful |Reset()| there will be no excluded |name| in the 45 // exclusion state. 46 virtual bool Reset() = 0; 47 48 // Not copyable or movable 49 ExcluderInterface(const ExcluderInterface&) = delete; 50 ExcluderInterface& operator=(const ExcluderInterface&) = delete; 51 ExcluderInterface(ExcluderInterface&&) = delete; 52 ExcluderInterface& operator=(ExcluderInterface&&) = delete; 53 54 protected: 55 ExcluderInterface() = default; 56 }; 57 58 std::unique_ptr<ExcluderInterface> CreateExcluder(); 59 60 } // namespace chromeos_update_engine 61 62 #endif // UPDATE_ENGINE_COMMON_EXCLUDER_INTERFACE_H_ 63