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

Side by Side Diff: compiled/ActiveFilter.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Patch Set: Split up String class into two, cleaned up RegExpFilter methods Created Feb. 4, 2016, 7:20 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
« no previous file with comments | « compile ('k') | compiled/ActiveFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #ifndef ADBLOCK_PLUS_ACTIVE_FILTER_H
2 #define ADBLOCK_PLUS_ACTIVE_FILTER_H
3
4 #include <emscripten.h>
5
6 #include "Filter.h"
7 #include "StringMap.h"
8
9 #define FILTER_PROPERTY(type, name, getter, setter) \
10 private:\
11 type name;\
12 public:\
13 type EMSCRIPTEN_KEEPALIVE getter() const\
14 {\
15 return name;\
16 }\
17 void EMSCRIPTEN_KEEPALIVE setter(type value)\
18 {\
19 if (name != value)\
20 {\
21 type oldvalue = name;\
22 name = value;\
23 String action(u"filter."_str #name);\
24 EM_ASM_ARGS({\
25 var filter = new (exports[Filter_mapping[$2]])($1);\
26 FilterNotifier.triggerListeners(getStringData($0), filter, $3, $4);\
27 }, &action, this, GetType(), value, oldvalue);\
28 }\
29 }
30
31 class ActiveFilter : public Filter
32 {
33 protected:
34 typedef StringMap<bool> DomainMap;
35 typedef StringSet SitekeySet;
36 void ParseDomains(const String& domains, char16_t separator) const;
37 void AddSitekey(const String& sitekey) const;
38 virtual DomainMap* GetDomains() const;
39 virtual SitekeySet* GetSitekeys() const;
40 mutable std::unique_ptr<DomainMap> mDomains;
41 mutable std::unique_ptr<SitekeySet> mSitekeys;
42 private:
43 bool mIgnoreTrailingDot;
44 public:
45 ActiveFilter(const String& text, bool ignoreTrailingDot);
46 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled);
47 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount);
48 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit);
49 static void ToLower(String& str, String::size_type start,
50 String::size_type end);
51 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain,
52 const String& sitekey) const;
53 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st;
54 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const;
55 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const;
56 };
57
58 #endif
OLDNEW
« no previous file with comments | « compile ('k') | compiled/ActiveFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld