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

Unified Diff: compiled/filter/Matcher.h

Issue 29556737: Issue 5141 - Convert filter match to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Cleanup. Fixed the bindings to export what we actually need. Created Sept. 27, 2017, 3:27 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | compiled/filter/Matcher.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/filter/Matcher.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/compiled/filter/Matcher.h
@@ -0,0 +1,83 @@
+/*
+ * 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 MatcherBase : public ref_counted
+{
+private:
+ static MatcherBase* mInstance;
+
+public:
+ virtual ~MatcherBase()
+ {
+ }
+
+ static MatcherBase* BINDINGS_EXPORTED GetDefaultInstance()
+ {
+ return mInstance;
+ }
+ virtual void BINDINGS_EXPORTED Add(const FilterPtr&) = 0;
+ virtual void BINDINGS_EXPORTED Remove(const FilterPtr&) = 0;
+ virtual void BINDINGS_EXPORTED Clear() = 0;
+ virtual bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const = 0;
+ virtual const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter) = 0;
+ virtual Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
+ int typeMask, DependentString& docDomain, bool thirdParty,
+ const String& sitekey, bool specificOnly) = 0;
+protected:
+ virtual OwnedString FindKeyword(const FilterPtr&) = 0;
+};
+
+typedef intrusive_ptr<MatcherBase> MatcherPtr;
+
+class Matcher : public MatcherBase
+{
+private:
+ friend class CombinedMatcher;
+ StringMap<std::vector<FilterPtr>> mFilterByKeyword;
+ StringMap<OwnedString> mKeywordByFilter;
+ int mFilterReId;
+ int mOptionsReId;
+ int mCandidatesReId;
+public:
+ Matcher();
+ ~Matcher();
+
+ void BINDINGS_EXPORTED Add(const FilterPtr&) override;
+ void BINDINGS_EXPORTED Remove(const FilterPtr&) override;
+ void BINDINGS_EXPORTED Clear() override ;
+ bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const override;
+ const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter) override;
+ Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
+ int typeMask, DependentString& docDomain, bool thirdParty,
+ const String& sitekey, bool specificOnly) override;
+protected:
+ OwnedString FindKeyword(const FilterPtr&) override;
+private:
+ Filter* CheckEntryMatch(const String& keyword,
+ const String& location,
+ int typeMask, DependentString& docDomain, bool thirdParty,
+ const String& sitekey, bool specificOnly);
+};
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | compiled/filter/Matcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld