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: Created Sept. 26, 2017, 9:34 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 MatcherBase : public ref_counted
hub 2017/09/26 21:49:00 the base class exposing the interface. Regular mat
28 {
29 private:
30 static MatcherBase* mInstance;
31
32 public:
33 virtual ~MatcherBase()
34 {
35 }
36
37 static MatcherBase* BINDINGS_EXPORTED GetDefaultInstance()
38 {
39 return mInstance;
40 }
41 virtual void BINDINGS_EXPORTED Add(const FilterPtr&) = 0;
42 virtual void BINDINGS_EXPORTED Remove(const FilterPtr&) = 0;
43 virtual void BINDINGS_EXPORTED Clear() = 0;
44 virtual bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const = 0;
45 virtual const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& f ilter) = 0;
46 virtual Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
47 int typeMask, DependentString& docDomain, bool thirdParty,
48 const String& sitekey, bool specificOnly) = 0;
49 virtual OwnedString FindKeyword(const FilterPtr&) = 0;
50 };
51
52 typedef intrusive_ptr<MatcherBase> MatcherPtr;
53
54 class Matcher : public MatcherBase
hub 2017/09/26 21:49:00 now that I re-read this I ponder whether this `Mat
hub 2017/09/27 15:28:25 We need it in a public header as notification.js w
55 {
56 private:
57 friend class CombinedMatcher;
58 StringMap<std::vector<FilterPtr>> mFilterByKeyword;
59 StringMap<OwnedString> mKeywordByFilter;
60 int mFilterReId;
61 int mOptionsReId;
62 int mCandidatesReId;
63 public:
64 Matcher();
65 ~Matcher();
66
67 void BINDINGS_EXPORTED Add(const FilterPtr&) override;
68 void BINDINGS_EXPORTED Remove(const FilterPtr&) override;
69 void BINDINGS_EXPORTED Clear() override ;
70 bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const override;
71 const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter) o verride;
72 Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
73 int typeMask, DependentString& docDomain, bool thirdParty,
74 const String& sitekey, bool specificOnly) override;
75 OwnedString FindKeyword(const FilterPtr&) override;
76 private:
77 Filter* _CheckEntryMatch(const String& keyword,
78 const String& location,
79 int typeMask, DependentString& docDomain, bool thirdParty,
80 const String& sitekey, bool specificOnly);
81 };
OLDNEW

Powered by Google App Engine
This is Rietveld