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

Unified Diff: include/AdblockPlus/FilterEngine.h

Issue 29377064: Issue 4944 - Make creation of FilterEngine asynchronous. (Closed)
Patch Set: Created Feb. 28, 2017, 2:21 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 | « README.md ('k') | shell/src/Main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/FilterEngine.h
diff --git a/include/AdblockPlus/FilterEngine.h b/include/AdblockPlus/FilterEngine.h
index 94b376eb8caadee35db2d4b96893ee5b0702b16d..dcf15a26604b4ca6d5f1484881b74303c0348478 100644
--- a/include/AdblockPlus/FilterEngine.h
+++ b/include/AdblockPlus/FilterEngine.h
@@ -29,6 +29,7 @@
namespace AdblockPlus
{
class FilterEngine;
+ typedef std::shared_ptr<FilterEngine> FilterEnginePtr;
/**
* Wrapper for an Adblock Plus filter object.
@@ -213,15 +214,40 @@ namespace AdblockPlus
typedef std::function<void(const NotificationPtr&)> ShowNotificationCallback;
/**
- * Constructor.
+ * FilterEngine creation parameters.
+ */
+ struct CreateParameters
Oleksandr 2017/03/16 15:05:25 Nit: How about CreationParameters. One might assum
sergei 2017/03/16 15:50:03 Agree, done.
+ {
+ /**
+ * `AdblockPlus::FilterEngine::Prefs` name - value list of preconfigured
+ * prefs.
+ */
+ Prefs preconfiguredPrefs;
+ };
+
+ /**
+ * Callback type invoked when FilterEngine is created.
+ */
+ typedef std::function<void(const FilterEnginePtr&)> OnCreatedCallback;
+
+ /**
+ * Asynchronously constructs FilterEngine.
* @param jsEngine `JsEngine` instance used to run JavaScript code
* internally.
- * @param preconfiguredPrefs `AdblockPlus::FilterEngine::Prefs`
- * name-value list of preconfigured prefs.
+ * @param onCreated A callback which is called when FilterEngine is ready
+ * for use.
+ * @param parameters optional creation parameters.
*/
- explicit FilterEngine(JsEnginePtr jsEngine,
- const Prefs& preconfiguredPrefs = Prefs()
- );
+ static void CreateAsync(const JsEnginePtr& jsEngine,
Eric 2017/02/28 17:04:50 (1) C++ has <future>. (2) This is new code. This
sergei 2017/02/28 22:18:27 Sorry, but what is the aim of this message? We cur
Oleksandr 2017/03/16 15:05:25 It does not look like we'll be able to move to a n
+ const OnCreatedCallback& onCreated,
+ const CreateParameters& parameters = CreateParameters());
+
+ /**
+ * Synchronous interface to construct FilterEngine. For details see
+ * asynchronous version CreateAsync.
+ */
+ static FilterEnginePtr Create(const JsEnginePtr& jsEngine,
+ const CreateParameters& params = CreateParameters());
/**
* Retrieves the `JsEngine` instance associated with this `FilterEngine`
@@ -442,12 +468,12 @@ namespace AdblockPlus
private:
JsEnginePtr jsEngine;
- bool initialized;
bool firstRun;
int updateCheckId;
static const std::map<ContentType, std::string> contentTypes;
- void InitDone(JsValueList& params);
+ explicit FilterEngine(const JsEnginePtr& jsEngine);
+
FilterPtr CheckFilterMatch(const std::string& url,
ContentTypeMask contentTypeMask,
const std::string& documentUrl) const;
« no previous file with comments | « README.md ('k') | shell/src/Main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld