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

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

Issue 29426559: Issue 5137 - [emscripten] Added basic filter storage implementation (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Rebased, updated copyright year Created Aug. 22, 2017, 11:03 a.m.
Right Patch Set: Fixed bogus assert Created Aug. 31, 2017, 12:44 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.h ('k') | compiled/subscription/Subscription.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 /* 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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \ 51 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \
52 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");\
53 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter) 53 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter)
54 54
55 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \ 55 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \
56 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter) 56 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter)
57 57
58 class Subscription : public ref_counted 58 class Subscription : public ref_counted
59 { 59 {
60 public:
61 typedef std::vector<FilterPtr> Filters;
62
60 protected: 63 protected:
61 OwnedString mID; 64 OwnedString mID;
62 std::vector<FilterPtr> mFilters; 65 Filters mFilters;
63 66
64 public: 67 public:
65 enum Type 68 enum Type
66 { 69 {
67 UNKNOWN = 0, 70 UNKNOWN = 0,
68 DOWNLOADABLE = 1, 71 DOWNLOADABLE = 1,
69 USERDEFINED = 2 72 USERDEFINED = 2
70 }; 73 };
71 74
72 explicit Subscription(Type type, const String& id); 75 explicit Subscription(Type type, const String& id);
73 ~Subscription(); 76 ~Subscription();
74 77
75 Type mType; 78 Type mType;
76 79
77 BINDINGS_EXPORTED const String& GetID() const 80 BINDINGS_EXPORTED const String& GetID() const
78 { 81 {
79 return mID; 82 return mID;
80 } 83 }
81 84
82 SUBSCRIPTION_STRING_PROPERTY(mTitle, SUBSCRIPTION_TITLE, GetTitle, SetTitle); 85 SUBSCRIPTION_STRING_PROPERTY(mTitle, SUBSCRIPTION_TITLE, GetTitle, SetTitle);
83 SUBSCRIPTION_PROPERTY(bool, mDisabled, SUBSCRIPTION_DISABLED, 86 SUBSCRIPTION_PROPERTY(bool, mDisabled, SUBSCRIPTION_DISABLED,
84 GetDisabled, SetDisabled); 87 GetDisabled, SetDisabled);
85 SUBSCRIPTION_PROPERTY(bool, mListed, NONE, GetListed, SetListed); 88 SUBSCRIPTION_PROPERTY(bool, mListed, NONE, GetListed, SetListed);
sergei 2017/08/24 13:32:06 To tell the truth I find this flag a bit questiona
86 89
87 BINDINGS_EXPORTED unsigned GetFilterCount() const 90 BINDINGS_EXPORTED Filters::size_type GetFilterCount() const
88 { 91 {
89 return mFilters.size(); 92 return mFilters.size();
90 } 93 }
91 94
92 BINDINGS_EXPORTED Filter* FilterAt(unsigned index); 95 BINDINGS_EXPORTED Filter* FilterAt(Filters::size_type index);
93 BINDINGS_EXPORTED int IndexOfFilter(Filter* filter); 96 BINDINGS_EXPORTED int IndexOfFilter(Filter* filter);
94 BINDINGS_EXPORTED OwnedString Serialize() const; 97 BINDINGS_EXPORTED OwnedString Serialize() const;
95 BINDINGS_EXPORTED OwnedString SerializeFilters() const; 98 BINDINGS_EXPORTED OwnedString SerializeFilters() const;
96 99
97 static BINDINGS_EXPORTED Subscription* FromID(const String& id); 100 static BINDINGS_EXPORTED Subscription* FromID(const String& id);
98 101
99 template<typename T> 102 template<typename T>
100 T* As(); 103 T* As();
101 }; 104 };
102 105
103 typedef intrusive_ptr<Subscription> SubscriptionPtr; 106 typedef intrusive_ptr<Subscription> SubscriptionPtr;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld