Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 * JavaScript engine used by `FilterEngine`, wraps v8. | 89 * JavaScript engine used by `FilterEngine`, wraps v8. |
90 */ | 90 */ |
91 class JsEngine : public std::enable_shared_from_this<JsEngine> | 91 class JsEngine : public std::enable_shared_from_this<JsEngine> |
92 { | 92 { |
93 friend class JsValue; | 93 friend class JsValue; |
94 friend class JsContext; | 94 friend class JsContext; |
95 | 95 |
96 struct JsWeakValuesList | 96 struct JsWeakValuesList |
97 { | 97 { |
98 ~JsWeakValuesList(); | 98 ~JsWeakValuesList(); |
99 std::vector<v8::Global<v8::Value>> values; | 99 std::vector<v8::Global<v8::Value>> values; |
sergei
2017/07/03 09:25:54
Wow, it seems to be rebased on new v8. That's very
hub
2017/07/04 19:58:27
Yes I did rebase on top of your patch. I was expec
| |
100 }; | 100 }; |
101 typedef std::list<JsWeakValuesList> JsWeakValuesLists; | 101 typedef std::list<JsWeakValuesList> JsWeakValuesLists; |
102 public: | 102 public: |
103 /** | 103 /** |
104 * Event callback function. | 104 * Event callback function. |
105 */ | 105 */ |
106 typedef std::function<void(JsValueList&& params)> EventCallback; | 106 typedef std::function<void(JsValueList&& params)> EventCallback; |
107 | 107 |
108 /** | 108 /** |
109 * Maps events to callback functions. | 109 * Maps events to callback functions. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 | 257 |
258 /** | 258 /** |
259 * Converts v8 arguments to `JsValue` objects. | 259 * Converts v8 arguments to `JsValue` objects. |
260 * @param arguments `v8::FunctionCallbackInfo` object containing the argumen ts to | 260 * @param arguments `v8::FunctionCallbackInfo` object containing the argumen ts to |
261 * convert. | 261 * convert. |
262 * @return List of arguments converted to `const JsValue` objects. | 262 * @return List of arguments converted to `const JsValue` objects. |
263 */ | 263 */ |
264 JsValueList ConvertArguments(const v8::FunctionCallbackInfo<v8::Value>& argu ments); | 264 JsValueList ConvertArguments(const v8::FunctionCallbackInfo<v8::Value>& argu ments); |
265 | 265 |
266 /** | 266 /** |
267 * Private functionality. | |
267 * @return The asynchronous IFileSystem implementation. | 268 * @return The asynchronous IFileSystem implementation. |
268 */ | 269 */ |
269 FileSystemPtr GetAsyncFileSystem() const; | 270 FileSystemPtr GetAsyncFileSystem() const; |
sergei
2017/07/03 09:25:54
From https://codereview.adblockplus.org/29449592/d
hub
2017/07/04 19:58:26
Acknowledged.
| |
270 | 271 |
271 /** | 272 /** |
272 * Sets the synchronous `FileSystem` implementation used for all | 273 * Sets the synchronous `FileSystem` implementation used for all |
273 * file I/O. Setting this is optional, the engine will use a | 274 * file I/O. Setting this is optional, the engine will use the |
274 * `DefaultFileSystemSync` instance by default, which might be | 275 * implementation created by `CreateDefaultFileSystem()` by |
sergei
2017/07/03 09:25:54
I think the comment should be a bit adjusted. By d
hub
2017/07/04 19:58:26
Acknowledged.
| |
275 * sufficient. | 276 * default, which might be sufficient. |
276 * @param The `FileSystem` instance to use. | 277 * @param The `FileSystem` instance to use. |
277 */ | 278 */ |
278 void SetFileSystem(const FileSystemSyncPtr& val); | 279 void SetFileSystem(const FileSystemSyncPtr& val); |
279 | 280 |
280 /** | 281 /** |
281 * Sets the `WebRequest` implementation used for XMLHttpRequests. | 282 * Sets the `WebRequest` implementation used for XMLHttpRequests. |
282 * Setting this is optional, the engine will use a `DefaultWebRequest` | 283 * Setting this is optional, the engine will use a `DefaultWebRequest` |
283 * instance by default, which might be sufficient. | 284 * instance by default, which might be sufficient. |
284 * @param The `WebRequest` instance to use. | 285 * @param The `WebRequest` instance to use. |
285 */ | 286 */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 | 325 |
325 explicit JsEngine(TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr we bRequest); | 326 explicit JsEngine(TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr we bRequest); |
326 | 327 |
327 JsValue GetGlobalObject(); | 328 JsValue GetGlobalObject(); |
328 | 329 |
329 /// Isolate must be disposed only after disposing of all objects which are | 330 /// Isolate must be disposed only after disposing of all objects which are |
330 /// using it. | 331 /// using it. |
331 ScopedV8Isolate isolate; | 332 ScopedV8Isolate isolate; |
332 | 333 |
333 FileSystemPtr fileSystem; | 334 FileSystemPtr fileSystem; |
334 FileSystemSyncPtr fileSystemLegacy; | |
335 LogSystemPtr logSystem; | 335 LogSystemPtr logSystem; |
336 std::unique_ptr<v8::Global<v8::Context>> context; | 336 std::unique_ptr<v8::Global<v8::Context>> context; |
337 EventMap eventCallbacks; | 337 EventMap eventCallbacks; |
338 std::mutex eventCallbacksMutex; | 338 std::mutex eventCallbacksMutex; |
339 JsWeakValuesLists jsWeakValuesLists; | 339 JsWeakValuesLists jsWeakValuesLists; |
340 std::mutex jsWeakValuesListsMutex; | 340 std::mutex jsWeakValuesListsMutex; |
341 TimerPtr timer; | 341 TimerPtr timer; |
342 WebRequestPtr webRequest; | 342 WebRequestPtr webRequest; |
343 WebRequestSharedPtr webRequestLegacy; | 343 WebRequestSharedPtr webRequestLegacy; |
344 }; | 344 }; |
345 } | 345 } |
346 | 346 |
347 #endif | 347 #endif |
LEFT | RIGHT |