| Index: include/AdblockPlus/JsEngine.h |
| =================================================================== |
| --- a/include/AdblockPlus/JsEngine.h |
| +++ b/include/AdblockPlus/JsEngine.h |
| @@ -50,31 +50,6 @@ |
| typedef std::shared_ptr<JsEngine> JsEnginePtr; |
| /** |
| - * Scope based isolate manager. Creates a new isolate instance on |
| - * constructing and disposes it on destructing. |
| - */ |
| - class ScopedV8Isolate |
| - { |
| - public: |
| - ScopedV8Isolate(); |
| - ~ScopedV8Isolate(); |
| - v8::Isolate* Get() |
| - { |
| - return isolate; |
| - } |
| - private: |
| - ScopedV8Isolate(const ScopedV8Isolate&); |
| - ScopedV8Isolate& operator=(const ScopedV8Isolate&); |
| - |
| - v8::Isolate* isolate; |
| - }; |
| - |
| - /** |
| - * 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> |
| @@ -97,7 +72,7 @@ |
| * as a temporary hack for tests, it will go away. Issue #3593. |
| * @return New `JsEngine` instance. |
| */ |
| - static JsEnginePtr New(const AppInfo& appInfo = AppInfo(), const ScopedV8IsolatePtr& isolate = ScopedV8IsolatePtr(new ScopedV8Isolate())); |
| + static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); |
| /** |
| * Registers the callback function for an event. |
| @@ -243,13 +218,22 @@ |
| /** |
| * Returns a pointer to associated v8::Isolate. |
| */ |
| - v8::Isolate* GetIsolate() |
| + v8::Isolate* GetIsolate() const |
| { |
| - return isolate->Get(); |
| + return isolate; |
| } |
| + /// Ordinary destructor |
| + ~JsEngine(); |
| + |
| protected: |
| - explicit JsEngine(const ScopedV8IsolatePtr& isolate); |
| + /** |
| + * Non-public constructor enforces factory use. |
| + * |
| + * @param isolate |
| + * v8 isolate obtained from its factory |
| + */ |
| + explicit JsEngine(v8::Isolate* isolate); |
| /** |
| * Retrieve the global object as a JsValuePtr |
| @@ -259,9 +243,12 @@ |
| */ |
| JsValuePtr GetGlobalObject(); |
| - /// Isolate must be disposed only after disposing of all objects which are |
| - /// using it. |
| - ScopedV8IsolatePtr isolate; |
| + /** |
| + * Isolate member must be have life span that encompasses any other object |
| + * that uses it. Thus it's declared first so that it is constructed first |
| + * and destroyed last. |
| + */ |
| + v8::Isolate* isolate; |
| FileSystemPtr fileSystem; |
| WebRequestPtr webRequest; |