| OLD | NEW |
| 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-2016 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 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 * Event callback function. | 86 * Event callback function. |
| 87 */ | 87 */ |
| 88 typedef std::function<void(JsValueList& params)> EventCallback; | 88 typedef std::function<void(JsValueList& params)> EventCallback; |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Maps events to callback functions. | 91 * Maps events to callback functions. |
| 92 */ | 92 */ |
| 93 typedef std::map<std::string, EventCallback> EventMap; | 93 typedef std::map<std::string, EventCallback> EventMap; |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Exception which is thrown when JsEngine is not available. |
| 97 * |
| 98 * For instance, if JsEngine is already released but someone calls a method |
| 99 * on JsValue this exception will be thrown. |
| 100 */ |
| 101 class JsEngineNotAvailableException : public std::runtime_error |
| 102 { |
| 103 public: |
| 104 JsEngineNotAvailableException() |
| 105 : std::runtime_error("JsEngine is not available") |
| 106 { |
| 107 } |
| 108 }; |
| 109 |
| 110 /** |
| 96 * Creates a new JavaScript engine instance. | 111 * Creates a new JavaScript engine instance. |
| 97 * @param appInfo Information about the app. | 112 * @param appInfo Information about the app. |
| 98 * @param isolate v8::Isolate wrapper. This parameter should be considered | 113 * @param isolate v8::Isolate wrapper. This parameter should be considered |
| 99 * as a temporary hack for tests, it will go away. Issue #3593. | 114 * as a temporary hack for tests, it will go away. Issue #3593. |
| 100 * @return New `JsEngine` instance. | 115 * @return New `JsEngine` instance. |
| 101 */ | 116 */ |
| 102 static JsEnginePtr New(const AppInfo& appInfo = AppInfo(), const ScopedV8Iso
latePtr& isolate = ScopedV8IsolatePtr(new ScopedV8Isolate())); | 117 static JsEnginePtr New(const AppInfo& appInfo = AppInfo(), const ScopedV8Iso
latePtr& isolate = ScopedV8IsolatePtr(new ScopedV8Isolate())); |
| 103 | 118 |
| 104 /** | 119 /** |
| 105 * Registers the callback function for an event. | 120 * Registers the callback function for an event. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 FileSystemPtr fileSystem; | 275 FileSystemPtr fileSystem; |
| 261 WebRequestPtr webRequest; | 276 WebRequestPtr webRequest; |
| 262 LogSystemPtr logSystem; | 277 LogSystemPtr logSystem; |
| 263 std::unique_ptr<v8::Persistent<v8::Context>> context; | 278 std::unique_ptr<v8::Persistent<v8::Context>> context; |
| 264 EventMap eventCallbacks; | 279 EventMap eventCallbacks; |
| 265 JsValuePtr globalJsObject; | 280 JsValuePtr globalJsObject; |
| 266 }; | 281 }; |
| 267 } | 282 } |
| 268 | 283 |
| 269 #endif | 284 #endif |
| OLD | NEW |