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: Addressed comments Created April 20, 2017, 8 a.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 name = value;\ 38 name = value;\
39 DependentString action(u"filter."_str #name);\ 39 if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\
40 EM_ASM_ARGS({\ 40 {\
41 var filter = new (exports[Filter_mapping[$2]])($1);\ 41 FilterNotifier::FilterChange(FilterNotifier::Topic::topic, this);\
42 FilterNotifier.triggerListeners(readString($0), filter, $3, $4);\ 42 }\
43 }, &action, this, mType, value, oldvalue);\
44 }\ 43 }\
45 } 44 }
46 45
47 class ActiveFilter : public Filter 46 class ActiveFilter : public Filter
48 { 47 {
49 protected: 48 protected:
50 typedef StringMap<bool> DomainMap; 49 typedef StringMap<bool> DomainMap;
51 typedef StringSet SitekeySet; 50 typedef StringSet SitekeySet;
52 void ParseDomains(const String& domains, String::value_type separator) const; 51 void ParseDomains(const String& domains, String::value_type separator) const;
53 void AddSitekey(const String& sitekey) const; 52 void AddSitekey(const String& sitekey) const;
54 virtual DomainMap* GetDomains() const; 53 virtual DomainMap* GetDomains() const;
55 virtual SitekeySet* GetSitekeys() const; 54 virtual SitekeySet* GetSitekeys() const;
56 mutable std::unique_ptr<DomainMap> mDomains; 55 mutable std::unique_ptr<DomainMap> mDomains;
57 mutable std::unique_ptr<SitekeySet> mSitekeys; 56 mutable std::unique_ptr<SitekeySet> mSitekeys;
58 private: 57 private:
59 bool mIgnoreTrailingDot; 58 bool mIgnoreTrailingDot;
60 public: 59 public:
61 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot); 60 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot);
62 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); 61 FILTER_PROPERTY(bool, mDisabled, FILTER_DISABLED, GetDisabled, SetDisabled);
63 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); 62 FILTER_PROPERTY(unsigned int, mHitCount, FILTER_HITCOUNT,
64 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); 63 GetHitCount, SetHitCount);
64 FILTER_PROPERTY(unsigned int, mLastHit, FILTER_LASTHIT,
65 GetLastHit, SetLastHit);
65 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain, 66 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain,
66 const String& sitekey) const; 67 const String& sitekey) const;
67 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st; 68 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st;
68 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const; 69 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const;
69 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const; 70 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const;
70 }; 71 };
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