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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 29500602: Issue 5450 - introduce the Platform class (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 28, 2017, 12:40 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.h ('k') | include/AdblockPlus/Platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/JsEngine.h
diff --git a/include/AdblockPlus/JsEngine.h b/include/AdblockPlus/JsEngine.h
index fbce51f93de65480b392e552ce13f317c7cc3373..4820ffc647c6ca7d535c3af02dafefd4bf8eb8d8 100644
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -45,6 +45,7 @@ namespace v8
namespace AdblockPlus
{
class JsEngine;
+ class Platform;
/**
* Shared smart pointer to a `JsEngine` instance.
@@ -52,26 +53,6 @@ namespace AdblockPlus
typedef std::shared_ptr<JsEngine> JsEnginePtr;
/**
- * A factory to construct DefaultTimer.
- */
- TimerPtr CreateDefaultTimer();
-
- /**
- * A factory to construct DefaultFileSystem.
- */
- FileSystemPtr CreateDefaultFileSystem(const Scheduler& scheduler);
-
- /**
- * A factory to construct DefaultWebRequest.
- */
- WebRequestPtr CreateDefaultWebRequest(const Scheduler& scheduler);
-
- /**
- * A factory to construct LogSystem.
- */
- LogSystemPtr CreateDefaultLogSystem();
-
- /**
* Scope based isolate manager. Creates a new isolate instance on
* constructing and disposes it on destructing.
*/
@@ -129,20 +110,12 @@ namespace AdblockPlus
/**
* Creates a new JavaScript engine instance.
*
- * When a parameter value is nullptr the corresponding default
- * implementation is chosen.
- *
* @param appInfo Information about the app.
- * @param timer Implementation of timer.
- * @param fileSystem Implementation of filesystem.
- * @param webRequest Implementation of web request.
- * @param logSystem Implementation of log system.
+ * @param platform AdblockPlus platform providing with necessary
+ * dependencies.
* @return New `JsEngine` instance.
*/
- static JsEnginePtr New(const AppInfo& appInfo = AppInfo(),
- TimerPtr timer = nullptr, FileSystemPtr fileSystem = nullptr,
- WebRequestPtr webRequest = nullptr, LogSystemPtr logSystem = nullptr);
-
+ static JsEnginePtr New(const AppInfo& appInfo, Platform& platform);
/**
* Registers the callback function for an event.
* @param eventName Event name. Note that this can be any string - it's a
@@ -272,18 +245,6 @@ namespace AdblockPlus
JsValueList ConvertArguments(const v8::FunctionCallbackInfo<v8::Value>& arguments);
/**
- * Private functionality.
- * @return The asynchronous IFileSystem implementation.
- */
- FileSystemPtr GetAsyncFileSystem() const;
-
- /**
- * Private functionality.
- * @return The LogSystem implementation.
- */
- LogSystem& GetLogSystem();
-
- /**
* Sets a global property that can be accessed by all the scripts.
* @param name Name of the property to set.
* @param value Value of the property to set.
@@ -303,26 +264,31 @@ namespace AdblockPlus
* garbage collection.
*/
void NotifyLowMemory();
+
+ /**
+ * Private functionality.
+ */
+ Platform& GetPlatform()
+ {
+ return platform;
+ }
private:
void CallTimerTask(const JsWeakValuesID& timerParamsID);
- explicit JsEngine(TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr webRequest, LogSystemPtr logSystem);
+ explicit JsEngine(Platform& platform);
JsValue GetGlobalObject();
/// Isolate must be disposed only after disposing of all objects which are
/// using it.
ScopedV8Isolate isolate;
+ Platform& platform;
hub 2017/07/28 14:29:03 The problem I see here is that there is no guarant
sergei 2017/07/28 15:10:29 Right but it should be the responsibility of a use
hub 2017/07/28 18:16:38 No. It is the responsibility of the API to make it
sergei 2017/07/28 19:16:50 But we cannot do it right now because FilterEngine
- FileSystemPtr fileSystem;
- LogSystemPtr logSystem;
std::unique_ptr<v8::Global<v8::Context>> context;
EventMap eventCallbacks;
std::mutex eventCallbacksMutex;
JsWeakValuesLists jsWeakValuesLists;
std::mutex jsWeakValuesListsMutex;
- TimerPtr timer;
- WebRequestPtr webRequest;
};
}
« no previous file with comments | « include/AdblockPlus.h ('k') | include/AdblockPlus/Platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld