Index: include/AdblockPlus/Platform.h |
diff --git a/include/AdblockPlus/Platform.h b/include/AdblockPlus/Platform.h |
index be1302b725aee0c0fe9654923328fabf575665b5..0b85dec8e8661e968fda41aa68c3dc0345f95e39 100644 |
--- a/include/AdblockPlus/Platform.h |
+++ b/include/AdblockPlus/Platform.h |
@@ -30,26 +30,6 @@ |
namespace AdblockPlus |
{ |
- /** |
- * A factory to construct DefaultTimer. |
- */ |
- TimerPtr CreateDefaultTimer(); |
- |
- /** |
- * A factory to construct DefaultFileSystem. |
- */ |
- FileSystemPtr CreateDefaultFileSystem(const Scheduler& scheduler, const std::string& basePath = std::string()); |
- |
- /** |
- * A factory to construct DefaultWebRequest. |
- */ |
- WebRequestPtr CreateDefaultWebRequest(const Scheduler& scheduler, WebRequestSyncPtr syncImpl = nullptr); |
- |
- /** |
- * A factory to construct LogSystem. |
- */ |
- LogSystemPtr CreateDefaultLogSystem(); |
- |
class IV8IsolateProvider; |
class JsEngine; |
@@ -91,7 +71,7 @@ namespace AdblockPlus |
* implementation is chosen. |
*/ |
explicit Platform(CreationParameters&& creationParameters = CreationParameters()); |
- ~Platform(); |
+ virtual ~Platform(); |
/** |
* Ensures that JsEngine is constructed. If JsEngine is already present |
@@ -157,6 +137,52 @@ namespace AdblockPlus |
std::shared_ptr<JsEngine> jsEngine; |
std::shared_future<FilterEnginePtr> filterEngine; |
}; |
+ |
+ /** |
+ * A helper class allowing to construct a default Platform and to obtain |
+ * the Scheduler used by Platform before the latter is constructed. |
+ */ |
+ class DefaultPlatformBuilder : public Platform::CreationParameters |
+ { |
+ public: |
+ /** |
+ * Constructs a default executor for asynchronous tasks. When Platform |
+ * is being destroyed it starts to ignore new tasks and waits for finishing |
+ * of already running tasks. |
+ * @return Scheduler allowing to execute tasks asynchronously. |
+ */ |
+ Scheduler GetDefaultAsyncExecutor(); |
+ |
+ /** |
+ * Constructs default implementation of `ITimer`. |
+ */ |
+ void CreateDefaultTimer(); |
+ |
+ /** |
+ * Constructs default implementation of `IFileSystem`. |
+ * @param basePath A working directory for file system operations. |
+ */ |
+ void CreateDefaultFileSystem(const std::string& basePath = std::string()); |
+ |
+ /** |
+ * Constructs default implementation of `IWebRequest`. |
+ */ |
+ void CreateDefaultWebRequest(WebRequestSyncPtr webRequest = nullptr); |
+ |
+ /** |
+ * Constructs default implementation of `LogSystem`. |
+ */ |
+ void CreateDefaultLogSystem(); |
+ |
+ /** |
+ * Constructs Platform with default implementations of platform interfaces |
+ * when a corresponding field is nullptr and with a default Scheduler. |
+ */ |
+ std::unique_ptr<Platform> CreatePlatform(); |
+ private: |
+ std::shared_ptr<Scheduler> asyncExecutor; |
+ Scheduler defaultScheduler; |
+ }; |
} |
#endif // ADBLOCK_PLUS_PLATFORM_H |