Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/filter/Matcher.h

Issue 29556737: Issue 5141 - Convert filter match to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Some more cleanup Created Sept. 29, 2017, 4:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #pragma once
19
20 #include <vector>
21
22 #include "../debug.h"
23 #include "../bindings/runtime.h"
24 #include "../StringMap.h"
25 #include "Filter.h"
26
27 class Matcher : public ref_counted
28 {
29 private:
30 friend class CombinedMatcher;
31 StringMap<std::vector<FilterPtr>> mFilterByKeyword;
32 StringMap<OwnedString> mKeywordByFilter;
33 public:
34 void BINDINGS_EXPORTED Add(const FilterPtr&);
35 void BINDINGS_EXPORTED Remove(const FilterPtr&);
36 void BINDINGS_EXPORTED Clear() ;
37 bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const;
38 const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter);
39 Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
40 int typeMask, DependentString& docDomain, bool thirdParty,
41 const String& sitekey, bool specificOnly);
42 OwnedString BINDINGS_EXPORTED FindKeyword(const FilterPtr&);
43 private:
44 FilterPtr CheckEntryMatch(const String& keyword,
45 const String& location,
46 int typeMask, DependentString& docDomain, bool thirdParty,
47 const String& sitekey, bool specificOnly);
48 };
49
50 class CombinedMatcher : public ref_counted
51 {
52 private:
53 static const size_t MAX_CACHE_ENTRIES;
54 StringMap<FilterPtr> mResultCache;
55 Matcher mBlacklist;
56 Matcher mWhitelist;
57
58 public:
59 void BINDINGS_EXPORTED Add(const FilterPtr& filter);
60 void BINDINGS_EXPORTED Remove(const FilterPtr& filter);
61 void BINDINGS_EXPORTED Clear();
62 bool BINDINGS_EXPORTED HasFilter(const FilterPtr& filter) const;
63 const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter);
64 Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
65 int typeMask, DependentString& docDomain, bool thirdParty,
66 const String& sitekey, bool specificOnly);
67 OwnedString BINDINGS_EXPORTED FindKeyword(const FilterPtr& filter);
68
69 private:
70 void ResetCache();
71 FilterPtr MatchesAnyInternal(const String& location,
72 int typeMask, DependentString& docDomain, bool thirdParty,
73 const String& sitekey, bool specificOnly);
74 };
OLDNEW

Powered by Google App Engine
This is Rietveld