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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 29453572: Issue 5286 - Update to use libadblockplus rev. b88d098aeab5 (Closed)
Patch Set: Created June 1, 2017, 11:10 a.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/IWebRequest.h ('k') | include/AdblockPlus/WebRequest.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 f54b98febd3d256ac88fa027c572aae948bd24bc..63f929c94a0b481b33ec3270d50a6ab51408540b 100644
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -57,6 +57,11 @@ namespace AdblockPlus
TimerPtr CreateDefaultTimer();
/**
+ * A factory to construct DefaultWebRequest.
+ */
+ WebRequestPtr CreateDefaultWebRequest();
+
+ /**
* Scope based isolate manager. Creates a new isolate instance on
* constructing and disposes it on destructing.
*/
@@ -77,11 +82,6 @@ namespace AdblockPlus
};
/**
- * Shared smart pointer to ScopedV8Isolate instance;
- */
- typedef std::shared_ptr<ScopedV8Isolate> ScopedV8IsolatePtr;
-
- /**
* JavaScript engine used by `FilterEngine`, wraps v8.
*/
class JsEngine : public std::enable_shared_from_this<JsEngine>
@@ -120,13 +120,14 @@ namespace AdblockPlus
* Creates a new JavaScript engine instance.
* @param appInfo Information about the app.
* @param timer Implementation of timer.
+ * @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(),
- const ScopedV8IsolatePtr& isolate = ScopedV8IsolatePtr(new ScopedV8Isolate()));
+ WebRequestPtr webRequest = CreateDefaultWebRequest());
/**
* Registers the callback function for an event.
@@ -241,6 +242,13 @@ namespace AdblockPlus
*/
static void ScheduleTimer(const v8::Arguments& arguments);
+ /*
+ * Private functionality required to implement web requests.
+ * @param arguments `v8::Arguments` is the arguments received in C++
+ * callback associated for global GET method.
+ */
+ static void ScheduleWebRequest(const v8::Arguments& arguments);
+
/**
* Converts v8 arguments to `JsValue` objects.
* @param arguments `v8::Arguments` object containing the arguments to
@@ -263,17 +271,12 @@ namespace AdblockPlus
void SetFileSystem(const FileSystemPtr& val);
/**
- * @see `SetWebRequest()`.
- */
- WebRequestPtr GetWebRequest() const;
-
- /**
* 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 WebRequestPtr& val);
+ void SetWebRequest(const WebRequestSharedPtr& val);
/**
* @see `SetLogSystem()`.
@@ -301,22 +304,26 @@ namespace AdblockPlus
*/
v8::Isolate* GetIsolate()
{
- return isolate->Get();
+ return isolate.Get();
}
+ /**
+ * Notifies JS engine about critically low memory what should cause a
+ * garbage collection.
+ */
+ void NotifyLowMemory();
private:
void CallTimerTask(const JsWeakValuesID& timerParamsID);
- explicit JsEngine(const ScopedV8IsolatePtr& isolate, TimerPtr timer);
+ explicit JsEngine(TimerPtr timer, WebRequestPtr webRequest);
JsValue GetGlobalObject();
/// Isolate must be disposed only after disposing of all objects which are
/// using it.
- ScopedV8IsolatePtr isolate;
+ ScopedV8Isolate isolate;
FileSystemPtr fileSystem;
- WebRequestPtr webRequest;
LogSystemPtr logSystem;
std::unique_ptr<v8::Persistent<v8::Context>> context;
EventMap eventCallbacks;
@@ -324,6 +331,8 @@ namespace AdblockPlus
JsWeakValuesLists jsWeakValuesLists;
std::mutex jsWeakValuesListsMutex;
TimerPtr timer;
+ WebRequestPtr webRequest;
+ WebRequestSharedPtr webRequestLegacy;
};
}
« no previous file with comments | « include/AdblockPlus/IWebRequest.h ('k') | include/AdblockPlus/WebRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld