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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 29508624: Issue 5473 - Update to use libadblockplus revision b4d6e55f2116 (Closed)
Patch Set: Created Aug. 7, 2017, 12:41 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/IFileSystem.h ('k') | include/AdblockPlus/JsValue.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 63f929c94a0b481b33ec3270d50a6ab51408540b..f7470ab84367b00e298c9038d92b21837fb08202 100644
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -34,12 +34,11 @@
namespace v8
{
- class Arguments;
class Isolate;
class Value;
class Context;
- template<class T> class Handle;
- typedef Handle<Value>(*InvocationCallback)(const Arguments &args);
+ template<typename T> class FunctionCallbackInfo;
+ typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>& info);
}
namespace AdblockPlus
@@ -57,6 +56,11 @@ namespace AdblockPlus
TimerPtr CreateDefaultTimer();
/**
+ * A factory to construct DefaultFileSystem.
+ */
+ FileSystemPtr CreateDefaultFileSystem();
+
+ /**
* A factory to construct DefaultWebRequest.
*/
WebRequestPtr CreateDefaultWebRequest();
@@ -92,7 +96,7 @@ namespace AdblockPlus
struct JsWeakValuesList
{
~JsWeakValuesList();
- std::vector<std::unique_ptr<v8::Persistent<v8::Value>>> values;
+ std::vector<v8::Global<v8::Value>> values;
};
typedef std::list<JsWeakValuesList> JsWeakValuesLists;
public:
@@ -120,13 +124,13 @@ namespace AdblockPlus
* 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());
/**
@@ -199,21 +203,21 @@ namespace AdblockPlus
/**
* Creates a JavaScript function that invokes a C++ callback.
* @param callback C++ callback to invoke. The callback receives a
- * `v8::Arguments` object and can use `FromArguments()` to retrieve
+ * `v8::FunctionCallbackInfo` object and can use `FromArguments()` to retrieve
* the current `JsEngine`.
* @return New `JsValue` instance.
*/
- JsValue NewCallback(const v8::InvocationCallback& callback);
+ JsValue NewCallback(const v8::FunctionCallback& callback);
/**
- * Returns a `JsEngine` instance contained in a `v8::Arguments` object.
+ * Returns a `JsEngine` instance contained in a `v8::FunctionCallbackInfo` object.
* Use this in callbacks created via `NewCallback()` to retrieve the current
* `JsEngine`.
- * @param arguments `v8::Arguments` object containing the `JsEngine`
+ * @param arguments `v8::FunctionCallbackInfo` object containing the `JsEngine`
* instance.
- * @return `JsEngine` instance from `v8::Arguments`.
+ * @return `JsEngine` instance from `v8::FunctionCallbackInfo`.
*/
- static JsEnginePtr FromArguments(const v8::Arguments& arguments);
+ static JsEnginePtr FromArguments(const v8::FunctionCallbackInfo<v8::Value>& arguments);
/**
* Stores `JsValue`s in a way they don't keep a strong reference to
@@ -237,38 +241,40 @@ namespace AdblockPlus
/*
* Private functionality required to implement timers.
- * @param arguments `v8::Arguments` is the arguments received in C++
+ * @param arguments `v8::FunctionCallbackInfo` is the arguments received in C++
* callback associated for global setTimeout method.
*/
- static void ScheduleTimer(const v8::Arguments& arguments);
+ static void ScheduleTimer(const v8::FunctionCallbackInfo<v8::Value>& arguments);
/*
* Private functionality required to implement web requests.
- * @param arguments `v8::Arguments` is the arguments received in C++
+ * @param arguments `v8::FunctionCallbackInfo` is the arguments received in C++
* callback associated for global GET method.
*/
- static void ScheduleWebRequest(const v8::Arguments& arguments);
+ static void ScheduleWebRequest(const v8::FunctionCallbackInfo<v8::Value>& arguments);
/**
* Converts v8 arguments to `JsValue` objects.
- * @param arguments `v8::Arguments` object containing the arguments to
+ * @param arguments `v8::FunctionCallbackInfo` object containing the arguments to
* convert.
* @return List of arguments converted to `const JsValue` objects.
*/
- JsValueList ConvertArguments(const v8::Arguments& arguments);
+ JsValueList ConvertArguments(const v8::FunctionCallbackInfo<v8::Value>& arguments);
/**
- * @see `SetFileSystem()`.
+ * Private functionality.
+ * @return The asynchronous IFileSystem implementation.
*/
- FileSystemPtr GetFileSystem() const;
+ FileSystemPtr GetAsyncFileSystem() const;
/**
- * 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.
+ * Sets the synchronous `FileSystem` implementation used for all
+ * file I/O. Setting this is optional, the engine will use the
+ * implementation created by `CreateDefaultFileSystem()` by
+ * default, which might be sufficient.
* @param The `FileSystem` instance to use.
*/
- void SetFileSystem(const FileSystemPtr& val);
+ void SetFileSystem(const FileSystemSyncPtr& val);
/**
* Sets the `WebRequest` implementation used for XMLHttpRequests.
@@ -315,7 +321,7 @@ namespace AdblockPlus
private:
void CallTimerTask(const JsWeakValuesID& timerParamsID);
- explicit JsEngine(TimerPtr timer, WebRequestPtr webRequest);
+ explicit JsEngine(TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr webRequest);
JsValue GetGlobalObject();
@@ -325,7 +331,7 @@ namespace AdblockPlus
FileSystemPtr fileSystem;
LogSystemPtr logSystem;
- std::unique_ptr<v8::Persistent<v8::Context>> context;
+ std::unique_ptr<v8::Global<v8::Context>> context;
EventMap eventCallbacks;
std::mutex eventCallbacksMutex;
JsWeakValuesLists jsWeakValuesLists;
« no previous file with comments | « include/AdblockPlus/IFileSystem.h ('k') | include/AdblockPlus/JsValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld