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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Remove a #include Utils.h from test. Created June 2, 2017, 7:38 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
Index: include/AdblockPlus/JsEngine.h
===================================================================
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -52,16 +52,21 @@
typedef std::shared_ptr<JsEngine> JsEnginePtr;
/**
* A factory to construct DefaultTimer.
*/
TimerPtr CreateDefaultTimer();
/**
+ * A factory to construct DefaultFileSystem.
+ */
+ FileSystemPtr CreateDefaultFileSystem();
+
+ /**
* A factory to construct DefaultWebRequest.
*/
WebRequestPtr CreateDefaultWebRequest();
/**
* Scope based isolate manager. Creates a new isolate instance on
* constructing and disposes it on destructing.
*/
@@ -115,23 +120,25 @@
friend class JsEngine;
JsWeakValuesLists::const_iterator iterator;
};
/**
* Creates a new JavaScript engine instance.
* @param appInfo Information about the app.
* @param timer Implementation of timer.
+ * @param fileSystem Implementation of filesystem.
* @param webRequest Implementation of web request.
* @param isolate v8::Isolate wrapper. This parameter should be considered
* as a temporary hack for tests, it will go away. Issue #3593.
* @return New `JsEngine` instance.
*/
static JsEnginePtr New(const AppInfo& appInfo = AppInfo(),
TimerPtr timer = CreateDefaultTimer(),
+ FileSystemPtr fileSystem = CreateDefaultFileSystem(),
WebRequestPtr webRequest = CreateDefaultWebRequest());
/**
* Registers the callback function for an event.
* @param eventName Event name. Note that this can be any string - it's a
* general purpose event handling mechanism.
* @param callback Event callback function.
*/
@@ -253,29 +260,21 @@
* Converts v8 arguments to `JsValue` objects.
* @param arguments `v8::Arguments` object containing the arguments to
* convert.
* @return List of arguments converted to `const JsValue` objects.
*/
JsValueList ConvertArguments(const v8::Arguments& arguments);
/**
- * @see `SetFileSystem()`.
+ * @return The asynchronous IFileSystem implementation.
*/
FileSystemPtr GetFileSystem() const;
sergei 2017/06/16 15:05:54 I think we can remove the getter but still have th
hub 2017/06/16 21:52:54 I need this accessor because it is use in FileSyst
/**
- * Sets the `FileSystem` implementation used for all file I/O.
- * Setting this is optional, the engine will use a `DefaultFileSystem`
- * instance by default, which might be sufficient.
- * @param The `FileSystem` instance to use.
- */
- void SetFileSystem(const FileSystemPtr& val);
-
- /**
* Sets the `WebRequest` implementation used for XMLHttpRequests.
* Setting this is optional, the engine will use a `DefaultWebRequest`
* instance by default, which might be sufficient.
* @param The `WebRequest` instance to use.
*/
void SetWebRequest(const WebRequestSharedPtr& val);
/**
@@ -310,17 +309,17 @@
/**
* Notifies JS engine about critically low memory what should cause a
* garbage collection.
*/
void NotifyLowMemory();
private:
void CallTimerTask(const JsWeakValuesID& timerParamsID);
- explicit JsEngine(TimerPtr timer, WebRequestPtr webRequest);
+ explicit JsEngine(TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr webRequest);
JsValue GetGlobalObject();
/// Isolate must be disposed only after disposing of all objects which are
/// using it.
ScopedV8Isolate isolate;
FileSystemPtr fileSystem;

Powered by Google App Engine
This is Rietveld