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

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

Issue 29398669: Issue 5063 - [emscripten] Make FilterNotifier calls more efficient (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Rebased Created April 13, 2017, 1:07 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 | « compiled/bindings.ipp ('k') | compiled/shell.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 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/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #pragma once 18 #pragma once
19 19
20 #include <emscripten.h> 20 #include <emscripten.h>
21 21
22 #include "Filter.h" 22 #include "Filter.h"
23 #include "../StringMap.h" 23 #include "../StringMap.h"
24 #include "../FilterNotifier.h"
24 25
25 #define FILTER_PROPERTY(type, name, getter, setter) \ 26 #define FILTER_PROPERTY(type, name, topic, getter, setter) \
26 private:\ 27 private:\
27 type name;\ 28 type name;\
28 public:\ 29 public:\
29 type EMSCRIPTEN_KEEPALIVE getter() const\ 30 type EMSCRIPTEN_KEEPALIVE getter() const\
30 {\ 31 {\
31 return name;\ 32 return name;\
32 }\ 33 }\
33 void EMSCRIPTEN_KEEPALIVE setter(type value)\ 34 void EMSCRIPTEN_KEEPALIVE setter(type value)\
34 {\ 35 {\
35 if (name != value)\ 36 if (name != value)\
36 {\ 37 {\
37 type oldvalue = name;\ 38 type oldvalue = name;\
38 name = value;\ 39 name = value;\
39 DependentString action(u"filter."_str #name);\ 40 if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\
40 EM_ASM_ARGS({\ 41 {\
41 var filter = new (exports[Filter_mapping[$2]])($1);\ 42 FilterNotifier::PropertyChange(FilterNotifier::Topic::topic,\
42 FilterNotifier.triggerListeners(readString($0), filter, $3, $4);\ 43 this, value, oldvalue);\
43 }, &action, this, mType, value, oldvalue);\ 44 }\
44 }\ 45 }\
45 } 46 }
46 47
47 class ActiveFilter : public Filter 48 class ActiveFilter : public Filter
48 { 49 {
49 protected: 50 protected:
50 typedef StringMap<bool> DomainMap; 51 typedef StringMap<bool> DomainMap;
51 typedef StringSet SitekeySet; 52 typedef StringSet SitekeySet;
52 void ParseDomains(const String& domains, String::value_type separator) const; 53 void ParseDomains(const String& domains, String::value_type separator) const;
53 void AddSitekey(const String& sitekey) const; 54 void AddSitekey(const String& sitekey) const;
54 virtual DomainMap* GetDomains() const; 55 virtual DomainMap* GetDomains() const;
55 virtual SitekeySet* GetSitekeys() const; 56 virtual SitekeySet* GetSitekeys() const;
56 mutable std::unique_ptr<DomainMap> mDomains; 57 mutable std::unique_ptr<DomainMap> mDomains;
57 mutable std::unique_ptr<SitekeySet> mSitekeys; 58 mutable std::unique_ptr<SitekeySet> mSitekeys;
58 private: 59 private:
59 bool mIgnoreTrailingDot; 60 bool mIgnoreTrailingDot;
60 public: 61 public:
61 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot); 62 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot);
62 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); 63 FILTER_PROPERTY(bool, mDisabled, FILTER_DISABLED, GetDisabled, SetDisabled);
63 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); 64 FILTER_PROPERTY(unsigned int, mHitCount, FILTER_HITCOUNT,
64 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); 65 GetHitCount, SetHitCount);
66 FILTER_PROPERTY(unsigned int, mLastHit, FILTER_LASTHIT,
67 GetLastHit, SetLastHit);
65 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain, 68 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain,
66 const String& sitekey) const; 69 const String& sitekey) const;
67 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st; 70 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st;
68 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const; 71 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const;
69 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const; 72 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const;
70 }; 73 };
OLDNEW
« no previous file with comments | « compiled/bindings.ipp ('k') | compiled/shell.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld