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-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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 std::lock_guard<std::mutex> lock(eventCallbacksMutex); | 180 std::lock_guard<std::mutex> lock(eventCallbacksMutex); |
181 eventCallbacks[eventName] = callback; | 181 eventCallbacks[eventName] = callback; |
182 } | 182 } |
183 | 183 |
184 void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName) | 184 void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName) |
185 { | 185 { |
186 std::lock_guard<std::mutex> lock(eventCallbacksMutex); | 186 std::lock_guard<std::mutex> lock(eventCallbacksMutex); |
187 eventCallbacks.erase(eventName); | 187 eventCallbacks.erase(eventName); |
188 } | 188 } |
189 | 189 |
190 void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, const Adb
lockPlus::JsValueList& params) | 190 void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, AdblockPl
us::JsValueList&& params) |
191 { | 191 { |
192 EventCallback callback; | 192 EventCallback callback; |
193 { | 193 { |
194 std::lock_guard<std::mutex> lock(eventCallbacksMutex); | 194 std::lock_guard<std::mutex> lock(eventCallbacksMutex); |
195 auto it = eventCallbacks.find(eventName); | 195 auto it = eventCallbacks.find(eventName); |
196 if (it == eventCallbacks.end()) | 196 if (it == eventCallbacks.end()) |
197 return; | 197 return; |
198 callback = it->second; | 198 callback = it->second; |
199 } | 199 } |
200 callback(params); | 200 callback(move(params)); |
201 } | 201 } |
202 | 202 |
203 void AdblockPlus::JsEngine::Gc() | 203 void AdblockPlus::JsEngine::Gc() |
204 { | 204 { |
205 while (!v8::V8::IdleNotification()); | 205 while (!v8::V8::IdleNotification()); |
206 } | 206 } |
207 | 207 |
208 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val) | 208 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val) |
209 { | 209 { |
210 const JsContext context(*this); | 210 const JsContext context(*this); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 logSystem = val; | 323 logSystem = val; |
324 } | 324 } |
325 | 325 |
326 | 326 |
327 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, | 327 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, |
328 const AdblockPlus::JsValue& value) | 328 const AdblockPlus::JsValue& value) |
329 { | 329 { |
330 auto global = GetGlobalObject(); | 330 auto global = GetGlobalObject(); |
331 global.SetProperty(name, value); | 331 global.SetProperty(name, value); |
332 } | 332 } |
OLD | NEW |