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

Side by Side Diff: include/AdblockPlus/FilterEngine.h

Issue 10100009: FilterEngine API improvements (Closed)
Patch Set: Created April 4, 2013, 5:04 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 | « no previous file | libadblockplus.gyp » ('j') | src/FilterEngine.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef ADBLOCKPLUS_FILTER_ENGINE_H 1 #ifndef ADBLOCKPLUS_FILTER_ENGINE_H
2 #define ADBLOCKPLUS_FILTER_ENGINE_H 2 #define ADBLOCKPLUS_FILTER_ENGINE_H
3 3
4 #include <vector> 4 #include <vector>
5 #include <map>
5 #include <string> 6 #include <string>
6 7
7 namespace AdblockPlus 8 namespace AdblockPlus
8 { 9 {
9 class JsEngine; 10 class JsEngine;
11 class FilterEngine;
10 12
11 struct Subscription 13 class Subscription
12 { 14 {
13 std::string url; 15 friend class FilterEngine;
14 std::string title; 16 public:
17 const std::string GetProperty(const std::string& name) const;
Felix Dahlke 2013/04/05 08:50:20 Why return a const value here? It's copied on retu
Wladimir Palant 2013/04/05 12:15:16 True of course, originally I tried to return a ref
18 int GetIntProperty(const std::string& name) const;
19 void SetProperty(const std::string& name, const std::string& value);
20 void SetIntProperty(const std::string& name, int value);
15 21
16 Subscription(const std::string& url, const std::string& title); 22 bool IsListed() const;
23 void AddToList();
24 void RemoveFromList();
25 void UpdateFilters();
26
27 private:
28 #if FILTER_ENGINE_STUBS
29 Subscription(FilterEngine& filterEngine, const std::string& url);
30
31 FilterEngine& filterEngine;
32 std::map<std::string,std::string> properties;
Felix Dahlke 2013/04/05 08:50:20 We generally put a space after a comma in template
33 std::map<std::string,int> intProperties;
Felix Dahlke 2013/04/05 08:50:20 Will we need more types than string and int? We'll
Wladimir Palant 2013/04/05 12:15:16 Yes, we need booleans as well. Other than that sub
34 #else
35 Subscription();
36 #endif
17 }; 37 };
18 38
39 typedef void (*SubscriptionsCallback)(const std::vector<Subscription*>&);
40
19 class FilterEngine 41 class FilterEngine
20 { 42 {
43 friend class Subscription;
21 public: 44 public:
22 explicit FilterEngine(JsEngine& jsEngine); 45 explicit FilterEngine(JsEngine& jsEngine);
23 void AddSubscription(Subscription subscription); 46 Subscription& GetSubscription(const std::string& url);
24 void RemoveSubscription(const Subscription& subscription); 47 const std::vector<Subscription*>& GetListedSubscriptions() const;
25 const Subscription* FindSubscription(const std::string& url) const; 48 void FetchAvailableSubscriptions(SubscriptionsCallback callback);
26 const std::vector<Subscription>& GetSubscriptions() const;
27 void UpdateSubscriptionFilters(const Subscription& subscription);
28 std::vector<Subscription> FetchAvailableSubscriptions();
29 bool Matches(const std::string& url, 49 bool Matches(const std::string& url,
30 const std::string& contentType) const; 50 const std::string& contentType,
51 const std::string& documentUrl) const;
31 std::vector<std::string> GetElementHidingRules() const; 52 std::vector<std::string> GetElementHidingRules() const;
32 53
33 private: 54 private:
34 JsEngine& jsEngine; 55 JsEngine& jsEngine;
35 std::vector<Subscription> subscriptions; 56 #if FILTER_ENGINE_STUBS
57 std::map<std::string,Subscription*> knownSubscriptions;
58 std::vector<Subscription*> listedSubscriptions;
59 #endif
36 }; 60 };
37 } 61 }
38 62
39 #endif 63 #endif
OLDNEW
« no previous file with comments | « no previous file | libadblockplus.gyp » ('j') | src/FilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld