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

Side by Side Diff: compiled/subscription/Subscription.h

Issue 29385742: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 2 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created March 16, 2017, 6:27 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
OLDNEW
1 #pragma once 1 #pragma once
2 2
3 #include <vector> 3 #include <vector>
4 4
5 #include "../filter/Filter.h" 5 #include "../filter/Filter.h"
6 #include "../String.h" 6 #include "../String.h"
7 #include "../intrusive_ptr.h" 7 #include "../intrusive_ptr.h"
8 #include "../debug.h" 8 #include "../debug.h"
9 9
10 #define SUBSCRIPTION_PROPERTY(type, name, getter, setter) \ 10 #define SUBSCRIPTION_PROPERTY(type, name, getter, setter) \
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 var subscription = new (exports[Subscription_mapping[$2]])($1);\ 48 var subscription = new (exports[Subscription_mapping[$2]])($1);\
49 FilterNotifier.triggerListeners(readString($0), subscription, readSt ring($3), readString($4));\ 49 FilterNotifier.triggerListeners(readString($0), subscription, readSt ring($3), readString($4));\
50 }, &action, this, mType, &value, &oldvalue);\ 50 }, &action, this, mType, &value, &oldvalue);\
51 }\ 51 }\
52 } 52 }
53 53
54 class Subscription : public ref_counted 54 class Subscription : public ref_counted
55 { 55 {
56 protected: 56 protected:
57 OwnedString mID; 57 OwnedString mID;
58 std::vector<Filter> mFilters; 58 std::vector<FilterPtr> mFilters;
59 59
60 public: 60 public:
61 enum Type 61 enum Type
62 { 62 {
63 UNKNOWN = 0, 63 UNKNOWN = 0,
64 DOWNLOADABLE = 1, 64 DOWNLOADABLE = 1,
65 USERDEFINED = 2 65 USERDEFINED = 2
66 }; 66 };
67 67
68 explicit Subscription(Type type, const String& id); 68 explicit Subscription(Type type, const String& id);
69 ~Subscription(); 69 ~Subscription();
70 70
71 Type mType; 71 Type mType;
72 72
73 EMSCRIPTEN_KEEPALIVE const String& GetID() const 73 EMSCRIPTEN_KEEPALIVE const String& GetID() const
74 { 74 {
75 return mID; 75 return mID;
76 } 76 }
77 77
78 SUBSCRIPTION_STRING_PROPERTY(mTitle, GetTitle, SetTitle); 78 SUBSCRIPTION_STRING_PROPERTY(mTitle, GetTitle, SetTitle);
79 SUBSCRIPTION_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); 79 SUBSCRIPTION_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled);
80 80
81 EMSCRIPTEN_KEEPALIVE unsigned GetFilterCount() const
82 {
83 return mFilters.size();
84 }
85
86 EMSCRIPTEN_KEEPALIVE Filter* FilterAt(unsigned index);
87 EMSCRIPTEN_KEEPALIVE int IndexOfFilter(Filter* filter);
81 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const; 88 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const;
82 EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const; 89 EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const;
83 90
84 static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id); 91 static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id);
85 }; 92 };
86 93
87 typedef intrusive_ptr<Subscription> SubscriptionPtr; 94 typedef intrusive_ptr<Subscription> SubscriptionPtr;
OLDNEW

Powered by Google App Engine
This is Rietveld