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

Delta Between Two Patch Sets: compiled/ActiveFilter.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: Replaced shared_ptr by boost-like intrusive_ptr Created Jan. 28, 2016, 7:50 p.m.
Right Patch Set: Addressed comments from Patch Set 28 Created March 21, 2017, 10:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compile ('k') | compiled/ActiveFilter.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #ifndef ADBLOCK_PLUS_ACTIVE_FILTER_H 1 #pragma once
2 #define ADBLOCK_PLUS_ACTIVE_FILTER_H 2
3 #include <emscripten.h>
3 4
4 #include "Filter.h" 5 #include "Filter.h"
5 #include "api.h"
6 #include "StringMap.h" 6 #include "StringMap.h"
7
8 #define FILTER_PROPERTY(type, name, getter, setter) \
9 private:\
10 type name;\
11 public:\
12 type EMSCRIPTEN_KEEPALIVE getter() const\
13 {\
14 return name;\
15 }\
16 void EMSCRIPTEN_KEEPALIVE setter(type value)\
17 {\
18 if (name != value)\
19 {\
20 type oldvalue = name;\
21 name = value;\
22 DependentString action(u"filter."_str #name);\
23 EM_ASM_ARGS({\
24 var filter = new (exports[Filter_mapping[$2]])($1);\
25 FilterNotifier.triggerListeners(readString($0), filter, $3, $4);\
26 }, &action, this, mType, value, oldvalue);\
27 }\
28 }
7 29
8 class ActiveFilter : public Filter 30 class ActiveFilter : public Filter
9 { 31 {
32 protected:
33 typedef StringMap<bool> DomainMap;
34 typedef StringSet SitekeySet;
35 void ParseDomains(const String& domains, String::value_type separator) const;
36 void AddSitekey(const String& sitekey) const;
37 virtual DomainMap* GetDomains() const;
38 virtual SitekeySet* GetSitekeys() const;
39 mutable std::unique_ptr<DomainMap> mDomains;
40 mutable std::unique_ptr<SitekeySet> mSitekeys;
10 private: 41 private:
11 bool mIgnoreTrailingDot; 42 bool mIgnoreTrailingDot;
12 typedef StringMap<bool> DomainMap;
13 typedef StringSet SitekeySet;
14 protected:
15 std::unique_ptr<DomainMap> mDomains;
16 std::unique_ptr<SitekeySet> mSitekeys;
17 void ParseDomains(const String& str, char16_t separator);
18 void AddSitekey(const String& sitekey);
19 public: 43 public:
20 explicit ActiveFilter(const String& text, 44 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot);
21 bool ignoreTrailingDot);
22 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); 45 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled);
23 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); 46 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount);
24 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); 47 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit);
25 bool IsActiveOnDomain(String& docDomain, 48 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain,
26 const String& sitekey) const; 49 const String& sitekey) const;
27 bool IsActiveOnlyOnDomain(String& docDomain) const; 50 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st;
28 bool IsGeneric() const; 51 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const;
29 String Serialize() const; 52 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const;
30 }; 53 };
31
32 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld