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

Unified Diff: include/AdblockPlus/FilterEngine.h

Issue 10100009: FilterEngine API improvements (Closed)
Patch Set: Created April 4, 2013, 5:04 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | libadblockplus.gyp » ('j') | src/FilterEngine.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/FilterEngine.h
===================================================================
--- a/include/AdblockPlus/FilterEngine.h
+++ b/include/AdblockPlus/FilterEngine.h
@@ -1,39 +1,63 @@
#ifndef ADBLOCKPLUS_FILTER_ENGINE_H
#define ADBLOCKPLUS_FILTER_ENGINE_H
#include <vector>
+#include <map>
#include <string>
namespace AdblockPlus
{
class JsEngine;
+ class FilterEngine;
- struct Subscription
+ class Subscription
{
- std::string url;
- std::string title;
+ friend class FilterEngine;
+ public:
+ 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
+ int GetIntProperty(const std::string& name) const;
+ void SetProperty(const std::string& name, const std::string& value);
+ void SetIntProperty(const std::string& name, int value);
- Subscription(const std::string& url, const std::string& title);
+ bool IsListed() const;
+ void AddToList();
+ void RemoveFromList();
+ void UpdateFilters();
+
+ private:
+#if FILTER_ENGINE_STUBS
+ Subscription(FilterEngine& filterEngine, const std::string& url);
+
+ FilterEngine& filterEngine;
+ 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
+ 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
+#else
+ Subscription();
+#endif
};
+ typedef void (*SubscriptionsCallback)(const std::vector<Subscription*>&);
+
class FilterEngine
{
+ friend class Subscription;
public:
explicit FilterEngine(JsEngine& jsEngine);
- void AddSubscription(Subscription subscription);
- void RemoveSubscription(const Subscription& subscription);
- const Subscription* FindSubscription(const std::string& url) const;
- const std::vector<Subscription>& GetSubscriptions() const;
- void UpdateSubscriptionFilters(const Subscription& subscription);
- std::vector<Subscription> FetchAvailableSubscriptions();
+ Subscription& GetSubscription(const std::string& url);
+ const std::vector<Subscription*>& GetListedSubscriptions() const;
+ void FetchAvailableSubscriptions(SubscriptionsCallback callback);
bool Matches(const std::string& url,
- const std::string& contentType) const;
+ const std::string& contentType,
+ const std::string& documentUrl) const;
std::vector<std::string> GetElementHidingRules() const;
private:
JsEngine& jsEngine;
- std::vector<Subscription> subscriptions;
+#if FILTER_ENGINE_STUBS
+ std::map<std::string,Subscription*> knownSubscriptions;
+ std::vector<Subscription*> listedSubscriptions;
+#endif
};
}
#endif
« no previous file with comments | « no previous file | libadblockplus.gyp » ('j') | src/FilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld