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

Unified Diff: include/AdblockPlus/Platform.h

Issue 29508555: Issue 5450 - move FilterEngine into Platform (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: fix typos Created Aug. 7, 2017, 1:03 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 | « include/AdblockPlus/FilterEngine.h ('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/Platform.h
diff --git a/include/AdblockPlus/Platform.h b/include/AdblockPlus/Platform.h
index efcae83bde90c28956c3376553658df26f8eb481..e40823f10ffa12b1d774854f38ac7c7b8a1271ff 100644
--- a/include/AdblockPlus/Platform.h
+++ b/include/AdblockPlus/Platform.h
@@ -24,7 +24,9 @@
#include "IWebRequest.h"
#include "AppInfo.h"
#include "Scheduler.h"
+#include "FilterEngine.h"
#include <mutex>
+#include <future>
namespace AdblockPlus
{
@@ -77,6 +79,11 @@ namespace AdblockPlus
};
/**
+ * Callback type invoked when FilterEngine is created.
+ */
+ typedef std::function<void(const FilterEnginePtr&)> OnFilterEngineCreatedCallback;
+
+ /**
* Platform constructor.
*
* When a parameter value is nullptr the corresponding default
@@ -100,6 +107,24 @@ namespace AdblockPlus
std::shared_ptr<JsEngine> GetJsEngine();
/**
+ * Ensures that FilterEngine is constructed. Only the first call is effective.
+ *
+ * @param parameters optional creation parameters.
+ * @param onCreated A callback which is called when FilterEngine is ready
+ * for use.
+ */
+ void CreateFilterEngineAsync(const FilterEngine::CreationParameters& parameters = FilterEngine::CreationParameters(),
+ const OnFilterEngineCreatedCallback& onCreated = OnFilterEngineCreatedCallback());
+
+ /**
+ * Synchronous equivalent of `CreateFilterEngineAsync`.
+ * Internally it blocks and waits for finishing of certain asynchronous
+ * operations, please ensure that provided implementation does not lead to
+ * a dead lock.
+ */
+ FilterEnginePtr GetFilterEngine();
+
+ /**
* @return The asynchronous ITimer implementation.
*/
ITimer& GetTimer();
@@ -127,6 +152,7 @@ namespace AdblockPlus
// used for creation and deletion of modules.
std::mutex modulesMutex;
std::shared_ptr<JsEngine> jsEngine;
+ std::shared_future<FilterEnginePtr> filterEngine;
};
}
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | shell/src/Main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld