| Index: compiled/filter/Matcher.h |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/compiled/filter/Matcher.h |
| @@ -0,0 +1,82 @@ |
| +/* |
| + * This file is part of Adblock Plus <https://adblockplus.org/>, |
| + * Copyright (C) 2006-present eyeo GmbH |
| + * |
| + * Adblock Plus is free software: you can redistribute it and/or modify |
| + * it under the terms of the GNU General Public License version 3 as |
| + * published by the Free Software Foundation. |
| + * |
| + * Adblock Plus is distributed in the hope that it will be useful, |
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| + * GNU General Public License for more details. |
| + * |
| + * You should have received a copy of the GNU General Public License |
| + * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| + */ |
| + |
| +#pragma once |
| + |
| +#include <vector> |
| + |
| +#include "../debug.h" |
| +#include "../bindings/runtime.h" |
| +#include "../StringMap.h" |
| +#include "Filter.h" |
| + |
| +class Matcher : public ref_counted |
| +{ |
| +private: |
| + friend class CombinedMatcher; |
| + StringMap<std::vector<FilterPtr>> mFilterByKeyword; |
| + StringMap<OwnedString> mKeywordByFilter; |
| + int mCandidatesReId; |
| +public: |
| + Matcher(); |
| + ~Matcher(); |
| + |
| + void BINDINGS_EXPORTED Add(const FilterPtr&); |
| + void BINDINGS_EXPORTED Remove(const FilterPtr&); |
| + void BINDINGS_EXPORTED Clear() ; |
| + bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const; |
| + const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter); |
| + Filter* BINDINGS_EXPORTED MatchesAny(const String& location, |
| + int typeMask, DependentString& docDomain, bool thirdParty, |
| + const String& sitekey, bool specificOnly); |
| + OwnedString BINDINGS_EXPORTED FindKeyword(const FilterPtr&); |
| +private: |
| + FilterPtr CheckEntryMatch(const String& keyword, |
| + const String& location, |
| + int typeMask, DependentString& docDomain, bool thirdParty, |
| + const String& sitekey, bool specificOnly); |
| +}; |
| + |
| +class CombinedMatcher : public ref_counted |
| +{ |
| +private: |
| + static const size_t MAX_CACHE_ENTRIES; |
| + StringMap<FilterPtr> mResultCache; |
| + int mMatchReId; |
| + Matcher mBlacklist; |
| + Matcher mWhitelist; |
| + |
| +public: |
| + CombinedMatcher(); |
| + ~CombinedMatcher(); |
| + |
| + void BINDINGS_EXPORTED Add(const FilterPtr& filter); |
| + void BINDINGS_EXPORTED Remove(const FilterPtr& filter); |
| + void BINDINGS_EXPORTED Clear(); |
| + bool BINDINGS_EXPORTED HasFilter(const FilterPtr& filter) const; |
| + const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter); |
| + Filter* BINDINGS_EXPORTED MatchesAny(const String& location, |
| + int typeMask, DependentString& docDomain, bool thirdParty, |
| + const String& sitekey, bool specificOnly); |
| + OwnedString BINDINGS_EXPORTED FindKeyword(const FilterPtr& filter); |
| + |
| +private: |
| + void ResetCache(); |
| + FilterPtr MatchesAnyInternal(const String& location, |
| + int typeMask, DependentString& docDomain, bool thirdParty, |
| + const String& sitekey, bool specificOnly); |
| +}; |