| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 { | 86 { |
| 87 const Context context(shared_from_this()); | 87 const Context context(shared_from_this()); |
| 88 const v8::TryCatch tryCatch; | 88 const v8::TryCatch tryCatch; |
| 89 const v8::Handle<v8::Script> script = CompileScript(source, filename); | 89 const v8::Handle<v8::Script> script = CompileScript(source, filename); |
| 90 CheckTryCatch(tryCatch); | 90 CheckTryCatch(tryCatch); |
| 91 v8::Local<v8::Value> result = script->Run(); | 91 v8::Local<v8::Value> result = script->Run(); |
| 92 CheckTryCatch(tryCatch); | 92 CheckTryCatch(tryCatch); |
| 93 return JsValuePtr(new JsValue(shared_from_this(), result)); | 93 return JsValuePtr(new JsValue(shared_from_this(), result)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void AdblockPlus::JsEngine::SetInitCallback(AdblockPlus::JsEngine::InitCallback
callback) |
| 97 { |
| 98 initCallback = callback; |
| 99 } |
| 100 |
| 101 void AdblockPlus::JsEngine::InitDone() |
| 102 { |
| 103 // Zero out callback immediately to prevent reentrance |
| 104 InitCallback callback = initCallback; |
| 105 initCallback = 0; |
| 106 if (callback) |
| 107 callback(); |
| 108 } |
| 109 |
| 96 void AdblockPlus::JsEngine::Gc() | 110 void AdblockPlus::JsEngine::Gc() |
| 97 { | 111 { |
| 98 while (!v8::V8::IdleNotification()); | 112 while (!v8::V8::IdleNotification()); |
| 99 } | 113 } |
| 100 | 114 |
| 101 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val) | 115 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val) |
| 102 { | 116 { |
| 103 const Context context(shared_from_this()); | 117 const Context context(shared_from_this()); |
| 104 return JsValuePtr(new JsValue(shared_from_this(), | 118 return JsValuePtr(new JsValue(shared_from_this(), |
| 105 v8::String::New(val.c_str(), val.length()))); | 119 v8::String::New(val.c_str(), val.length()))); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 throw std::runtime_error("LogSystem cannot be null"); | 215 throw std::runtime_error("LogSystem cannot be null"); |
| 202 | 216 |
| 203 logSystem = val; | 217 logSystem = val; |
| 204 } | 218 } |
| 205 | 219 |
| 206 AdblockPlus::JsEngine::Context::Context(const JsEnginePtr jsEngine) | 220 AdblockPlus::JsEngine::Context::Context(const JsEnginePtr jsEngine) |
| 207 : locker(jsEngine->isolate), handleScope(), | 221 : locker(jsEngine->isolate), handleScope(), |
| 208 contextScope(jsEngine->context) | 222 contextScope(jsEngine->context) |
| 209 { | 223 { |
| 210 } | 224 } |
| OLD | NEW |