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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 6233220328718336: Issue #3593, #1197- fix isolate management (Closed)
Patch Set: Created June 11, 2015, 12:45 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 | « no previous file | src/JsEngine.cpp » ('j') | src/JsEngine.cpp » ('J')
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 c82ae02d5b24cae3c40737c19286968388dc7615..0bb0b89df2d904d1845bb010a72a05bb885d4567 100644
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -52,13 +52,28 @@ namespace AdblockPlus
typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr;
/**
+ * Scope based isolate manager. Creates a new isolate instance on
+ * constructing and disposes it on destructing.
+ */
+ class ScopedV8Isolate
Eric 2015/08/05 22:29:16 There's no need for this class. Member constructio
sergei 2015/11/16 16:52:09 Thanks for explanation but this class and construc
+ {
+ public:
+ ScopedV8Isolate();
+ ~ScopedV8Isolate();
+ protected:
+ v8::Isolate* isolate;
+ };
+
+ /**
* JavaScript engine used by `FilterEngine`, wraps v8.
+ *
+ * It's inherited from ScopedV8Isolate to have isolate disposed only after
+ * disposing of all objects which are using it.
*/
Eric 2015/08/05 22:29:16 Keep this comment (after a rewrite) at the declara
sergei 2015/11/16 16:52:09 I've inherited because it's more reliable than the
Eric 2015/11/17 21:27:43 Whatever other reason you might want for it, argui
- class JsEngine : public std::tr1::enable_shared_from_this<JsEngine>
+ class JsEngine : public std::tr1::enable_shared_from_this<JsEngine>, protected ScopedV8Isolate
{
friend class JsValue;
friend class JsContext;
-
public:
/**
* Event callback function.
@@ -213,11 +228,9 @@ namespace AdblockPlus
private:
JsEngine();
-
FileSystemPtr fileSystem;
WebRequestPtr webRequest;
LogSystemPtr logSystem;
- v8::Isolate* isolate;
Eric 2015/08/05 22:29:16 Declared fourth, not first. Just fix it here.
V8ValueHolder<v8::Context> context;
EventMap eventCallbacks;
};
« no previous file with comments | « no previous file | src/JsEngine.cpp » ('j') | src/JsEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld