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

Side by Side Diff: include/AdblockPlus/JsEngine.h

Issue 6233220328718336: Issue #3593, #1197- fix isolate management (Closed)
Patch Set: Created June 11, 2015, 12:45 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/JsEngine.cpp » ('j') | src/JsEngine.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 namespace AdblockPlus 45 namespace AdblockPlus
46 { 46 {
47 class JsEngine; 47 class JsEngine;
48 48
49 /** 49 /**
50 * Shared smart pointer to a `JsEngine` instance. 50 * Shared smart pointer to a `JsEngine` instance.
51 */ 51 */
52 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; 52 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr;
53 53
54 /** 54 /**
55 * Scope based isolate manager. Creates a new isolate instance on
56 * constructing and disposes it on destructing.
57 */
58 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
59 {
60 public:
61 ScopedV8Isolate();
62 ~ScopedV8Isolate();
63 protected:
64 v8::Isolate* isolate;
65 };
66
67 /**
55 * JavaScript engine used by `FilterEngine`, wraps v8. 68 * JavaScript engine used by `FilterEngine`, wraps v8.
69 *
70 * It's inherited from ScopedV8Isolate to have isolate disposed only after
71 * disposing of all objects which are using it.
56 */ 72 */
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
57 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> 73 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine>, protected ScopedV8Isolate
58 { 74 {
59 friend class JsValue; 75 friend class JsValue;
60 friend class JsContext; 76 friend class JsContext;
61
62 public: 77 public:
63 /** 78 /**
64 * Event callback function. 79 * Event callback function.
65 */ 80 */
66 typedef std::tr1::function<void(JsValueList& params)> EventCallback; 81 typedef std::tr1::function<void(JsValueList& params)> EventCallback;
67 82
68 /** 83 /**
69 * Maps events to callback functions. 84 * Maps events to callback functions.
70 */ 85 */
71 typedef std::map<std::string, EventCallback> EventMap; 86 typedef std::map<std::string, EventCallback> EventMap;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 * Sets the `LogSystem` implementation used for logging (e.g. to handle 221 * Sets the `LogSystem` implementation used for logging (e.g. to handle
207 * `console.log()` calls from JavaScript). 222 * `console.log()` calls from JavaScript).
208 * Setting this is optional, the engine will use a `DefaultLogSystem` 223 * Setting this is optional, the engine will use a `DefaultLogSystem`
209 * instance by default, which might be sufficient. 224 * instance by default, which might be sufficient.
210 * @param The `LogSystem` instance to use. 225 * @param The `LogSystem` instance to use.
211 */ 226 */
212 void SetLogSystem(LogSystemPtr val); 227 void SetLogSystem(LogSystemPtr val);
213 228
214 private: 229 private:
215 JsEngine(); 230 JsEngine();
216
217 FileSystemPtr fileSystem; 231 FileSystemPtr fileSystem;
218 WebRequestPtr webRequest; 232 WebRequestPtr webRequest;
219 LogSystemPtr logSystem; 233 LogSystemPtr logSystem;
220 v8::Isolate* isolate;
Eric 2015/08/05 22:29:16 Declared fourth, not first. Just fix it here.
221 V8ValueHolder<v8::Context> context; 234 V8ValueHolder<v8::Context> context;
222 EventMap eventCallbacks; 235 EventMap eventCallbacks;
223 }; 236 };
224 } 237 }
225 238
226 #endif 239 #endif
OLDNEW
« no previous file with comments | « no previous file | src/JsEngine.cpp » ('j') | src/JsEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld