| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 AdblockPlus::JsValue AdblockPlus::JsEngine::GetGlobalObject() | 183 AdblockPlus::JsValue AdblockPlus::JsEngine::GetGlobalObject() |
| 184 { | 184 { |
| 185 JsContext context(*this); | 185 JsContext context(*this); |
| 186 return JsValue(shared_from_this(), context.GetV8Context()->Global()); | 186 return JsValue(shared_from_this(), context.GetV8Context()->Global()); |
| 187 } | 187 } |
| 188 | 188 |
| 189 AdblockPlus::JsValue AdblockPlus::JsEngine::Evaluate(const std::string& source, | 189 AdblockPlus::JsValue AdblockPlus::JsEngine::Evaluate(const std::string& source, |
| 190 const std::string& filename) | 190 const std::string& filename) |
| 191 { | 191 { |
| 192 const JsContext context(*this); | 192 const JsContext context(*this); |
| 193 const v8::TryCatch tryCatch; | 193 const v8::TryCatch tryCatch(GetIsolate()); |
| 194 const v8::Handle<v8::Script> script = CompileScript(GetIsolate(), source, | 194 const v8::Handle<v8::Script> script = CompileScript(GetIsolate(), source, |
| 195 filename); | 195 filename); |
| 196 CheckTryCatch(tryCatch); | 196 CheckTryCatch(tryCatch); |
| 197 v8::Local<v8::Value> result = script->Run(); | 197 v8::Local<v8::Value> result = script->Run(); |
| 198 CheckTryCatch(tryCatch); | 198 CheckTryCatch(tryCatch); |
| 199 return JsValue(shared_from_this(), result); | 199 return JsValue(shared_from_this(), result); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName, | 202 void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName, |
| 203 const AdblockPlus::JsEngine::EventCallback& callback) | 203 const AdblockPlus::JsEngine::EventCallback& callback) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 225 auto it = eventCallbacks.find(eventName); | 225 auto it = eventCallbacks.find(eventName); |
| 226 if (it == eventCallbacks.end()) | 226 if (it == eventCallbacks.end()) |
| 227 return; | 227 return; |
| 228 callback = it->second; | 228 callback = it->second; |
| 229 } | 229 } |
| 230 callback(move(params)); | 230 callback(move(params)); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void AdblockPlus::JsEngine::Gc() | 233 void AdblockPlus::JsEngine::Gc() |
| 234 { | 234 { |
| 235 while (!GetIsolate()->IdleNotification(1000)); | 235 while (!GetIsolate()->IdleNotificationDeadline(1000)); |
| 236 } | 236 } |
| 237 | 237 |
| 238 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val) | 238 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val) |
| 239 { | 239 { |
| 240 const JsContext context(*this); | 240 const JsContext context(*this); |
| 241 return JsValue(shared_from_this(), Utils::ToV8String(GetIsolate(), val)); | 241 return JsValue(shared_from_this(), Utils::ToV8String(GetIsolate(), val)); |
| 242 } | 242 } |
| 243 | 243 |
| 244 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(int64_t val) | 244 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(int64_t val) |
| 245 { | 245 { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 list.push_back(JsValue(shared_from_this(), arguments[i])); | 340 list.push_back(JsValue(shared_from_this(), arguments[i])); |
| 341 return list; | 341 return list; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, | 344 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, |
| 345 const AdblockPlus::JsValue& value) | 345 const AdblockPlus::JsValue& value) |
| 346 { | 346 { |
| 347 auto global = GetGlobalObject(); | 347 auto global = GetGlobalObject(); |
| 348 global.SetProperty(name, value); | 348 global.SetProperty(name, value); |
| 349 } | 349 } |
| OLD | NEW |