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

Delta Between Two Patch Sets: compiled/subscription/Subscription.h

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Added md5 checksum. Reorganized some code. Created Nov. 28, 2017, 10:46 p.m.
Right Patch Set: Removed Md5sum and associated code Created Aug. 14, 2018, 12:38 p.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 | « compiled/subscription/DownloadableSubscription.cpp ('k') | lib/synchronizer.js » ('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 /* 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 <vector> 20 #include <vector>
21 21
22 #include "../base.h"
22 #include "../filter/Filter.h" 23 #include "../filter/Filter.h"
23 #include "../String.h" 24 #include "../String.h"
24 #include "../FilterNotifier.h" 25 #include "../FilterNotifier.h"
25 #include "../intrusive_ptr.h" 26 #include "../intrusive_ptr.h"
26 #include "../debug.h" 27 #include "../debug.h"
27 #include "../bindings/runtime.h" 28 #include "../bindings/runtime.h"
28 29
29 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett er, setter) \ 30 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett er, setter) \
30 private:\ 31 private:\
31 field_type name;\ 32 field_type name;\
32 public:\ 33 public:\
33 param_type BINDINGS_EXPORTED getter() const\ 34 param_type BINDINGS_EXPORTED getter() const\
34 {\ 35 {\
35 return name;\ 36 return name;\
36 }\ 37 }\
37 void BINDINGS_EXPORTED setter(param_type value)\ 38 void BINDINGS_EXPORTED setter(param_type value)\
38 {\ 39 {\
39 if (name != value)\ 40 if (name != value)\
40 {\ 41 {\
41 name = value;\ 42 name = value;\
42 if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ 43 if (ABP_NS::FilterNotifier::Topic::topic != ABP_NS::FilterNotifier::To pic::NONE)\
43 {\ 44 {\
44 FilterNotifier::SubscriptionChange(FilterNotifier::Topic::topic,\ 45 ABP_NS::FilterNotifier::SubscriptionChange(ABP_NS::FilterNotifier::T opic::topic,\
45 *this);\ 46 *this);\
46 }\ 47 }\
47 }\ 48 }\
48 } 49 }
49 50
50 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \ 51 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \
51 static_assert(std::is_arithmetic<type>::value, "SUBSCRIPTION_PROPERTY macro can only be used with arithmetic types");\ 52 static_assert(std::is_arithmetic<type>::value, "SUBSCRIPTION_PROPERTY macro can only be used with arithmetic types");\
52 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter) 53 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter)
53 54
54 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \ 55 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \
55 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter) 56 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter)
57
58 ABP_NS_BEGIN
56 59
57 class Subscription : public ref_counted 60 class Subscription : public ref_counted
58 { 61 {
59 public: 62 public:
60 typedef std::vector<FilterPtr> Filters; 63 typedef std::vector<FilterPtr> Filters;
61 64
62 protected: 65 protected:
63 OwnedString mID; 66 OwnedString mID;
64 Filters mFilters; 67 Filters mFilters;
65 68
66 public: 69 public:
67 enum Type 70 enum Type
68 { 71 {
69 UNKNOWN = 0, 72 UNKNOWN = 0,
70 DOWNLOADABLE = 1, 73 DOWNLOADABLE = 1,
71 USERDEFINED = 2 74 USERDEFINED = 2
72 }; 75 };
73 76
74 explicit Subscription(Type type, const String& id); 77 explicit Subscription(Type type, const String& id);
75 ~Subscription(); 78 ~Subscription();
76 79
77 Type mType; 80 Type mType;
78 81
79 const BINDINGS_EXPORTED String& GetID() const 82 const BINDINGS_EXPORTED String& GetID() const
80 { 83 {
81 return mID; 84 return mID;
82 } 85 }
83 86
84 Filters& GetFilters() 87 void SetFilters(Filters&& filters)
85 { 88 {
86 return mFilters; 89 mFilters = filters;
90 }
91
92 void ClearFilters()
93 {
94 mFilters.clear();
87 } 95 }
88 96
89 SUBSCRIPTION_STRING_PROPERTY(mTitle, SUBSCRIPTION_TITLE, GetTitle, SetTitle); 97 SUBSCRIPTION_STRING_PROPERTY(mTitle, SUBSCRIPTION_TITLE, GetTitle, SetTitle);
90 SUBSCRIPTION_PROPERTY(bool, mDisabled, SUBSCRIPTION_DISABLED, 98 SUBSCRIPTION_PROPERTY(bool, mDisabled, SUBSCRIPTION_DISABLED,
91 GetDisabled, SetDisabled); 99 GetDisabled, SetDisabled);
92 SUBSCRIPTION_PROPERTY(bool, mListed, NONE, GetListed, SetListed); 100 SUBSCRIPTION_PROPERTY(bool, mListed, NONE, GetListed, SetListed);
93 101
94 Filters::size_type BINDINGS_EXPORTED GetFilterCount() const 102 Filters::size_type BINDINGS_EXPORTED GetFilterCount() const
95 { 103 {
96 return mFilters.size(); 104 return mFilters.size();
(...skipping 19 matching lines...) Expand all
116 const T* As() const 124 const T* As() const
117 { 125 {
118 if (mType != T::classType) 126 if (mType != T::classType)
119 return nullptr; 127 return nullptr;
120 128
121 return static_cast<const T*>(this); 129 return static_cast<const T*>(this);
122 } 130 }
123 }; 131 };
124 132
125 typedef intrusive_ptr<Subscription> SubscriptionPtr; 133 typedef intrusive_ptr<Subscription> SubscriptionPtr;
134
135 ABP_NS_END
LEFTRIGHT

Powered by Google App Engine
This is Rietveld