| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #ifndef ADBLOCK_PLUS_JS_ENGINE_H | 18 #ifndef ADBLOCK_PLUS_JS_ENGINE_H |
| 19 #define ADBLOCK_PLUS_JS_ENGINE_H | 19 #define ADBLOCK_PLUS_JS_ENGINE_H |
| 20 | 20 |
| 21 #include <functional> |
| 21 #include <map> | 22 #include <map> |
| 22 #include <stdexcept> | 23 #include <stdexcept> |
| 23 #include <stdint.h> | 24 #include <stdint.h> |
| 24 #include <string> | 25 #include <string> |
| 25 #include <AdblockPlus/AppInfo.h> | 26 #include <AdblockPlus/AppInfo.h> |
| 26 #include <AdblockPlus/tr1_functional.h> | |
| 27 #include <AdblockPlus/LogSystem.h> | 27 #include <AdblockPlus/LogSystem.h> |
| 28 #include <AdblockPlus/FileSystem.h> | 28 #include <AdblockPlus/FileSystem.h> |
| 29 #include <AdblockPlus/JsValue.h> | 29 #include <AdblockPlus/JsValue.h> |
| 30 #include <AdblockPlus/WebRequest.h> | 30 #include <AdblockPlus/WebRequest.h> |
| 31 | |
| 32 #include "tr1_memory.h" | |
| 33 | 31 |
| 34 namespace v8 | 32 namespace v8 |
| 35 { | 33 { |
| 36 class Arguments; | 34 class Arguments; |
| 37 class Isolate; | 35 class Isolate; |
| 38 class Value; | 36 class Value; |
| 39 class Context; | 37 class Context; |
| 40 template<class T> class Handle; | 38 template<class T> class Handle; |
| 41 typedef Handle<Value>(*InvocationCallback)(const Arguments &args); | 39 typedef Handle<Value>(*InvocationCallback)(const Arguments &args); |
| 42 } | 40 } |
| 43 | 41 |
| 44 namespace AdblockPlus | 42 namespace AdblockPlus |
| 45 { | 43 { |
| 46 class JsEngine; | 44 class JsEngine; |
| 47 | 45 |
| 48 /** | 46 /** |
| 49 * Shared smart pointer to a `JsEngine` instance. | 47 * Shared smart pointer to a `JsEngine` instance. |
| 50 */ | 48 */ |
| 51 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; | 49 typedef std::shared_ptr<JsEngine> JsEnginePtr; |
| 52 | 50 |
| 53 /** | 51 /** |
| 54 * JavaScript engine used by `FilterEngine`, wraps v8. | 52 * JavaScript engine used by `FilterEngine`, wraps v8. |
| 55 */ | 53 */ |
| 56 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> | 54 class JsEngine : public std::enable_shared_from_this<JsEngine> |
| 57 { | 55 { |
| 58 friend class JsValue; | 56 friend class JsValue; |
| 59 friend class JsContext; | 57 friend class JsContext; |
| 60 | 58 |
| 61 public: | 59 public: |
| 62 /** | 60 /** |
| 63 * Event callback function. | 61 * Event callback function. |
| 64 */ | 62 */ |
| 65 typedef std::tr1::function<void(JsValueList& params)> EventCallback; | 63 typedef std::function<void(JsValueList& params)> EventCallback; |
| 66 | 64 |
| 67 /** | 65 /** |
| 68 * Maps events to callback functions. | 66 * Maps events to callback functions. |
| 69 */ | 67 */ |
| 70 typedef std::map<std::string, EventCallback> EventMap; | 68 typedef std::map<std::string, EventCallback> EventMap; |
| 71 | 69 |
| 72 /** | 70 /** |
| 73 * Creates a new JavaScript engine instance. | 71 * Creates a new JavaScript engine instance. |
| 74 * @param appInfo Information about the app. | 72 * @param appInfo Information about the app. |
| 75 * @return New `JsEngine` instance. | 73 * @return New `JsEngine` instance. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 WebRequestPtr webRequest; | 222 WebRequestPtr webRequest; |
| 225 LogSystemPtr logSystem; | 223 LogSystemPtr logSystem; |
| 226 v8::Isolate* isolate; | 224 v8::Isolate* isolate; |
| 227 std::unique_ptr<v8::Persistent<v8::Context>> context; | 225 std::unique_ptr<v8::Persistent<v8::Context>> context; |
| 228 EventMap eventCallbacks; | 226 EventMap eventCallbacks; |
| 229 JsValuePtr globalJsObject; | 227 JsValuePtr globalJsObject; |
| 230 }; | 228 }; |
| 231 } | 229 } |
| 232 | 230 |
| 233 #endif | 231 #endif |
| LEFT | RIGHT |